ipstrings

  • 通信量を統計するipauditについてくるおまけツール(?).パケットからASCII文字列を抽出する.
  • ngrepとは違ってマッチング機能はない.連続するASCII文字列の長さによる出力制御が出来る.
  • パケットダンプ全てを保存する場合に比べ,ASCII文字列のみを残しバイナリ部分,暗号化された部分を捨ててしまうことでサイズを1/5程度に,bzip2圧縮と併用すれば1/10弱に押えることが出来る.
  • リンク
  • オプション
Usage: ipstrings  -defimnprtwvz [interface]
  Read tcp packets destined for specific port (default 21, FTP) live
   from interface or from dump file and print ascii strings.

  -n nchar      -  Minimum length of printed strings, 0 means print only NULL terminated strings, default is 4
  -r readfile   -  Read packets from pcap format file, use -r- for standard in Don't need interface with this option
  -f filterstr  -  Use pcap filters (see tcpdump)
  -w writefile  -  Dump selected packets to pcap format file,
                   use -w- for standard out
  -s nlen       -  Read first <nlen> bytes of each packet live
                   (default 96, min 68)
  -c npacket    -  Only read in specific number of ip packets
  -m            -  Do not enter promiscuous mode
  -e            -  Print source, destination ethernet address for each packet
  -i            -  Print source, destination ip address for each packet
  -p            -  Print source, destination port addresses for each packet
  -t            -  Print time of day for each packet
  -z            -  Print size of each ip packet
  -v            -  Print version info
  -d            -  Print debug info
  • デフォルト(連続するASCII文字列の長さ4以上)だと改行が無視されて読みづらいので,それらを空白にして出力する.
*** ipstrings.c.dist	2003-10-08 12:00:37.000000000 +0900
--- ipstrings.c	2005-12-10 14:57:30.808249000 +0900
***************
*** 149,155 ****
  
  
  #define ISPRINT(c) \
! 	((c)>31 && (c)<127)
  
  
  
--- 149,155 ----
  
  
  #define ISPRINT(c) \
! 	( ((c)>31 && (c)<127) || ((c) == 10) || ((c) == 13) )
  
  
  
***************
*** 752,761 ****
  		while (*strstart && nstring--) {
  			switch (*strstart) {
  				case '\n':
! 					printf ("\\n");
  					break;
  				case '\r':
! 					printf ("\\r");
  					break;
  				default:
  					printf ("%c", *strstart);
--- 752,761 ----
  		while (*strstart && nstring--) {
  			switch (*strstart) {
  				case '\n':
! 					printf (" ");
  					break;
  				case '\r':
! 					printf (" ");
  					break;
  				default:
  					printf ("%c", *strstart);
  		}