ngrep – http://ngrep.sourceforge.net/
在 Linux 系統上,如果沒有安裝 GUI介面,就無法使用 wireshark,在純文字介面的環境下怎麼看細一點的封包資訊,
比方說存取 80 服務時,這個封包是在抓那個檔案作什麼動作,是 GET 還是 POST,
用 tcpdump 只看的懂來源、目的、服務port,其它沒了。
這時後我們就用 ngrep 吧,且只要你熟 tcpdump 其實參數用法大同小異,你可以把 ngrep 想成 network + grep 它也確實是如此,
指令1: ngrep port 80
這樣子是不是好看多了
安裝: 有 yum 安裝就用 yum 安裝吧,除非舊的系統,只好 tarball 編譯
編譯時遇到的問題
CentOS release 3.7
Q: ngrep-1.45]# ./configure
creating Makefile
creating doc/Makefile
creating test/MakefileConfiguring Network Grep (ngrep) …
checking for a broken redhat glibc udphdr declaration… no
checking for a complete set of pcap headers…more than one set found in:
/usr/local/include
/usr/local/include/pcapplease wipe out all unused pcap installations
A: 這是因為有兩個 pcap.h,一個在 /usr/local/include/pcap/pcap.h,一個在 /usr/local/include/pcap.h
解決方法有兩個,
把 /usr/local/include/pcap.h 移掉,mv /usr/local/include/pcap.h /usr/local/include/pcap.h_或者
./configure –with-pcap-include=/usr/local/include/pcap/pcap.h
留言
找封包同時為目的ip 1.1.1.1 及目的port 25,注意要兩個單引號 '' ngrep '' dst host 1.1.1.1 and dst port 25