Ngrep:方便的數(shù)據(jù)包匹配和顯示工具
ngrep 是grep(在文本中搜索字符串的工具)的網(wǎng)絡(luò)版,他力求更多的grep特征,用于搜尋指定的數(shù)據(jù)包。正由于安裝ngrep需用到libpcap庫(kù),所以支持大量的操作系統(tǒng)和網(wǎng)絡(luò)協(xié)議。能識(shí)別TCP、UDP和ICMP包,理解bpf的過(guò)濾機(jī)制。
下載鏈接:http://down.51cto.com/data/149233
>>去網(wǎng)絡(luò)安全工具百寶箱看看其它安全工具
應(yīng)用如下(以下的例子中本機(jī)地址是"10.178.41.31"):
- iron_gavel$ngrep -qd rl0 (同時(shí)在另一控制臺(tái)$mazilla http://www.google.com)
- U 10.178.41.31:1054 ->; 211.98.2.4:53
- .............www.google.com.....
- T 216.239.57.104:80 ->; 10.178.41.31:1029 [AFP]
- HTTP/1.0 302 Found..Location: http://www.google.com/intl/zh-CN/..Set-Cookie
- Type: text/html..Server: GWS/2.1..Content-length: 163..Date: Sat, 08 May 20
- 04 13:29:26 GMT..Connection: Keep-Alive....<HTML>;<BODY>;...BODY>;HTML>;..
該命令的輸出說(shuō)明本機(jī)和Google交互的數(shù)據(jù)
- iron_gavel$ngrep -iw 'lynx'
- interface: rl0 (10.178.41.0/255.255.255.0)
- match: ((^lynx\W)|(\Wlynx$)|(\Wlynx\W))
- T 10.178.41.31:1050 ->; 64.233.161.99:80 [AP]
- GET / HTTP/1.0 Accept-Language: en..User-Agent: Lynx/2.8.4rel.1 l
- ibwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.7c....
- 匹配進(jìn)出數(shù)據(jù)包中包括lynx(參數(shù)"i"忽略大小寫)的信息。
- iron_gavel$ngrep host 10.178.41.5/*看看對(duì)面的同事在干嘛*/
- interface: rl0 (10.178.0.0/255.255.0.0)
- filter: ip and ( host 10.178.41.5 )
- T 10.178.41.5:2035 ->; 61.153.48.247:80 [AP]
- GET /show.asp HTTP/1.1..Host: www.music9999.com.
- .Connection: Keep-Alive..Referer: http://www.music9999.com/....
- T 219.133.40.79:7204 ->; 10.178.41.5:1115 [AP]
- .(OICQ_2280***30.OICQ_33****314.1.0..5m...........
他在瀏覽music9999.com,同時(shí)用QQ和朋友聊天。
做為sinffer的用法:
可以用ngrep來(lái)匹配特定的數(shù)據(jù)包:
- iron_gavel$ngrep '' udp /*匹配udp包*/
- iron_gavel$ngrep '' icmp/*匹配icmp包*/
- iron_gavel$ngrep '' port 53 /*顯示所有的dns請(qǐng)求*/
- iron_gavel$ngrep '../'/*監(jiān)聽遠(yuǎn)程主機(jī)的'../'請(qǐng)求*/
- iron_gavel$ngrep -d rl0 port 80/*服務(wù)器端http數(shù)據(jù)*/
- iron_gavel$ngrep -d rl0 'error' port syslog/**/
- iron_gavel$ngrep -wi -d rl0 'user|pass' port 21/*關(guān)注端口21上的user和pass*/
下面是一些常用的參數(shù):
ngrep -v '' port 23
顯示除telnet的數(shù)據(jù)包,-v意為反轉(zhuǎn)。
ngrep -d eth0 ''
在redhat上顯示所有的數(shù)據(jù)包,-d 指定硬件接口。