ngrep 是grep(在文本中搜索字符串的工具)的网络版,他力求更多的grep特征,
用于搜寻指定的数据包

一: ngrep的安装 CentOS6.2 64位

wget http://nchc.dl.sourceforge.net/sourceforge/ngrep/ngrep-1.45.tar.bz2

下载下来是一个 bz2的包, 用bzip2命令加压成tar包,在用tar解压

bzip2 -d ngrep-1.45.tar.bz2

  tar xf ngrep-1.45.tar

二:安装 ngrep

cd 进入目录 ngrep-1.45

./configure

  make

  make install

三:我这样安装的时候报错了, 如下:

或者是这样的错误:

看错误说明,系统缺少 libpacp的包,那么yum安装 libpacp,

yum install libpcap libpcap-devel -y

重新安装ngrep

./configure --with-pcap-includes=/usr/local/include/pcap

make

make install

注意加上红色的部分,这样才正确的安装了

四:使用 http://blog.sina.com.cn/s/blog_4d14fb2b01012tqo.html

使用方法:()
usage: ngrep <-LhNXViwqpevxlDtTRM> <-IO pcap_dump> <-n num> <-d dev> <-A num>
<-s snaplen> <-S limitlen> <-W normal|byline|single|none> <-c cols>
<-P char> <-F file> <match expression> <bpf filter>
-h is help/usage
-V is version information
-q is be quiet (don't print packet reception hash marks)静默模式,如果没有此开关,未匹配的数据包都以“#”显示
-e is show empty packets 显示空数据包
-i is ignore case 忽略大小写
-v is invert match 反转匹配
-R is don't do privilege revocation logic
-x is print in alternate hexdump format 以16进制格式显示
-X is interpret match expression as hexadecimal 以16进制格式匹配
-w is word-regex (expression must match as a word) 整字匹配
-p is don't go into promiscuous mode 不使用混杂模式
-l is make stdout line buffered
-D is replay pcap_dumps with their recorded time intervals
-t is print timestamp every time a packet is matched在每个匹配的包之前显示时间戳
-T is print delta timestamp every time a packet is matched显示上一个匹配的数据包之间的时间间隔
-M is don't do multi-line match (do single-line match instead)仅进行单行匹配
-I is read packet stream from pcap format file pcap_dump 从文件中读取数据进行匹配
-O is dump matched packets in pcap format to pcap_dump 将匹配的数据保存到文件
-n is look at only num packets 仅捕获指定数目的数据包进行查看
-A is dump num packets after a match匹配到数据包后Dump随后的指定数目的数据包
-s is set the bpf caplen
-S is set the limitlen on matched packets
-W is set the dump format (normal, byline, single, none) 设置显示格式byline将解析包中的换行符
-c is force the column width to the specified size 强制显示列的宽度
-P is set the non-printable display char to what is specified
-F is read the bpf filter from the specified file 使用文件中定义的bpf(Berkeley Packet Filter)
-N is show sub protocol number 显示由IANA定义的子协议号
-d is use specified device (index) instead of the pcap default 使用哪个网卡,可以用-L选项查询
-L is show the winpcap device list index 查询网卡接口

五:应用示例:

1:捕获字符串".flv",比如要查看在Web Flash 视频中的flv文件的下载地址
ngrep -d3 -N -q \.flv
interface: \Device\TNT_40_1_{670F6B50-0A13-4BAB-9D9E-994A833F5BA9} (10.132.0.0/2
55.255.192.0)
match: \.flv

2:ngrep -W byline -d lo port 18080
捕捉cloudian:18080端口的request和response。-W byline用来解析包中的换行符,否则包里的所有数据都是连续的,可读性差。-d lo是监听本地网卡
ngrep -W byline -d eth0 port 80
捕捉amazon:80端口的request和response。-d eth0 是用来监听对外的网卡

3:可以用-d any来捕捉所有的包,这个很管用。
ngrep '[a-zA-Z]' -t -W byline -d any tcp port 18080

以下部分使用来自 这里:http://blog.58share.com/?p=37

4:ngrep -W byline -d lo port 18080 
捕捉cloudian:18080端口的request和response。
-W byline : 用来解析包中的换行符,否则包里的所有数据都是连续的,可读性差。
-d lo  : 是监听本地网卡

5:ngrep -W byline -d eth0 port 80
捕捉amazon:80端口的request和response。
-d eth0:  是用来监听对外的网卡
可以用-d any来捕捉所有的包,这个很管用。

6:ngrep ‘[a-zA-Z]‘ -t -W byline -d any tcp port 18080 
抓取header头信息

ngrep 比 tcpdump 更方便查看的抓包显示工具的更多相关文章

  1. wireshark抓包分析工具的使用

    # wireshark抓包分析工具的使用 ## 常用抓包指令 - `ip.src==192.168.60.26 and ip.dst==111.7.187.220 and tcp.port == 80 ...

  2. jmeter-Charles抓包显示的请求方式错误了,难道

    抓包显示的请求方式为get,但是get一直报错见上图 将get修改为post就正确了

  3. Wireshark-配合tcpdump对Android(安卓)手机抓包

    环境:Windows, 安装真机(可以获取Root权限), adb, Wireshark, tcpdump 原理: 使用 tcpdump 进行抓包, 然后用 Wireshark 进行分析 1.获取手机 ...

  4. Charles 抓包的工具

    下面是整个链接. http://www.winshy.com/2013/08/something_about_charlesproxy/?utm_source=rss Charles:移动端抓包工具安 ...

  5. 用Web抓包分析工具Livepool 实现本地替换开发

    这是官方的介绍: LivePool 是一个基于 NodeJS,类似 Fiddler 支持抓包和本地替换的 Web 开发调试工具,是 Tencent AlloyTeam 在开发实践过程总结出的一套的便捷 ...

  6. 安全测试6_Web安全工具第二节(代理抓包分析工具)

    上节课讲了浏览器及扩展,这节课继续来学习下抓包分析. 首先看下下图,了解下代理工具的原理:代理就相当于收费站一样,任何要通过的车辆必须经过它. 浏览器的代理我们可以通过设置进行手动设置代理,或者通过P ...

  7. Wireshark网络抓包(四)——工具

    一.基本信息统计工具 1)捕获文件属性(Summary) 1. File:了解抓包文件的各种属性,例如抓包文件的名称.路径.文件所含数据包的规模等信息 2. Time:获悉抓包的开始.结束和持续时间 ...

  8. 解决Charles https抓包显示<unknown>

    用mac电脑开发安卓的都应该知道青花瓷吧~(不知道的都是小菜鸡,邪恶.jpg) Charles类似Windows版的Fiddler(没用过Fiddler的都是小菜鸡中的战斗机,嘲笑.png),基本用法 ...

  9. Charles抓包显示乱码解决方法

    [问题现象] 在抓https协议请求时,Request和Response显示乱码了: [解决办法] 第一步:点击 [工具栏-->Proxy-->SSL Proxying Settings. ...

随机推荐

  1. Linux课题实践一

    Linux课题实践一 20135318 刘浩晨 1.1应用安装 (1)掌握软件源的维护方法,配置系统使用软件源镜像  删除过期或者重复的软件包:进入”系统设置“-”软件和更新”-”ubuntu软件“- ...

  2. idea 设置注释

    idea和eclipse的注释还是有一些差别的. idea: 类头注释:打开file->setting->Editor->Filr and Code Templates->In ...

  3. SVN解决冲突

    SVN冲突出现场景 如今是一个团结协作的时代,开发一个系统,往往会多人协作共同完成.版本管理是必不可少的,常用的软件有Git,SVN等.今天说一下,SVN管理版本时,如果出现冲突后,如何快速解决冲突. ...

  4. 学习github心得

    Git 是 Linux 的创始人 Linus Torvalds 开发的开源和免费的版本管理系统,利用底层文件系统原理进行版本控制的工具.Git是目前为止最著名运用最好最受欢迎的分布式的配置管理工具. ...

  5. 小学生四则运算App实验成果

    组名:会飞的小鸟 组员:徐侃 陈志棚  罗伟业 刘芮熔 —成员分工: —①刘芮熔:设置安卓包.界面的代码,界面的排序. —②陈志棚:加减乘除的判断异常处理,例如除数不能为零的异常处理等问题. —③徐侃 ...

  6. shell脚本--变量与数组

    Linux中的变量有环境变量和用户自定义变量,关于环境变量,可以查看这篇博客:linux环境变量 本文主要针对的是用户在shell脚本中定义的变量,但是环境变量也可以在shell脚本中使用. 普通变量 ...

  7. [转帖] 从零开始编写自己的C#框架(27)——什么是开发框架

    从零开始编写自己的C#框架(27)——什么是开发框架 http://www.cnblogs.com/EmptyFS/p/4105713.html 没写过代码 一直不清楚 框架的含义 不过看了一遍 也没 ...

  8. Jenkins Jfrog Artifactory 以及docker下的pipeline 容器编排实践

    1. 测试环境情况: Docker主机 10.24.101.99 JFrog Artifactory 主机 (admin password) jenkinx github原始地址:https://gi ...

  9. 深入理解CSS绝对定位absolute

    前面的话 前面已经介绍了定位的偏移和层叠,例子中大量的应用了绝对定位.因为相较于相对定位和固定定位,绝对定位在实际中应用频率更高.应用场景更广泛.本文将介绍使用绝对定位时的具体细节 定义 当元素绝对定 ...

  10. pgm16

    前面结束了关于 learning 部分一些粗浅的讨论,我们大概明白了一些 learning 中 common sense/techniques.剩下的部分我们分为 causality 和 utilit ...