在 Linux NAT 監看 MSN 聊天內容

回覆文章
yehlu
Site Admin
文章: 3244
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

在 Linux NAT 監看 MSN 聊天內容

文章 yehlu »

http://cha.homeip.net/blog/archives/200 ... t_msn.html

2005年12月01日
在 Linux NAT 監看 MSN 聊天內容

Gateway 是上網時網路封包必經的關卡, 從中截聽封包內容最能掌握使用者上網的所有動作.

網路上已有許多如: MSN Sniffer、ICQ Sniffer、AIM Sniffer 等網路聊天監聽軟體, 需要的話可以在搜尋引擎找到一堆. 以下是在 Linux 平台上使用 msniff 監看 MSN 傳訊內容的操作備忘:

安裝 msniff

需求套件: libpcap

wget http://shh.thathost.com/pub-unix/files/ ... 1.3.tar.gz
tar -zxf msniff-0.1.3.tar.gz
cd msniff-0.1.3
make

ps. 若確定已安裝 libpcap, 但 make 時仍發生 "pcap.h: No such file or directory" 的錯誤訊息, 修正 Makefile 裡的 INCDIR, 將它指向 pcap.h 的正確路徑即可解決

使用前的前置動作

由於 msnnif 尚無法解析 msn 透過 port 80 傳輸的內容 (因格式不同), 因此在 iptables 中禁止使用者透過 tcp port 80 傳訊:

iptables -A FORWARD -p tcp -d 207.46.0.0/16 --dport 80 -j DROP
iptables -A FORWARD -p tcp -s 207.46.0.0/16 --sport 80 -j DROP

若 Linux NAT 扮演 Transparent Proxy 的角色, 須修改 REDIRECT 規則如下:

iptables -t nat -A PREROUTING -p tcp -s 192.168.0.0/24 -d ! 207.46.0.0/16 --dport 80 -j REDIRECT --to-port 3128

ps. 207.46.0.0/16 是指 baym[n]-gw[1-n].msgr.hotmail.com

搭配 Squid 全面封鎖 msn http 傳輸的辦法:

修改 squid.conf

acl msn_domain dstdomain .msgr.hotmail.com .messenger.hotmail.com webmessenger.msn.com
acl msn_mime req_mime_type -i ^application/x-msn-messenger$
http_access deny msn_domain
http_access deny msn_mime

資料來源: 資安論壇的這篇文章

-- 2005/12/27 補充:

使用 iptables + L7-filter 強迫 MSN Messenger 使用 1863 port

iptables -t mangle -A PREROUTING -p tcp --sport 1863 -m layer7 --l7proto msnmessenger -j ACCEPT
iptables -t mangle -A PREROUTING -p tcp --dport 1863 -m layer7 --l7proto msnmessenger -j ACCEPT
iptables -t mangle -A PREROUTING -m layer7 --l7proto msnmessenger -j DROP

監看 msn 傳訊內容

./msniff eth0 > msn.log & (背景執行, 預設監聽 msn 標準 port -- tcp 1863)

tail -f msn.log (持續監看所有聊天內容, 中文內容為 UTF-8 格式)

若需轉為 BIG5 可使用 iconv 指令轉換: iconv -f utf-8 -t big5 msn.log


相關網頁:

* Sverre's Software for Unix/Linux
* 鳥哥的 Linux 新手討論區 - [問題]想擋MSN,不知道這樣的方式IPTABLES可以做嗎?
* 中国IT动力 - [shell]用tcpdump截获msn信息
* IMHear, el sniffer de MSN Messenger @ VivaLinux!
* FireTower, Inc. - Forum - tcpdump tutorial
回覆文章

回到「Linux」