Chinaunix首页 | 论坛 | 博客
  • 博客访问: 128309
  • 博文数量: 100
  • 博客积分: 1850
  • 博客等级: 上尉
  • 技术积分: 650
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-02 23:52
文章分类

全部博文(100)

文章存档

2016年(1)

2009年(1)

2008年(5)

2007年(11)

2006年(32)

2005年(50)

我的朋友

分类: LINUX

2006-03-18 15:33:06

ngrep简介

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

ngrep下载地址:;
libpcap下载地址:。
应用如下(以下的例子中本机地址是"10.178.41.31"

iron_gavel$ngrep -qd rl0 (同时在另一控制台$mazilla )
U 10.178.41.31:1054 ->; 211.98.2.4:53
  .............                          
T 216.239.57.104:80 ->; 10.178.41.31:1029 [AFP]
  HTTP/1.0 302 Found..Location: /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....;;... ;;..
该命令的输出说明本机和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:
  .Connection: Keep-Alive..Referer:           
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 指定硬件接口。

阅读(726) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~