Archives

gravatar

FON AP: Always Turn On SSH

在 /www/cgi-bin/webif/upgrade.sh 中,有這樣的步驟,會把原先設定的一些資料保存下來,不會因為 FON AP 使用 web 管理界面的 upgrade 把整個 NVRAM 給 flash 掉而消失。而設定要怎麼保存?

tar czf /tmp/config.tar.gz /etc/config/
mtd write /tmp/config.tar.gz config > /dev/null

簡單的說就是把 /etc/config 整個 tar 起來後,透過 mtd 把設定寫入,之後 upgrade 完成後,應該也是照反向方法把設定取回。所以先前設定的像是 public/private SSID、WPA 密碼、network 設定等等,都會保存著。所以我想透過 /etc/config 裡面的修改,嘗試看看讓原本修改 /etc/init.d/dropbear 和 /etc/firewall.user 的方式,變成不需要更動,而依然可以保有 SSH login 功能。原理在於 /etc/config/openports 這個 script,是提供 port forwarding 的設定,以下是我嘗試的修改:

#!/bin/sh
. /etc/functions.sh
iptables -t nat -A prerouting_rule -i $1 -p tcp –dport 22 -j ACCEPT
iptables -A input_rule -i $1 -p tcp –dport 22 -j ACCEPT
[ ! -f /var/run/dropbear.pid ] && /usr/sbin/dropbear
# 在 web 上設定的 port forwarding 會被 append 在後面
open_port $1 22 192.168.10.10 22 udp
open_port $1 22 192.168.10.10 22 tcp

/etc/config/openports 是在啟動時候,由 /etc/init.d/S45firewall 所執行,啟動的命令列大概是 /etc/config/openports eth0。所以 iptables 會把 eth0 的 port 22 打開,同時如果發現 /var/run/dropbear.pid 不存在,則去執行 dropbear 來啟動 SSH daemon。

註:單純理論上測試,還沒真正完全 upgrade 0.7.1r2 ROM image 試驗過。

gravatar

啟用 La Fonera 的 SSH

參考打開0.7.1r1的SSH,由於 0.7.1.1 (0.7.1r1) 的 Firmware 在 Router 網頁管理界面上有漏洞,因此可以透過 HTML Form 的方式把指令 submit 給 AP 上的 CGI 執行,依序先讓 iptables 允許 port 22 的連線,接著把 SSH (dropbear) deamon 啟動。接著就可以透過 ssh 連接到 FON 然後登入。
但是,我收到的 AP firmware 是 0.7.1.2 (0.7.1r2) 版本,這個漏洞已經被修掉了,所以沒辦法如法炮製。但是看到不少論壇或是 BBS 有很多人說無法由 0.7.1.2 downgrade 到 0.7.1.1,但是我試了卻沒有問題,可以回到 0.7.1.1 的 firmware。首先下載 0.7.1.1 的 firmware,官方網站已經不提供這個版本下載,但是可以透過 google search 找到例如這個網站,裡面有不少版本的 firmwares。下載之後,看要把分享器的 ADSL 關閉,還是 HUB 的 WAN 拔掉,總之讓他無法連到 internet,然後拔掉電源重新啟動 FON AP(註1)。
然後等一段時間讓 FON AP 開機後,透過無線網路連到任何網站。因為沒有 internet 連線,所以 FON 會顯示連線問題的頁面,接著就到 Advanced 的 Firmware Upgrade 去把 0.7.1.1 的韌體更新上去。更新後他會自己重新開機,同時也不要讓他可以連到 internet。同樣一段時間後,也是可以透過無線連接他的 Router 管理界面。接著就是做下面的事情,允許 port 22 的連線,


<html>
<head>
</head>
<body>
<center>
<form method=”post” action=”http://192.168.10.1/cgi-bin/webif/connection.sh” enctype=”multipart/form-data”>
<input name=”username” value=”$(/usr/sbin/iptables -I INPUT 1 -p tcp –dport 22 -j ACCEPT)” size=”68″ >
<input type=”submit” name=”submit” value=”Submit” onClick=”{this.form.wifimode.value=’”;’ + this.form.wifimode.value +’;”‘}” />
</form>
</body>
</html>

啟動 SSH daemon (dropbear)


<html>
<head>
</head>
<body>
<center>
<form method=”post” action=”http://192.168.10.1/cgi-bin/webif/connection.sh” enctype=”multipart/form-data”>
<input name=”username” value=”$(/etc/init.d/dropbear)” size=”68″ >
<input type=”submit” name=”submit” value=”Submit” onClick=”{this.form.wifimode.value=’”;’ + this.form.wifimode.value +’;”‘}” />
</form>
</body>
</html>

分別存成兩個 html 檔案後,以 browser 開啟後按 Submit 送出。完成之後,就可以開啟 Terminal 執行

ssh root@192.168.10.1

接著就會出現登入提示,打入在 Router Web 管理界面設定的密碼後,就可以登入了。
Fonera CLI
同樣,依照前面提的文章,就可以把預設開啟 port 22 和啟動 SSH daemon (dropbear),以後不管重新啟動都可以使用 SSH 登入 FON。接著把網路接回去或是讓 FON AP 連到 ADSL modem 或是重新設定網路,重新讓 FON AP 啟用 internet connection。

另外,更新 firmware 版本並不會影響這些設定,除非使用 web 界面的 Firmware Upgrade,那就會把整個 flash 內容更新掉,於是這些設定就掰掰了。FON AP 的 crontab 內部會於整點執行 /bin/thinclient。如果需要升級的話,他會透過 ssh 向 FON 核對版本資料,如果需要更新的話,會產生 /tmp/.thinclient,

cd /tmp
wget http://download.fon.com/firmware/update/0.7.1/1/upgrade.fon
/bin/fonverify /etc/public_fon_rsa_key.der /tmp/upgrade.fon
rm -f /tmp/.thinclient.sh
exit

而其中的 upgrade.fon 並不是 1.9MB fonera_0.7.1.2.fon 的 flash image,只有幾百 KB,應該是類似區域更新或是 diff 升級方式的檔案。所以不要透過 web 界面升級韌體,同樣也可以升級到 0.7.1r2,且一樣可以繼續使用 SSH 來進入 CLI 模式。

註1: 因為把 FON AP 的網路線拔掉,之後重新啟動無法啟動他的 WAN 界面,也就無法做以後的更新。

gravatar

Leopard version 9A343

聽說此版本的 Mac OS X 10.5 有不少視覺上的 improvement。Terminal.app 有 tab 的支援,而且可以在把 multiple window 的設定存在 workspace 中。另外一個主要的重點,

Apple has maintained that it does not plan to ship Leopard until sometime later this spring

看來還有得等呀呀呀呀….

gravatar

iPhone 使用 Intel Xscale CPU

在 Intel exec claims iPhone runs on Xscale chip 提到了 Apple iPhone 使用的 CPU 是 Intel Xscale。雖然不是 PowerPC 或是 x86;因為在 handheld、mobile device 用這些 desktop,即使是 mobile edition 是不太可能;但是把 ARM 架構的 CPU 用在 mobile devices 上倒是蠻直接可以預期的。對於 developer 來說,就要以移植的方式來發展 Applications。但對於有 PowerPC 到 x86 transition 經驗的 Apple 來說,不同平台上的移植應該不成問題了,猜想也會提供類似 Xcode 這種 seamless 的環境吧。

gravatar

FON AP 的預設密碼

La Fonera 的無限網路 AP,預設在斷電之後,會把 Router 的管理界面登入密碼回復為 “admin”。如果要永久更改,就得上 FON 的網頁,登入個人帳號後,在「安裝您的FON無限網路基地台」(Configure your FON Social Router)裡面,把新密碼打進去更新後,從此 FON AP 的 admin 密碼就會預設成那個。

gravatar

Camino trunk with specific fallbacks

這個 Camino 版本是從每天的 mozilla source code CVS 所更新和編譯出來的 trunk 版本。最主要的地方是修改了 gecko 的 thebes 中的 ATSUI font fallbacks。直接使用 hard code 的「儷黑Pro」、「Apple LiGothic Medium」、和「STHeiti」來當作預設的字形 fallbacks。感覺起來比較好看多了,總比預設不知哪來的 fallback 順序使用的日文字形和產生出來的粗細不一字體好太多了,而且跟 Safari 比起來,也比較類似。
不過 trunk 版本總是有些風險和代價,目前的 gecko 1.9 似乎還有一些 layout 上的問題,cairo 針對 Quartz Surface 和 ATSUI 也還在實驗版本階段。自己使用上起來似乎也沒有 coredump 產生,但是有些排版和 Cocoa widgets 會消失倒是不知道原因。或許就是 trunk 上的問題。有些網頁上的顯示和使用反而更慢,例如使用 google spreadsheet,在上面打字的速度真是慢到暴,但是其他網頁的輸入感覺卻蠻正常的。有興趣的人可以試用看看,不過有些網頁上顯示的問題可能也不是短時間能解的,畢竟我只是小小修改 ATSUI font fallbacks 部份,頂多顯示的字形不太一樣而已,其他的可能也幫不了什麼忙。

gravatar

FON Wireless AP

FON 的 AP 使用起來感覺還蠻讚的,但是對於進階使用者來說,還是有不少美中不足的地方。例如斷電後 admin 的密碼就會被 reset 為 admin,還好用 FON_AP 的使用者無法登入 192.168.10.1 這個設定頁;並且 MyPlace 的 WPA/WPA2 密碼不會 reset,不然就好笑了(剛好今天台電停電檢修)。另外一般 wireless AP 常見的狀態記錄,在 FON AP 上也看不到,例如連線時間,有哪些使用者登入,有哪些使用者正在使用,完全都不知道。雖然可以在一段時間後上 FON website 的個人網頁內容去看,但是記錄的內容其實也是蠻簡單的。我相信這些資訊都是有的,只是並沒有提供輸出在管理的網頁上而已。

另外也是蠻好奇到底是不是會有人會去使用他人的 FON AP。原因在於台灣目前只有 Linus 或 Bill,但沒有非 FON AP 只購買上網點數的 Bill。因此除非對方也有購買 FON AP 成為 Linus 或 Bill,他才能登入別人的 FON AP。再來,使用 FON_AP 這個 public SSID 登入 FON 的帳號後使用 internet,他並沒有 WEP/WPA 的加密保護(在 KisMac 上看到的),因此感覺安全性上有不小的顧慮。因此大概即使街坊鄰居都有 FON AP 的訊號重疊,也不會隨便用他人的 FON AP 去登入來使用 non-encryption 的 wireless AP。

Tags: , wireless

gravatar

Firefox with user-specific font fallbacks

Firefox 3.0 的 nightly trunk 使用了 gecko 1.9 新的 layout engine,對於中文方面的 glyphs rendering,還是覺得非常不好看。在 Safari,不論是 zh-TW, UTF-8 裡面的中文似乎都是使用 LiHei Pro 或是 Apple LiGothic Medium。相反的 Firefox 只要是非 zh-TW, Big5 的網頁,似乎都會去用日文字形裡面的中文字,看起來就有很大差異。缺字的話還需要 fallback 找到其他字形去替補,因此各種混雜家錯的字形看起來真是不好看。對於 Firefox 3 的 gecko,給他寫了 default 的 fallback fonts,像是 Apple LiGothic Medium,LiHei Pro,簡體用 STHeiti,看起來畫面像 Safari 產生的文字,感覺好多了。
圖左邊是 Minefield,也就是 Firefox nightly trunk;右邊是 GranParadiso。

Firefox3 trunk with user font fallbacks
Tags: , Firefox

gravatar

Camino nightly trunk with Cairo

Firefox 3.0 的 Gecko 1.9 已經將 text rendering 的工作,統一交由跨平台的 Cairo 處理。另外有一篇 Cairo bets Safari? 的文章,內有 Camino、Safari、以及新的 Camino trunk 的 screenshot,看起來 Cairo 的清晰程度和 Quality 蠻不錯的。另外新的 Camino with Cairo 的 nightly trunk 可以下載來試試看。

gravatar

MSN Messenger 安全性

不管是 Yahoo Messenger 或是 MSN Messenger,已經幾乎是不可或缺、人手一套的傳訊軟體。但是在軟體的背後,傳遞的訊息卻是以明文的內容在彼此和 servers 之間傳送。當然有心人士或是某些有網路控管的公司,很容易就可以窺視訊息的內容。雖然可能沒有什麼危急存亡大事或是商業機密,但是彼此之間的隱私或祕密,在彈指之間不小心就有洩漏出去的可能。大部分 MSN protocol clone 的軟體,都有實作加密的訊息交換機制。以 GAIM 來說,除了在 Linux 平台上外,Mac OS X 的 AdiumX 也是以 libgaim 來作為基礎,同樣 GAIM 也有 Windows 版本。因此如果是同類之間的加密通訊,理論上應該是可以 seamless 地通行無阻。但是最平常的好友其實大都是 Windows MSN Messenger,或公司的 OS 平台也最普遍都是 Windows。反而大家最普遍使用的 IM 版本缺乏加密的功能。
但是還好有一套 SimpLite for MSN 可以實現這個安全的需求(也有其他 IM 版本)。基本上他是當作一個 SOCKS server,並且修改 IM 的 SOCKS proxy 來經過這套軟體,然後在訊息部份以他人的 public key 加密後送出。當然如果對方沒有這套軟體,則本身就無法擁有加密的功用。

gravatar

Copy to Blogger Beta

很久以前就開始用 gslin 的 copyblog.pl 把 wordpress feeds 內容複製到 blogger 去,曾經有一段時間是自己改一部份內容直接用 Blogger Atom API 把文章貼進去。後來似乎 API 有所修改或更動,一段時間經常會失敗造成兩邊不同步。現在 Blogger 的帳戶轉換成 Blogger Beta 之後,更是無法使用舊的方式把文章複製過去了。

所以現在改用 Google Data APIs 把內容貼過去。看來看去比較簡單的方法就是參考裡面的 java 範例,直接改一下,搭配上原本的 copyblog.pl 方式。先把文章標題和內容寫到一個檔案,然後執行 java 來透過 Google Client Data Library 把文章內容新增到 Blogger Beta。程式大致如下,


import com.google.gdata.client.*;
import com.google.gdata.client.calendar.*;
import com.google.gdata.data.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.net.URL;
import java.io.*;

class blogpost
{
  final static String email = "user@gmail.com";
  final static String user = "user";
  final static String passwd = "password";
  final static String filename = "content.txt";
  final static String post_url = "http://www.blogger.com/feeds/{BlogId}/posts/default";
  public static void main(String[] args) throws Exception
  {
    File file = new File( filename );
    BufferedReader br = new BufferedReader( new InputStreamReader(
                          new FileInputStream(file), "utf-8"));
    String title = br.readLine();
    String content = "", line = "";
    while( (line = br.readLine()) != null ) {
      content += line;
    }
    br.close();

    URL postUrl = new URL( post_url );
    Entry myEntry = new Entry();

    myEntry.setTitle(new PlainTextConstruct( title ));
    myEntry.setContent(new PlainTextConstruct( content ));

    Person author = new Person( user, null, email );
    myEntry.getAuthors().add(author);

    GoogleService myService = new GoogleService("blogger", "blog-post-1");
    myService.setUserCredentials(email, passwd);

    Entry insertedEntry = myService.insert(postUrl, myEntry);
  }
}

gravatar

Skype 與 Firewalls

在這篇文章說明了Skype 或是類似的 VoIP 軟體,如何在兩邊都是 NAT 網路情況下,讓兩邊的 clients 連線起來建立通話,而不需要透過非 NAT 的電腦當作 relay。就好像對兩邊的防火牆打了洞一樣,讓雙方可以自行建立起連線。另外參考UDP打洞。

gravatar

Firefox 2.0 (with Websense Bypass Modification)

Here is the page of my personal build Mozilla Firefox 2.0. In this version, it adopts a method to bypass the Websense content filter. Just read the details in the page. We have Windows 32bit version binary and Mac OS X PowerPC G4 (7450) version binary of Firefox. For somebody will still encounter browsing difficulities behind Websense network, just adjust some perferences in Firefox (about:config).

  1. set network.http.keep-alive to false
  2. set network.http.max-persistent-connections-per-server to 0
Please refer to this page for details.

gravatar

網頁加速

看到網頁瀏覽加速法和vgod的網頁瀏覽加速,我覺得 Mozilla 和 Firefox 的確可以有很多的設定來加速網頁下載的速度。但是依照之前的經驗來說,Safari 是用 Cocoa 的 NSURLConnection、NSURLRequest、NSURLResponse,因此這些系統內建的 framework 所提供的可調整設定似乎就已經固定,也無法更改。另外 Opera 平常用起來的速度蠻快的,其實他有點作弊的手法。
Opera Preference
在這個圖片中,是 Opera 原廠安裝後的設定,要仔細看的地方是在 "Check documents" 和 "Check images" 這兩個地方,一開始未更改的設定是 Every 5 hours。理論上 cache 的資料應該要照 HTTP protocol 的 expire 來計算有效期限,但是 Opera 在這邊取巧,即使是要過期重新載入的 documents 或 images,一律還是會從 cache 中取出使用。這樣會有什麼問題?當然就是過期的圖片還是會顯示舊的。簡單的例子從 railway.hinet.net 的訂票系統就可以看到,新的設計需要輸入圖形內的數字才能定掉,而且每次應該是不同的數字。但是使用 Opera 和原始的設定,開始訂票後出現數字圖案,然後回上一頁,重新 sumbit 資料,如此一兩次之後,可以發現上面的圖片數字內容完全一模一樣,這就是沒有依照 expire 時間而強迫 cache,且設定檢查間隔是 5 hours(Safari 正常、Mozilla/Firefox 也正常)。好處就是在瀏覽速度上會快很多,比如說上 tw.yahoo.com 這種很多"圖文"並茂的網頁,短期間內因為不用 check 而直接使用舊的資料,速度上幾乎就是馬上出現。解決上面訂票的方法,當然就是改成每次 always check 就可以正常運作。
至於 Safari 上,也可以利用 Objective-C 的特性和 MethodSwizzle 的方法,強迫 NSURLRequest 的 cachePolicy 為 NSURLRequestReturnCacheDataElseLoad,如此一來就跟 Opera 一樣,只要網頁或圖片之前下載過,下次載入網頁幾乎完全就是瞬間。但是這樣問題就跟 Opera 一樣,某些有 expire mechanism 的網頁或圖片就是沒有更新。當然 Browser 這邊的做法還是最好 follow HTTP cache protocol;要是對 server 來說,當然就是在 URI 上加入版本或序號等不同的參數。

gravatar

Bypass Websense, part 2

It is very easy to modify a HTTP proxy server to adopt Websense bypass mechanise. Take Muffin for example, it is an open-source HTTP/HTTPS proxy server written in Java programming language. In src/org/doit/muffin/Request.java, write() method, the original code,

super.write(out);
if (data != null)
{
out.write(data);
out.flush();
}
Just have some modification,
ByteArray ba = super.toByteArray();
byte[] array = ba.getBytes();
out.write( array, 0, 1 ); out.flush();
out.write( array , 1, 1 ); out.flush();
out.write( array, 2, ba.length()-2); out.flush();
//super.write(out);
if (data != null)
{
out.write(data);
out.flush();
}
The new code will force HTTP request to become multiple segmented packets. For example, GET http://tw.yahoo.com HTTP/1.1 will become "G" in one packet, "E" in another packet, and T http://tw..... to the end of request will be in other packets. By this way, Websense will not able to get the FULL HTTP request packet. Therefore, Websense will not able to block you out.

Tags: , websense

gravatar

Bypass Websense

In Tech-Faq , there is an article talking about how to by pass Websense. Instead of using proxy or tunneling methods, there is still a way to bypass the firewall filter. In the article, there are some important sentences, listed in following,

In transparent mode, Websense counts on the fact that the firewall will forward the whole request in a single time. If the whole request is not transferred at one time, Websense will allow the packet to pass, as the packet doesn't look like a HTTP request.
In the fact, if you browse a prohibited website, the Websense server will feedback an HTTP redirect header to your browser. Then your browser will go to the page like this. The techniques of above sentences could clearly explain why I can bypass the Websense via Telnet. Instead of using any browsers, I just telneted to a prohibited website host with port 80. Then I keyed in the HTTP protocol strings, for example, GET /index.html HTTP/1.1. Then The raw HTML content was dumped to the terminal, not Websense HTTP redirect or blocked page.
Maybe I can modify the PERL HTTP proxy program I wrote before to adopt this mechanism to bypass the Websense. :P Because of the ridiculous policies and reasons of preventing PCs from attacks of viruses, Trojans, worms, and hackers, they blocked out some sites like Flickr, wretch, pixnet, xuite, google spreadsheets, and so on. It is very ridiculous and amazing.

Tags: , websense

gravatar

MovieTime

在 MacOSX 底下,最常用的 player 不外乎是 VLC 或是 MPlayerOSX,但是這兩種設定影片的外掛字幕通常不是很簡單,而且還需要特殊的字型設定,甚至有些文字顯示不出來,或是顯示得上下不對齊。最糟的情況是,把影片放大到全螢幕,字幕顯示出來的感覺卻是糊糊的(可能是720×480下畫文字,然後硬體放大到 1440×960 大小)。因此總是覺得 MacOSX 底下對字幕支援很不好。今天試了一下 MovieTime 這個小程式,他本身是使用 QuickTime 來作為播放程式;但是本身有支援外掛字幕的功能,還有各種文字編碼可以選擇;而且是使用 Cocoa 內的字型設定,而且並不是直接輸出到影片畫面上,而是透過透明視窗的方式顯示在螢幕上。感覺上字型效果就好太多了。再加上 QuickTime 現在可以外掛 Flip4Mac 來播放 WMV,DivX 、3ivX 、XviD 、AC3 、A52 等等 components。因此不少 mov、avi、wmv 就可以直接透過 MovieTime 來播放,然後利用它的外掛字幕功能。

gravatar

Hello There!!

Hello There!!

This is a simple test from Google Docs & Spreadsheets

gravatar

有名大站

最近鬧得很熱,雖然自己沒有在用,但是很多地方卻都看在眼裡。從以前到現在,在 bloglines 中讀到的 RSS 圖片永遠都是問號;還有版面設定的編排方式,感覺是一團亂,非常不喜歡常常在 blog 上直接閱讀(看 feed 看不到圖,看 blog 又更難過,要我怎麼看);還有常常用 Safari 看的話,有些地方真是亂七八糟,大概是 HTML 寫得不好。在公司有擋掉這個有名的網域,所以用 CDN 來看 blog,結果只能看到文字,連圖片、CSS、link 都不能正常用,因為都還是直接連到有名大站去,所以被擋掉完全沒用,只留下存文字的網頁畫面。此外,當然也是因為在 HiNet 就….
總之,搬不搬家好像對我來說都無關緊要,但是能換到好一點的 hosting 去,自己閱讀起來應該更好吧。

gravatar

DV-2008

2008年美國綠卡樂透申請即將開始,從 EDT 時區2006/10/4中午到12/3截止。