Wireshark  捕捉过滤器匹配特殊‘字符串’

 

 

 

 

过滤器实例:

 


  
  1. ####### 
  2. # TCP 
  3. #  
  4. # filter ssh 
  5. tcp[(tcp[12]>>2):4] = 0x5353482D && (tcp[((tcp[12]>>2)+4):2] = 0x312E || \ 
  6.  tcp[((tcp[12]>>2)+4):2] = 0x322E) 
  7.  
  8. # filter "combine" rlogin 
  9. (tcp[(ip[2:2]-((ip[0]&0x0f)<<2))-1]=0) && \ 
  10.  ((ip[2:2]-((ip[0]&0x0f)<<2) - (tcp[12]>>2)) != 0) && \ 
  11.  ((ip[2:2]-((ip[0]&0x0f)<<2) - (tcp[12]>>2)) <= 128) 
  12.  
  13. # filter ftp 
  14. tcp[(tcp[12]>>2):4] = 0x3232302d || tcp[(tcp[12]>>2):4] = 0x32323020 
  15.  
  16. # URG set and ACK not set 
  17. tcp[13] & 0x30 = 0x20  
  18.  
  19. # IMAP service exploit  
  20. tcp && (tcp[13] & 2 != 0) && (dst port 143) 
  21.  
  22. # filter root backdoor 
  23. tcp[(tcp[12]>>2):2] = 0x2320 && \ 
  24.  (ip[2:2] - ((ip[0]&0x0f)<<2) - (tcp[12]>>2)) == 2 
  25.  
  26. # RST set and FIN set 
  27. tcp[13] & 0x05 = 5  
  28.  
  29. # filter out napster 
  30. ((ip[2:2] - ((ip[0]&0x0f)<<2) - (tcp[12]>>2)) = 4 && \ 
  31.  tcp[(tcp[12]>>2):4] = 0x53454e44) || \ 
  32.  ((ip[2:2] - ((ip[0]&0x0f)<<2) - (tcp[12]>>2)) = 3 && \ 
  33.  tcp[(tcp[12]>>2):2] = 0x4745 && tcp[(tcp[12]>>2)+2]=0x54) 
  34.  
  35. # telnet  
  36. tcp[2:2] = 23 
  37. # again telnet but beter... 
  38. (tcp[(tcp[12]>>2):2] > 0xfffa) && (tcp[(tcp[12]>>2):2] < 0xffff
  39.  
  40. # attempted ftp connection to other hosts on the network than the ftp server 
  41. dst net 82.48.9.1/22 && dst port 21 \ 
  42.  && (tcp[13] & 0x3f = 2) && !(dst host ftp.bla.org) 
  43.  
  44. # attempts to include data on the initial SYN. 
  45. tcp[13] & 0xff = 2 && \ 
  46.  (ip[2:2] - ((ip[0] & 0x0f) * 4) - ((tcp[12] & 0xf0) / 4)) != 0 
  47.  
  48. # active open (syn set without ack) 
  49. (tcp[13] & 0x12 < 16
  50.  
  51. # winnuke DOS attack 
  52. (tcp[2:2] = 139) && (tcp[13] & 0x20 != 0) && (tcp[19] & 0x01 = 1) 
  53.  
  54. # destination port less than 1024 
  55. tcp[2:2] < 1024 
  56.  
  57. # SYN set and FIN set 
  58. tcp[13] & 0x03 = 3 
  59.  
  60. # one of the reserved bits of tcp[13] is set 
  61. tcp[13] & 0xc0 != 0  
  62.  
  63. # DNS zone transfer 
  64. tcp && dst port 53  
  65.  
  66. # active open connection, syn is set, ack is not 
  67. tcp[13] & 0x12 = 2 
  68.  
  69. # X11 ports 
  70. (tcp[2:2] >= 6000) && (tcp[2:2] < 7000
  71.  
  72. # TCP port 6667 with ACK flag set and payload starting at byte 12  
  73. # that does not include the asciiwords "PING", "PONG", "JOIN", or "QUIT". 
  74. (tcp[13] & 0x10 = 1) && (tcp[0:2]=6667 || tcp[2:2]=6667) \ 
  75.  && (not ip[32:4] = 1346981447 || not ip[32:4] = 1347374663 \ 
  76.  || not ip[32:4] = 1246710094 || not ip[32:4] = 1364543828) 
  77.  
  78. # except ack push 
  79. (tcp[13] & 0xe7) != 0 
  80.  
  81. # all packets with the PUSH flag set 
  82. tcp[13] & 8 != 0 
  83.  
  84. # all packets with the RST flag set 
  85. tcp[13] & 4 != 0 
  86.  
  87. # filter out gnutella 
  88. tcp[(tcp[12]>>2):4] = 0x474e5554 && \ 
  89.  tcp[(4+(tcp[12]>>2)):4] = 0x454c4c41 && tcp[8+(tcp[12]>>2)] = 0x20 
  90.  
  91. # catch default hping 2 pings 
  92. tcp [3] = 0 && tcp[13] = 0  
  93.  
  94. # FIN set and ACK not set 
  95. tcp[13] & 0x11 = 1        
  96.  
  97. # null scan filter with no flags set 
  98. tcp[13] = 0 
  99. # could also be written as 
  100. tcp[13] & 00xff = 0 
  101.  
  102. # no flags set, null packet 
  103. tcp[13] & 00x3f = 0 
  104.  
  105. # syn-fyn  
  106. tcp[13] = 3 
  107.  
  108. # syn-fyn both flags set 
  109. (tcp[13] & 0x03) = 3 
  110.  
  111. # only syn.. 
  112. tcp[13] & 0x02) != 0 
  113. ####### 

参考:

http://www.wireshark.org/docs/man-pages/wireshark-filter.html

http://www.packetlevel.ch/html/tcpdumpf.html

http://www.wireshark.org/lists/wireshark-users/201003/msg00024.html