Linux系統(tǒng)中字符串搜索命令ngrep的用法

這篇文章主要介紹“Linux系統(tǒng)中字符串搜索命令ngrep的用法”,在日常操作中,相信很多人在Linux系統(tǒng)中字符串搜索命令ngrep的用法問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Linux系統(tǒng)中字符串搜索命令ngrep的用法”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)松陽(yáng)免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了1000+企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

安裝ngrep
下載地址

代碼如下:


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


進(jìn)入目錄

代碼如下:


cd ngrep-code
./configure --with-pcap-includes=/usr/local/include/pcap
make
make install

選項(xiàng)

-h     is help/usage
-V    is version information
-q    is be quiet (don't print packet reception hash marks)靜默模式,如果沒(méi)有此開關(guān),未匹配的數(shù)據(jù)包都以“#”顯示
-e    is show empty packets 顯示空數(shù)據(jù)包
-i     is ignore case 忽略大小寫
-v    is invert match 反轉(zhuǎn)匹配
-R   is don't do privilege revocation logic
-x    is print in alternate hexdump format 以16進(jìn)制格式顯示
-X   is interpret match expression as hexadecimal 以16進(jìn)制格式匹配
-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在每個(gè)匹配的包之前顯示時(shí)間戳
-T    is print delta timestamp every time a packet is matched顯示上一個(gè)匹配的數(shù)據(jù)包之間的時(shí)間間隔
-M   is don't do multi-line match (do single-line match instead)僅進(jìn)行單行匹配
-I     is read packet stream from pcap format file pcap_dump 從文件中讀取數(shù)據(jù)進(jìn)行匹配
-O   is dump matched packets in pcap format to pcap_dump 將匹配的數(shù)據(jù)保存到文件
-n    is look at only num packets 僅捕獲指定數(shù)目的數(shù)據(jù)包進(jìn)行查看
-A   is dump num packets after a match匹配到數(shù)據(jù)包后Dump隨后的指定數(shù)目的數(shù)據(jù)包
-s    is set the bpf caplen
-S   is set the limitlen on matched packets
-W  is set the dump format (normal, byline, single, none) 設(shè)置顯示格式byline將解析包中的換行符
-c    is force the column width to the specified size 強(qiáng)制顯示列的寬度
-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定義的子協(xié)議號(hào)
-d   is use specified device (index) instead of the pcap default


應(yīng)用舉例:

捕獲所有post請(qǐng)求(加個(gè)-W byline 參數(shù)后,將解析包中的換行符):

代碼如下:


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.
.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <Request xmlns="http://ctrip.com/"> <requestXML>&lt;Request&gt;
&lt;Header AllianceID="***" SID="***" TimeStamp="1393554304685" RequestType="OTA_HotelSearch" Signature="B166CDF5422A6DA5BA81A08036E938E7"/&gt;
&lt;HotelRequest&gt;
&lt;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"&gt;
&lt;ns:OTA_HotelSearchRQ Version="1.0" PrimaryLangID="zh"
xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_HotelSearchRQ.xsd"

到此,關(guān)于“Linux系統(tǒng)中字符串搜索命令ngrep的用法”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

當(dāng)前標(biāo)題:Linux系統(tǒng)中字符串搜索命令ngrep的用法
網(wǎng)頁(yè)URL:http://muchs.cn/article22/ipgsjc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、網(wǎng)站收錄微信公眾號(hào)、網(wǎng)站內(nèi)鏈、搜索引擎優(yōu)化網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司