ngrep 是grep的網絡版,他力求更多的grep特征,用于搜尋指定的數據包。由于安裝ngrep需用到ibpcap庫, 所以支持大量的操作系統和網絡協議,能識別TCP、UDP和ICMP包。
安裝ngrep
下載地址
選項
-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 參數后,將解析包中的換行符):
新聞熱點
疑難解答