Archive for September, 2005

小心 “.

Thursday, September 29th, 2005

最近學校的電腦有幾台使用者不管的電腦有個使用者的密碼被猜到,侵入的 angelbot 用 ssh 登錄,然後會載入一堆針對 linux 中許多程式的漏洞來攻擊的程式取得 root 權限,然後會再去掃描其他電腦的 ssh 的 user/password 組合。這個 bot 應該是可以從遠端 irc 中控制。

如果發現系統中,有個 angel 的帳號的話,那就是中獎了。這個 bot 藏在 /var/tmp 的一個目錄,這個目錄名是 “. “,所以不小心看,會以為這是 “.” 目錄,要進這個目錄,要 ‘cd “. /”‘。進去後會有一堆 cracker 用的工具。

不要有亂七八糟的使用者帳號,沒事去看看 /var/log/auth.log 或是 /var/log/secure,如果被入侵了,記得把 “. ” 擦乾淨。

(另一個 angelbot 的 trace 是這個 bot 會跑一個叫 “[httpd]” process 來跟遠方的 bot 透過 port 8888 眉來眼去。不注意看的話也是很容易漏掉。)

nice stories

Wednesday, September 28th, 2005

The road to a science Ph.D.

Part I
Part II

Debian linux as a VPN server for OS X

Tuesday, September 27th, 2005

最近決定來試看看把在學校裡工作用的 desktop 拿來當自己的 VPN server,這樣作最大的好處是可以在家裏工作時還是可以取用學校有訂閱的期刊論文的電子版。雖然學校其實有提供 VPN client 連到學校的 VPN server,但是好像還不支援 Tiger,要多裝一個 client 也是很煩的事。之前我是用 ssh tunneling 加上 tinyproxy 來『模擬』VPN,其實也已經很實用了。但是還是手癢,想來玩玩自己的 VPN server 然後用 Tiger 內建的 VPN client 去連結。

在 Tiger 可用的而 linux 有支援的 VPN 中,pptp 是最好設定的。在 Debian 下唯一比較麻煩的是要自行編譯 ppp_mppe.ko 的 kernel module。把 ppp_mppe.ko 編好後,在 /etc/modutils/aliases 中加入一行

alias ppp-compress-18   ppp_mppe

這樣 kernel 才會自動載入這個 module,當然妳也可以用 insmod 來載入所有 ppp_* 相關的 module。

要把 debian 設成 pptp 的 server 要先用 apt-get 安裝 pptd 套件:

apt-get install pptpd

然後再來要設定下面幾個檔案,

設定 pptp:

file: /etc/pptpd.conf 

speed 115200
option /etc/ppp/pptpd-options
noipparam
logwtmp
bcrelay eth0
localip 192.168.0.1
remoteip 192.168.0.234-238,192.168.0.245

設定 ppp:

file: /etc/ppp/pptpd-options

name pptpd
ktune
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
# replace 127.0.0.1 with the remote server's DNS ip
ms-dns 127.0.0.1
proxyarp
nodefaultroute
lock
nobsdcomp
nodeflate

設定用戶代號與密碼:

file: /etc/ppp/chap-secrets                              

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
VPNUserName pptpd VPNPassword *

把 ppp 連結的 traffic 導向到 server 的外部 ip/網路卡:

file: /etc/ppp/ip-up.local 

#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
modprobe ipt_MASQUERADE
iptables -t nat -F
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

這些設定完成後。在 OS X 下就可以 Internet Connector 中的 PPTP VPN 來連到 server 上。記得要把 Internet Connector 的選單中 Connect -> Options 中的 Send all traffic over VPN connect 選起來。這樣再加上在 server 上的 iptable 的設定,當用 VPN 連線的時候,外界看起來就像你是從 server 連出去的(妳可以試著連到 checkip.dyndns.org 來看看外面的網站看到的 ip 是不是 server 的 ip)。

在 Aquamacs 用中文的小訣竅

Sunday, September 4th, 2005

在 Mac OS X 上的 emacs 正如其他 Unix 裡的 emacs 一般有很多不同的版本。以前用的是 Carbonize 的 emacs,要在上面設定使用 utf-8 的正體中文總是對 .emacs 動不少工程,甚至必要的時候,還得自行從原始嗎加上補丁重新編譯。

Aquamacs emacs 是在 Mac OS X 上 Aqua 化的 emacs,所以就 GUI/字形來說,會比別的建立在 Carbon 及 Terminal 上的 emacs 來得自然。但是我以前試驗過早期 Aquamacs 的版本不夠穩定,所以我一直是使用自己編譯的 Carbonize emacs。不過,最近一版的 Aquamacs 相當不錯,加上要在其中使用,utf-8 中設定相當方便,試驗中文成功後,我就把自己編的 Carbonize emacs 給砍了。

要在 Aquamacs 下使用 utf-8 的正體中文只需在 ~/Library/Preferences/Aquamacs Emacs/Preferences.el 中加上兩行,

(set-language-environment “Chinese-Big5″)
(prefer-coding-system ‘utf-8)

就可以用中文了。

Auqamacs 中也正確處理了剪貼簿中的編碼,不需要任何特別的設定,不管是那種 encoding,都可以在 Aquamacs 與其他的 OS X 軟體中自由的剪來貼去了。

有需要在 OS X 下中用 emacs 的朋友不妨試試 Aquamacs,說不定您會像我一樣,覺得 Aquamacs 還滿合用的。

Finder 下 “New File” 功能

Sunday, September 4th, 2005

在 Finder 下,有 New folder 但沒有 New File 的 Context menu。雖然不是一定要的功能,但是如果可以在 Finder 下建立空檔,然雙擊來打開對應的應用程式來在想要的目錄下建立對應的檔案也是一件滿方便的事。在看了一個相關的 osxhintshint 後,發現這樣的事情可用 Automator 加上 Apple Script 來做到。以下說明如何來在 Finder 下做到這件事。

打開 Automator,找到 run apple script 的 Action,然後用把下面的 Apple script 貼上:

on run {input, parameters}
set input_text to text returned of
     (display dialog “Please input a file name” default answer “Untitled.txt”)
do shell script “touch ” & (POSIX path of (input as string)) & input_text
return input
end run

然後在選單下選 Save As Plugin…,把 Workflow 存成 Finder 的 Plug-in,把 workflow 命名成 “New File”。這樣,在 Finder 的 Context menu 下的 Automator 中就會有新的選項 “New File”。這樣,就可在 Finder 下用 context menu 來建立新檔了。