<code id='05rxj'><strong id='05rxj'></strong></code>
    1. <fieldset id='05rxj'></fieldset>

      <i id='05rxj'><div id='05rxj'><ins id='05rxj'></ins></div></i>

    2. <ins id='05rxj'></ins>
    3. <tr id='05rxj'><strong id='05rxj'></strong><small id='05rxj'></small><button id='05rxj'></button><li id='05rxj'><noscript id='05rxj'><big id='05rxj'></big><dt id='05rxj'></dt></noscript></li></tr><ol id='05rxj'><table id='05rxj'><blockquote id='05rxj'><tbody id='05rxj'></tbody></blockquote></table></ol><u id='05rxj'></u><kbd id='05rxj'><kbd id='05rxj'></kbd></kbd>
    4. <span id='05rxj'></span>

      <dl id='05rxj'></dl>
        <acronym id='05rxj'><em id='05rxj'></em><td id='05rxj'><div id='05rxj'></div></td></acronym><address id='05rxj'><big id='05rxj'><big id='05rxj'></big><legend id='05rxj'></legend></big></address>

          <i id='05rxj'></i>

          Linux系统中字符串搜索命令ngrep的用法

          • 时间:
          • 浏览:9
          • 来源:124软件资讯网

              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.

              .

              

              

              

              

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

              

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