文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>抄一篇关于ngrep的文章

抄一篇关于ngrep的文章

时间:2006-03-18  来源:barterr

ngrep简介 ngrep 是grep(在文本中搜索字符串的工具)的网络版,他力求更多的grep特征,
用于搜寻指定的数据包。正由于安装ngrep需用到libpcap库, 所以支持大量的
操作系统和网络协议。能识别TCP、UDP和ICMP包,理解bpf的过滤机制。

ngrep下载地址:http://ngrep.sourceforge.net/;
libpcap下载地址:http://www.tcpdump.org/。
应用如下(以下的例子中本机地址是"10.178.41.31"

iron_gavel$ngrep -qd rl0 (同时在另一控制台$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>;..
该命令的输出说明本机和Google交互的数据                                                

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....
匹配进出数据包中包括lynx(参数"i"忽略大小写)的信息。

iron_gavel$ngrep host 10.178.41.5/*看看对面的同事在干嘛*/
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,同时用QQ和朋友聊天。

做为sinffer的用法:
可以用ngrep来匹配特定的数据包:
iron_gavel$ngrep '' udp /*匹配udp包*/
iron_gavel$ngrep '' icmp/*匹配icmp包*/
iron_gavel$ngrep '' port 53 /*显示所有的dns请求*/

iron_gavel$ngrep '../'/*监听远程主机的'../'请求*/
iron_gavel$ngrep -d rl0 port 80/*服务器端http数据*/
iron_gavel$ngrep -d rl0 'error' port syslog/**/
iron_gavel$ngrep -wi -d rl0 'user|pass' port 21/*关注端口21上的user和pass*/

下面是一些常用的参数:
ngrep -v '' port 23

显示除telnet的数据包,-v意为反转。

ngrep -d eth0 ''
在redhat上显示所有的数据包,-d 指定硬件接口。
相关阅读 更多 +
排行榜 更多 +
密室逃脱18移动迷城白蚁怎么抓

密室逃脱18移动迷城白蚁怎么抓

冒险解谜 下载
少女战地模拟器

少女战地模拟器

飞行射击 下载
Mad Dragon Defense

Mad Dragon Defense

飞行射击 下载