Ubuntu 11.04 最近一次 kernel 升級後沒聲音…

桌機還在用 Ubuntu 11.04,剛剛 apt-get 升級後沒聲音了 (有注意到 kernel 有更新),後來是用「Ubuntu 11.04 – No sound at all」這篇的方法解決:

rm -r ~/.pulse ~/.asound* ~/.pulse-cookie
sudo rm /etc/asound.conf

重開機後就有聲音了…

Posted in Computer, Linux, Murmuring, OS, Software | Tagged , | Leave a comment

The Pirate Bay (海盜灣) 從 Torrent 檔下載換成 Magnet URI (磁力連結)

The Pirate Bay 將把 torrent 檔下載方式換成磁力連結:「The Pirate Bay Will Stop Serving Torrents」。

Magnet URI 下載 BitTorrent 檔案其實只是多了一個抓 torrent 檔的步驟:首先先從 Magnet URI 內取得 SHA1 值,然後透過 DHT 抓到 torrent 檔的 metadata,然後後面就可以照舊進行… 至於 DHT 的初次建立,除了可以透過中央式的 router.utorrent.com 取得外,也可以透過其他 torrent 檔案下載所提供的 tracker 找到節點。在取得一批節點後,透過 PEX 交換出更多的節點。

DHT + PEX 的技術逐漸成熟 (愈來愈多程式支援),然後是最大的 torrent site 採用。之後的 public torrent site 應該都會改朝這個方向走…

Posted in Computer, Murmuring, Network, P2P, WWW | Tagged , , , , , , | 1 Comment

儲存密碼的方式

主要是參考「Cryptographic Right Answers」這篇給的建議:

Password handling: As soon as you receive a password, hash it using scrypt or PBKDF2 and erase the plaintext password from memory.
Do NOT store users’ passwords. Do NOT hash them with MD5. Use a real key derivation algorithm. PBKDF2 is the most official standard; but scrypt is stronger.
Please keep in mind that even if YOUR application isn’t particularly sensitive, your users are probably re-using passwords which they have used on other, more sensitive, websites — so if you screw up how you store your users’ passwords, you might end up doing them a lot of harm.

其中 scrypt 是作者自己發展的演算法,這邊看看就好。

你可以用 PBKDF2 (RFC 2898)。這邊假設的前提是,你不需要常常重複計算使用者的密碼是否正確。在這個前提下,我們可以把演算法弄得很複雜,而且很耗時,要複雜到用硬體加速也無法產生實質上有效的攻擊。

如果你對密碼學這個領域並不熟,Colin Percival 這篇文章可以拿來當做起點,文章裡面告訴你,某些類型的問題會用某些工具解決。

Posted in Computer, Murmuring, Network, Security | Tagged , , , , , | 1 Comment

自己編 rTorrent 與 libTorrent…

Ubuntu 提供的 rTorrent 比較舊,11.04 上面只有 0.8.6 可以用,11.10 則是 0.8.7。目前最新的 stable 是 0.8.9,有支援 magnet uri… 找了 launchpad 上面有沒有人做,看起來是沒有 :/

因為不想影響到系統舊版的 libTorrent 與 rTorrent,所以裝在自己的 home directory 下。

先安裝 libTorrent,用 ./configure --prefix=/home/gslin/foo 之後用 make 編完後 make install 就可以了,有缺軟體的部份會跳訊息出來,用 apt-get 補上 -dev 版本後再繼續安裝。

再來是 rTorrent,首先要注意的是要裝 libncursesw5-dev,也就是有 wide character support 的版本,不然顯示 UTF-8 會有問題 (實際在磁碟上的檔名不會有問題,但顯示會有問題),接著用 libtorrent_CFLAGS="-I/home/gslin/foo/include" libtorrent_LIBS="-L/home/gslin/foo/lib -ltorrent" ./configure --prefix=/home/gslin/foo 指定 libtrorrent 所在位置,然後用 make 編完後 make install

接下來用 ~/foo/rtorrent 執行,應該就會是新版的 rTorrent 了…

Posted in Computer, Linux, Murmuring, Network, OS, P2P, Software | Tagged , , | Leave a comment

請更新 HP 印表機的韌體…

HP 發了安全通告「HPSBPI02728 SSRT100692 rev.2 – Certain HP Printers and HP Digital Senders, Remote Firmware Update Enabled by Default」,在安全通告內列出的印表機都有安全問題,「允許遠端安裝未經授權的印表機韌體」,攻擊者可以遠端直接安裝有木馬的韌體:

A potential security vulnerability has been identified with certain HP printers and HP digital senders. The vulnerability could be exploited remotely to install unauthorized printer firmware.

另外可以參考 CVE-2011-4161 的說明:

The default configuration of the HP CM8060 Color MFP with Edgeline; Color LaserJet 3xxx, 4xxx, 5550, 9500, CMxxxx, CPxxxx, and Enterprise CPxxxx; Digital Sender 9200c and 9250c; LaserJet 4xxx, 5200, 90xx, Mxxxx, and Pxxxx; and LaserJet Enterprise 500 color M551, 600, M4555 MFP, and P3015 enables the Remote Firmware Update (RFU) setting, which allows remote attackers to execute arbitrary code by using a session on TCP port 9100 to upload a crafted firmware update.

能更新的就想辦法更新吧,無法更新的看看有沒有辦法處理 port 9100…

Posted in Computer, Hardware, Murmuring, Network, Security | Tagged , , , , , | Leave a comment

Akamai 買下 Cotendo…

Akaiami 的新聞稿先出來了:「December 22, 2011 – Akamai to Acquire Cotendo」,Cotendo 的只有在 Twitter 上看到官方帳號提到 Akamai 的新聞稿。

併購的金額在:

Under terms of the agreement, Akamai will acquire all of the outstanding equity of Cotendo in exchange for a net cash payment of approximately $268 million

上個月月底的時候就有消息了:「Akamai Reportedly Buying Rival Cotendo For Up To $350 Million」,不過一直都是謠傳而已…

Cotendo 的產品在 Akamai 裡面都有對應的產品,這次併購看起來比較像是減少競爭對手,或是買專利…

Posted in CDN, Computer, Murmuring, Network, WWW | Tagged , , | Leave a comment

把 Google Plus 的數字 icon 藏起來…

那個紅色的數字 icon 還蠻妨礙工作的,到 userscripts.org 上翻一翻,果然有人有寫過了 (雖然是沒幾天前):「Go Away! Google Plus」。

PS:隨便丟字進去測試的時候,發現 “test” 第五名是 tw.yahoo.com,這是怎麼了…?

Posted in Browser, Computer, Firefox, GoogleChrome, Murmuring, Network, Social, Software | Tagged , , , , , | Leave a comment

gitolite 的 hook…

弄了整個週末的 gitolite,總算是把 hook 搞定。

簡單的說,修改完 ~/.gitolite/hooks/common/ 裡的 hook script 後,需要下 gl-setup 指令,這個指令會把現在所有的 git repository 內的 hook script 再 symbolic link 一次。

另外,gitolite 的環境變數可能會影響 git 本身執行 (我是在 git pull -v 更新某個目錄下的 git repository 時失敗),這時可以用 /usr/bin/env -i /usr/local/bin/git 確保 git 執行時不會被環境變數影響…

gitolite 看起來是個好東西,不過光是靠官方的文件要搞定頗累… (週末都在 Stack Overflow 上度過)

Posted in Computer, Murmuring, Network, Software | Tagged , , , | Leave a comment

如果要自己寫 TOTP 的幾個要看的東西…

整理下來:

有玩過 HMAC 的人,讀這些文件應該不難…

TOTP 在預設的情況下,其實就是 HMAC-SHA-1 後取後面 32bits,然後轉成數字取 100000 的餘數,而 TOTP 文件是架構在 HOTP 的定義上,把時間切齊 (預設 30secs) 變成整數丟進去攪和,然後特地交代要處理 2038 年超過 Int32 的 case XDDD

最後 Google 那份文件是要輸出 QR code 讓手機可以讀的方式,建議不要用網路服務產生 QR code (因為有 secret key 啊),寧可自己抓 library 建一個用…

另外 Google Authenticator 一堆東西都只能用預設值 (Currently, the XXX is ignored by the Google Authenticator implementations.),所以也沒什麼好選的,就拿預設值吧… :o

Server side 的話,至少我在 CPAN 上面看到 Authen-OATH 可以用了,用起來也很簡單 :o

Posted in Computer, Murmuring, Network, Programming, Security, Software | Tagged , , , , , , , | Leave a comment

PHP 提供的資料結構…

從「How big are PHP arrays (and values) really? (Hint: BIG!)」這篇看到的。文章本身值得花些時間看過了解,不過對我來說重點在最後面的 SplFixedArray

PHPDatastructures 說明目前 PHP SPL 所支援的 data structure,在記憶體用量以及效率上面都會比自己實作來的小且快。

可以看到很多都支援 Countable、Iterator,以及 ArrayAccess,代表可以用 foreach() 或是對應的方式存取… 如果自己寫 library 的時候應該要善用這些 SPL。

Posted in Computer, Murmuring, Programming, Software | Tagged , , , , | Leave a comment