词条信息

admin
admin
超级管理员
词条创建者 发短消息   

相关词条

热门词条

更多>>
什么是端口?到底是做什么的呢?
端口一般指两种,一种是硬件比如路由器或者交换机的插网线的端口,一种是软件的逻辑的概念,比如http的80端口!...
7种进阶方法让你快速测试端口连通性
Ping是Windows、Linux和Unix系统下的一个检查网络连通性的命令工具,对于大部分互联网用户来说很...
电脑开机,总需要按F1,是什么原因造成的?
一.主板掉电这个说法是行业内的叫法了,一般是主板的CMOS电池没电了导致的。也是最常见的一种提示你按F1的提示...
社保降费对个人有什么影响?
下调城镇职工基本养老保险单位缴费比例是政府给企业发的一个大红包,特别是对于企业来说是一个利好,但是对个人来说有...
车辆“出险”对下年保费的影响,到底有多大?
【出险对交强险的影响】【出险对商业险的影响】车辆“出险”对下年保费的影响,到底有多大?这里有必要先提下车险第三...

精选图集

更多>>
简易百科旧版 >>所属分类 >> 软件技术    Linux   

Linux系统中ngrep的用法

标签: Linux ngrep

顶[0] 发表评论(0) 编辑词条

  ngrep 是grep的网络版,他力求更多的grep特征,用于搜寻指定的数据包。由于安装ngrep需用到ibpcap库, 所以支持大量的操作系统和网络协议,能识别TCP、UDP和ICMP包。

  安装ngrep

  下载地址

  代码如下:

  git clone git://git.code.sf.net/p/ngrep/code ngrep-code

  进入目录

  代码如下:

  cd ngrep-code

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

  make

  make install

  选项

  -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

  应用举例:

  捕获所有post请求(加个-W byline 参数后,将解析包中的换行符):

  代码如下:

  ranger@ranger:~$ sudo ngrep -q -W byline "(POST).*"

  interface: eth0 (192.168.122.0/255.255.254.0)

  match: (POST).*

  T 192.168.122.74:46048 -> 140.207.228.58:80 [A]

  POST /Hotel/OTA_HotelSearch.asmx?wsdl HTTP/1.1.

  Content-Type: text/xml; charset=UTF-8.

  SOAPAction: http://ctrip.com/Request.

  Accept-Encoding: gzip, deflate.

  Content-Length: 1330.

  Accept: */*.

  Accept-Language: zh-cn.

  User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0).

  UA-CPU: x86.

  Accept-Encoding: gzip, deflate.

  Connection: close.

  Host: openapi.ctrip.com.

  .

   <Request>

  <Header AllianceID="***" SID="***" TimeStamp="1393554304685" RequestType="OTA_HotelSearch" Signature="B166CDF5422A6DA5BA81A08036E938E7"/>

  <HotelRequest>

  <RequestBody xmlns:ns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <ns:OTA_HotelSearchRQ Version="1.0" PrimaryLangID="zh"

  xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelSearchRQ.xsd"

 

 

附件列表


按字母顺序浏览:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

→我们致力于为广大网民解决所遇到的各种电脑技术问题
 如果您认为本词条还有待完善,请 编辑词条

上一篇Linux中find的常见用法
下一篇如何安装linux系统

0
1. 本站部分内容来自互联网,如有任何版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
2. 本站内容仅供参考,如果您需要解决具体问题,建议您咨询相关领域专业人士。
3. 如果您没有找到需要的百科词条,您可以到百科问答提问或创建词条,等待高手解答。

关于本词条的提问

查看全部/我要提问>>