`
eyesmore
  • 浏览: 364537 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

wireshark过滤器

阅读更多

<!-- [if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!-- [if !mso]><span class="mceItemObject" classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></span> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><!-- [if !supportAnnotations]--><!-- --> <script><!-- function msoCommentShow(anchor_id, com_id) { if(msoBrowserCheck()) { c = document.all(com_id); a = document.all(anchor_id); if (null != c && null == c.length && null != a && null == a.length) { var cw = c.offsetWidth; var ch = c.offsetHeight; var aw = a.offsetWidth; var ah = a.offsetHeight; var x = a.offsetLeft; var y = a.offsetTop; var el = a; while (el.tagName != "BODY") { el = el.offsetParent; x = x + el.offsetLeft; y = y + el.offsetTop; } var bw = document.body.clientWidth; var bh = document.body.clientHeight; var bsl = document.body.scrollLeft; var bst = document.body.scrollTop; if (x + cw + ah / 2 > bw + bsl && x + aw - ah / 2 - cw >= bsl ) { c.style.left = x + aw - ah / 2 - cw; } else { c.style.left = x + ah / 2; } if (y + ch + ah / 2 > bh + bst && y + ah / 2 - ch >= bst ) { c.style.top = y + ah / 2 - ch; } else { c.style.top = y + ah / 2; } c.style.visibility = "visible"; } } } function msoCommentHide(com_id) { if(msoBrowserCheck()) { c = document.all(com_id); if (null != c && null == c.length) { c.style.visibility = "hidden"; c.style.left = -1000; c.style.top = -1000; } } } function msoBrowserCheck() { ms = navigator.appVersion.indexOf("MSIE"); vers = navigator.appVersion.substring(ms + 5, ms + 6); ie4 = (ms > 0) && (parseInt(vers) >= 4); return ie4; } if (msoBrowserCheck()) { document.styleSheets.dynCom.addRule(".msocomanchor","background: infobackground"); document.styleSheets.dynCom.addRule(".msocomoff","display: none"); document.styleSheets.dynCom.addRule(".msocomtxt","visibility: hidden"); document.styleSheets.dynCom.addRule(".msocomtxt","position: absolute"); document.styleSheets.dynCom.addRule(".msocomtxt","top: -1000"); document.styleSheets.dynCom.addRule(".msocomtxt","left: -1000"); document.styleSheets.dynCom.addRule(".msocomtxt","width: 33%"); document.styleSheets.dynCom.addRule(".msocomtxt","background: infobackground"); document.styleSheets.dynCom.addRule(".msocomtxt","color: infotext"); document.styleSheets.dynCom.addRule(".msocomtxt","border-top: 1pt solid threedlightshadow"); document.styleSheets.dynCom.addRule(".msocomtxt","border-right: 2pt solid threedshadow"); document.styleSheets.dynCom.addRule(".msocomtxt","border-bottom: 2pt solid threedshadow"); document.styleSheets.dynCom.addRule(".msocomtxt","border-left: 1pt solid threedlightshadow"); document.styleSheets.dynCom.addRule(".msocomtxt","padding: 3pt 3pt 3pt 3pt"); document.styleSheets.dynCom.addRule(".msocomtxt","z-index: 100"); } // --></script><!-- [endif]--> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:黑体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimHei; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"\@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@黑体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} h1 {mso-style-next:正文; margin-top:17.0pt; margin-right:0cm; margin-bottom:16.5pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:240%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:1; font-size:22.0pt; font-family:"Times New Roman"; mso-font-kerning:22.0pt;} h2 {mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:2; font-size:16.0pt; font-family:Arial; mso-fareast-font-family:黑体; mso-bidi-font-family:"Times New Roman"; mso-font-kerning:1.0pt;} h3 {mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:3; font-size:16.0pt; font-family:"Times New Roman"; mso-font-kerning:1.0pt;} p.MsoCommentText, li.MsoCommentText, div.MsoCommentText {mso-style-noshow:yes; margin:0cm; margin-bottom:.0001pt; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} span.MsoCommentReference {mso-style-noshow:yes; mso-ansi-font-size:10.5pt; mso-bidi-font-size:10.5pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:891649832; mso-list-type:hybrid; mso-list-template-ids:1971879654 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-tab-stop:21.0pt; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt;} @list l1 {mso-list-id:1878079274; mso-list-type:hybrid; mso-list-template-ids:21677698 -967258448 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-text:%1、; mso-level-tab-stop:18.0pt; mso-level-number-position:left; margin-left:18.0pt; text-indent:-18.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} --> <!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

WireShark 过滤器

WireShark 提供两种不同类型的过滤器:

捕捉过滤器: 用于决定将什么样的信息记录在捕捉结果中。需要在开始捕捉前设置。

显示过滤器: 在捕捉结果中进行详细查找。他们可以在得到捕捉结果后随意修改。

那么我应该使用哪一种过滤器呢?

两种过滤器的目的是不同的,使用的语法也不同。

捕捉过滤器是数据经过的第一层过滤器,它用于控制捕捉数据的数量,以避免产生过大的日志文件。

显示过滤器是一种更为强大(复杂)的过滤器。它允许您在日志文件中迅速准确地找到所需要的记录。

捕捉过滤器

语法:

<!-- [if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style="width:356.25pt; height:30pt" mce_style="width:356.25pt; height:30pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" o:title="New2"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

“捕获单元”是 PDHV Protocol-Direction-Hosts-Value

“捕获表达式”是由逻辑运算符连接起来的“捕获单元”的序列。

 

Protocol (协议) :

可能的值 : ether, fddi, ip, arp, rarp, decnet, lat, sca, moprc, mopdl, tcp and udp.

如果没有特别指明是什么协议,则默认使用所有支持的协议。

 

Direction (方向) :

可能的值 : src, dst, src and dst, src or dst

如果没有特别指明来源或目的地,则默认使用 "src or dst" 作为关键字。

例如, "host 10.2.2.2" "src or dst host 10.2.2.2" 是一样的。

 

Host(s): (表示“目的地”,可以是真的 host ,也可以是 port 等,也可以是 host 集合, post 集合。)

可能的值: net, port, host, portrange.

如果没有指定此值,则默认使用 "host" 关键字。

例如, "src 10.1.1.1" "src host 10.1.1.1" 相同。

讲解 1 Host(s) 是个抽象的概念,不一定是真的 host ,而是目的地的意思,我们可以指定主机 host ,主机范围(也就是网络) net ,端口 port 和端口范围 portrange

讲解 2 :在 Protocol 中已经指明了协议,为什么还要指定端口呢?其实协议跟端口的映射关系并不是严格的,端口才是真正决定网络上一个进程的,而协议是用来告诉 wireshark 如何解析报文。

 

Value

数值表示的是 Host(s) 对应的值。

 

 

Logical Operations (逻辑运算) :

可能的值: not, and, or.

("not") 具有最高的优先级。或 ("or") 和与 ("and") 具有相同的优先级,运算时从左至右进行。

例如,

"not tcp port 3128 and tcp port 23" "(not tcp port 3128) and tcp port 23" 相同。

"not tcp port 3128 and tcp port 23" "not (tcp port 3128 and tcp port 23)" 不同。

 

实例练习

<!-- [if !supportLists]-->1.         <!-- [endif]-->问:捕捉目的 TCP 端口为 3128 的封包。

答: tcp   dst   port   3128

<!-- [if !supportLists]-->2.         <!-- [endif]-->问:捕捉来源 IP 地址为 10.1.1 .1 的封包。

答: src host 10.1.1.1

<!-- [if !supportLists]-->3.         <!-- [endif]-->问:捕捉目的或来源 IP 地址为 10.1.2 .3 的封包。

答: src or dst   host 10.1.2.3  ( host 10.1.2.3 因为 src or dst Direction 的默认值 )

<!-- [if !supportLists]-->4.         <!-- [endif]-->问:捕捉来源为 UDP TCP ,并且端口号在 2000 2500 范围内的封包。

答: src  portrange  200-2500

<!-- [if !supportLists]-->5.         <!-- [endif]-->问:捕捉除了 icmp 以外的所有封包。( icmp 通常被 ping 工具使用)

答: not    icmp

<!-- [if !supportLists]-->6.         <!-- [endif]-->问:捕获来源 IP 地址为 10.7.2 .12 ,但目的地不是 10.200.0.0/16 的封包。

答: src  host  10.7.2.12  and   not dst net   10.200.0.0/16

<!-- [if !supportLists]-->7.         <!-- [endif]-->问:捕获来源 IP 10.4.1 .12 或者来源网络为 10.6.0.0/16 ,目的地 TCP 端口号在 200 10000 之间,并且目的位于网络 10.0.0.0/8 内的所有封包。

答: (src host 10.4.1.12 or src net 10.6.0.0/16) and tcp dst portrange 200-10000 and dst net 10.0.0.0/8

 

<!-- [if !supportLists]-->8.         <!-- [endif]-->注意事项:

当使用关键字作为值时,需使用反斜杠 “\”

  "ether proto \ip" ( 与关键字 "ip" 相同 )

这样写将会以 IP 协议作为目标。

"ip proto \icmp" ( 与关键字 "icmp" 相同 ).

这样写将会以 ping 工具常用的 icmp 作为目标。

可以在 "ip" "ether" 后面使用 "multicast" "broadcast" 关键字。

当您想排除广播请求时, "no broadcast" 就会非常有用。

 

TCPDUMP 的语法 http://www.ethereal.com/docs/man-pages/tcpdump.8.html

常见错误

研究院测试时用: tcp host 192.168.18.202 port 22

语法: PDHV ,其中 Hosts 可以是 host, port, net, portrange 但是指定目的一个“捕获单元”只能选择一个关键字,如果要指定主机 + 端口,必须得由两个“捕获单元”。 Tcp host 192.168.18.202 and tcp dst port 22 。可是我们在 wireshark 中输入时依然有错误。

但是捕获过滤器,在指定主机和端口方面还是方便的。比如我们希望捕获主机 192.168.18.202 22 端口,我们可以写 : dst host 192.168.18.202 and dst port 22

工作实战

<!-- [if !supportLists]-->9.         <!-- [endif]-->分析从本机到 www.baidu.com HTTP 请求

1 )捕获过滤器: dst host www.baidu.com and dst port 80

2 )此时捕获中可以看到很多报文,其中包括 TCP 建立连接的部分,如果我们只想分析 HTTP 应用层协议,那么我们可以使用“显示过滤器”。显示过滤器配置: http.host == www.baidu.com Filter 编辑区会提供提示,用户只要输入 http. ,那么可选的参数都会显示出来,如果尚未编辑完,有语法错误,编辑区的背景是“红色”的,如果语法正确,那么编辑区是“绿色”的。编辑完后,点击“ Apply ”则会应用该过滤器。)

3 )观察第一个包 GET / HTTP/1.1 ,双击打开专门的包查看器,可以看到不同层的信息。

<!-- [if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" style="width:324pt;height:74.25pt" mce_style="width:324pt;height:74.25pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image002.gif" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image002.gif" o:title="New2"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

整个一个流“比特流”,一大片的数据,被解析成了层次结构:数据帧,以太网, IP 层, TCP 层次,应用层( HTTP 协议)。

4 )复制出数据并在文本编辑器中分析

如果要复制数据,就不能在专门的“单行(双击后出来的)”查看器中查看,而要在集成的(捕获界面直接显示的)查看器查看。复制功能比较强大,可以自由选择要复制的协议层次和格式( Hex, offsetHex )。

<!-- [if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" style="width:414.75pt;height:136.5pt" mce_style="width:414.75pt;height:136.5pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image003.png" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image003.png" o:title="New2"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

HTTP 协议部分, Copy 的格式是: offset  Hex  Text

0000   <!-- [if !supportAnnotations]-->[l1] <!-- [endif]-->  47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a <!-- [if !supportAnnotations]-->[l2] <!-- [endif]-->    GET / HTTP/1.1 <!-- [if !supportAnnotations]-->[l3] <!-- [endif]-->  ..

0010   48 6f 73 74 3a 20 77 77 77 2e 62 61 69 64 75 2e  Host: www.baidu.

0020    63 6f 6d 0d 0a <!-- [if !supportAnnotations]-->[l4] <!-- [endif]-->  55 73 65 72 2d 41 67 65 6e 74 3a  com..User-Agent:

0030   20 4d 6f 7a 69 6c 6c 61 2f 35 2e 30 20 28 57 69   Mozilla/5.0 (Wi

0040   6e 64 6f 77 73 3b 20 55 3b 20 57 69 6e 64 6f 77  ndows; U; Window

0050   73 20 4e 54 20 35 2e 31 3b 20 65 6e 2d 55 53 3b  s NT 5.1; en-US;

0060   20 72 76 3a 31 2e 39 2e 31 2e 35 29 20 47 65 63   rv:1.9.1.5) Gec

0070   6b 6f 2f 32 30 30 39 31 31 30 32 20 46 69 72 65  ko/20091102 Fire

0080   66 6f 78 2f 33 2e 35 2e 35 20 28 2e 4e 45 54 20  fox/3.5.5 (.NET

0090    43 4c 52 20 33 2e 35 2e 33 30 37 32 39 29 0d 0a  CLR 3.5.30729)..

00a 0   41 63 63 65 70 74 3a 20 74 65 78 74 2f 68 74 6d  Accept: text/htm

00b0   6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 68  l,application/xh

00c 0   74 6d 6c 2b 78 6d 6c 2c 61 70 70 6c 69 63 61 74  tml+xml,applicat

00d0   69 6f 6e 2f 78 6d 6c 3b 71 3d 30 2e 39 2c 2a 2f  ion/xml;q=0.9,*/

00e0   2a 3b 71 3d 30 2e 38 0d 0a 41 63 63 65 70 74 2d  *;q=0.8..Accept-

00f 0   4c 61 6e 67 75 61 67 65 3a 20 65 6e 2d 75 73 2c  Language: en-us,

0100   65 6e 3b 71 3d 30 2e 35 0d 0a 41 63 63 65 70 74  en;q=0.5..Accept

0110   2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70 2c  -Encoding: gzip,

0120   64 65 66 6c 61 74 65 0d 0a 41 63 63 65 70 74 2d  deflate..Accept-

0130   43 68 61 72 73 65 74 3a 20 49 53 4f 2d 38 38 35  Charset: ISO-885

0140   39 2d 31 2c 75 74 66 2d 38 3b 71 3d 30 2e 37 2c  9-1,utf-8;q=0.7,

0150   2a 3b 71 3d 30 2e 37 0d 0a 4b 65 65 70 2d 41 6c  *;q=0.7..Keep-Al

0160   69 76 65 3a 20 33 30 30 0d 0a 43 6f 6e 6e 65 63  ive: 300..Connec

0170   74 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65  tion: keep-alive

0180   0d 0a 43 6f 6f 6b 69 65 3a 20 42 41 49 44 55 49  ..Cookie: BAIDUI

0190   44 3d 37 32 32 34 32 37 30 36 36 30 39 41 44 46  D=72242706609ADF

01a 0   36 34 38 34 44 32 43 37 30 46 38 37 32 41 44 37  6484D2C70F872AD7

01b0   41 37 3a 46 47 3d 31 0d 0a 0d 0a                 A7:FG=1....

 

<!-- [if !supportLists]-->10.     <!-- [endif]-->对应的响应报文为什么捕获不到?

1 )我们除了关心请求,还关心请求对应的响应。所以我们在 Destination 上应该使用 src or dst ,也就是默认值。从“ dst host www.baidu.com and dst port 80 修改成“ src or dst host www.baidu.com and src or dst port 80 ,或者“ host   www.baidu.com   and port 80

2 )修改成“ host www.baidu.com and port 80 后,我们已经看到 HTTP 响应报文了,但是也有很多 TCP 层的交互,所以我们还要把 HTTP 单独过滤出来,所以我们在显示过滤器配置“ http ”,而不需要带子过滤器“ http.host == www.baidu.com ”,这样会把响应给过滤掉。“ http ”不带子项,表示 HTTP 协议,无论请求还是响应。

<!-- [if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" style="width:414.75pt;height:110.25pt" mce_style="width:414.75pt;height:110.25pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image005.png" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image005.png" o:title="New2"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

 

显示过滤器

通常经过捕捉过滤器过滤后的数据还是很复杂。此时您可以使用显示过滤器进行更加细致的查找。它的功能比捕捉过滤器更为强大 ,而且在您想修改过滤器条件时,并不需要重新捕捉一次。

语法:

<!-- [if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" style="width:400.5pt;height:42.75pt" mce_style="width:400.5pt;height:42.75pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image007.gif" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image007.gif" o:title="New3"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

“显示单元”是 Protocol String1 String2 ComparisonOperator value

“显示表达式”是逻辑运算符连接起来的“显示单元”的序列。

 

Protocol (协议) :

 

您可以使用大量位于 OSI 模型第 2 7 层的协议。点击 "Expression..." 按钮 <!-- [if !supportAnnotations]-->[l5] <!-- [endif]-->  后,您可以看到它们。

比如: IP TCP DNS SSH

 

String1, String2 ( 可选项 ):

 

协议的子类。

点击相关父类旁的 "+" 号,然后选择其子类。

 

<!-- [if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" style="width:375pt;height:265.5pt" mce_style="width:375pt;height:265.5pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image008.png" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image008.png" o:title=""/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

 

 

Comparison operators (比较运算符) :

 

可以使用 6 种比较运算符:

<!-- [if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" style="width:146.25pt;height:104.25pt" mce_style="width:146.25pt;height:104.25pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image010.gif" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image010.gif" o:title="New4"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

 

Logical expressions (逻辑运算符) :

<!-- [if gte vml 1]><v:shape id="_x0000_i1032" type="#_x0000_t75" style="width:146.25pt;height:76.5pt" mce_style="width:146.25pt;height:76.5pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image011.gif" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image011.gif" o:title="New5"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

被程序员们熟知的逻辑 <!-- [if !supportAnnotations]-->[l6] <!-- [endif]-->  一种排除性的或。当其被用在过滤器的两个条件之间时,只有当且仅当其中的一个条件满足时,这样的结果才会被显示在屏幕上。让我们举个例子: "tcp.dstport 80   xor   tcp.dstport 1025"

只有当目的 TCP 端口为 80 或者来源于端口 1025 (但又不能同时满足这两点)时,这样的封包才会被显示。

实例练习

<!-- [if !supportLists]-->11.     <!-- [endif]-->问:显示来源或目的 IP 地址为 10.1.1 .1 的封包。

答: ip.addr == 10.1.1.1

<!-- [if !supportLists]-->12.     <!-- [endif]-->问:显示来源不为 10.1.2 .3 或者目的不为 10.4.5.6 的封包。

答: ip.src != 10.1.2.3 or ip.dst != 10.4.5.6

<!-- [if !supportLists]-->13.     <!-- [endif]-->问:显示来源不为 10.1.2 .3 或者目的不为 10.4.5.6 的封包。

答: ip.src != 10.1.2.3 or ip.dst != 10.4.5.6

换句话说,显示的封包将会为:

来源 IP :除了 10.1.2 .3 以外任意;目的 IP :任意以及来源 IP :任意;目的 IP :除了 10.4.5 .6 以外任意

<!-- [if !supportLists]-->14.     <!-- [endif]-->问:显示来源不为 10.1.2 .3 并且目的 IP 不为 10.4.5.6 的封包。

答: ip.src != 10.1.2.3 and ip.dst != 10.4.5.6

 

tcp.port == 25       显示来源或目的 TCP 端口号为 25 的封包。

tcp.dstport == 25   显示目的 TCP 端口号为 25 的封包。

tcp.flags  显示包含 TCP 标志的封包。

tcp.flags.syn == 0x02    显示包含 TCP SYN 标志的封包。

 

如果过滤器的语法是正确的,表达式的背景呈绿色。如果呈红色,说明表达式有误。

<!-- [if gte vml 1]><v:shape id="_x0000_i1033" type="#_x0000_t75" style="width:377.25pt;height:55.5pt" mce_style="width:377.25pt;height:55.5pt"> <v:imagedata src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image012.gif" mce_src="file:///C:\DOCUME~1\liwei2\LOCALS~1\Temp\msohtml1\01\clip_image012.gif" o:title="New2"/> </v:shape><![endif]--><!-- [if !vml]--><!-- [endif]-->

 

Sniffer 常识

要抓到包,有两个条件:要 Sniffer 访问某个网卡,而且数据要走这个网卡。

We're EffeTech - leading network monitoring <!-- [if !supportAnnotations]-->[l7] <!-- [endif]-->  solution provider. We're the people who also bring you EtherDetect Packet Sniffer (Connection-oriented packet sniffer), and HTTP Sniffer (capture and reassembly HTTP packets).

How it works?

MSN Sniffer utilizes network adapter to capture MSN chats passing through the computer on which it is installed. So all you need to do is to make MSN chats traffic from other computers pass through the monitoring computer <!-- [if !supportAnnotations]-->[l8] <!-- [endif]-->  . A hub or a switch with port monitoring will do the job You can use a hub, or configure SPAN or port mirroring for your switch to forward a copy of each packet to your monitoring PC. , and there is also many alternatives available .

(因为 MSN Sniffer 是依靠捕获网卡上的数据来捕获 MSN 消息的,所以你要捕获 MSN 消息,你所要做的一件事就是让 MSN 消息经过你的网卡,也就是安装有 MSN Sniffer 软件的计算机上的网卡。要做到这一点,如果你的网络设备用的是 Hub ,那自然可以捕获;如果你的网络设备用的是交换机,那交换机一般都带“监控管理”功能,有个 port monitoring 。如果这两个你做不到,那么还有其他的替代方案:)

 

1. Execute the sniffer program on your Internet gateway <!-- [if !supportAnnotations]-->[l9] <!-- [endif]-->  , router or proxy server if possible. Any Internet traffic will pass through the gateway, therefore sniffer program could capture them.

2. Send some fake ARP packet to your network to cheat your switch (ARP 欺骗 <!-- [if !supportAnnotations]-->[l10] <!-- [endif]-->  ). And then switch will forward traffic from other computers to your computer. But it is an inefficient and dangerous way.

3. Downgrade <!-- [if !supportAnnotations]-->[l11] <!-- [endif]-->  your top-level switch to a common hub. (把高档的交换机换成普通的 Hub If your Internet bandwidth is less than 5M bps, downgrading will not have any negative impact on your Internet access. Please note most Internet bandwidth for home or company are less than 5M bps. Typical bandwidth are Dial-up(0.06M bps), DSL/Cable(0.4M bps), and T1(1.5M bps). Replace top-level switch with a hub as following diagram.

 

 

1 Hub 本身是共享网络,很自然可以被捕获到。但是目前大部分公司都不再使用 Hub 了,即使使用也只是临时集中工作时,一个小组有时为了方便临时组建一个基于 Hub 的共享网络。

2 Switch 环境,需要 Switch 支持 port monitoring 。当配置好 port monitoring 后, Switch 上所有转发的报文都会转发一份到 port monitoring 端口, Sniffer 软件就安装在这个端口对应的共享网络上,从而能够捕获报文。

3 、其他替代方法,把 sniffer 安装到默认网关 ,代理服务器等。因为 MSN 通信原理是所有 IM 消息都要经过 MSN Server 进行中转, MSN Server 一般是外网,所以消息要发出去必须经过网关路由器的转发,所以可以在网关路由器上进行 sniffer

4 、对交换机进行 ARP 欺骗,让交换机混淆 MAC 地址。 ARP 欺骗)

ARP 欺骗

顾名思义 ARP ,地址解析协议,是用来解析地址的,是解析什么地址的呢?其实是将网络层的 IP 地址解析成链路层的 MAC 地址

ARP 协议是“ Address Resolution Protocol ”(地址解析协议)的缩写。在局域网中,网络中实际传输的是“帧”,帧里面是有目标主机的 MAC 地址的(链路层传输:不管你主机到主机如何寻址,如何跳跃多个路由器,到最后总得是一个链路接着一个链路的传输)。在以太网中,一个主机和另一个主机进行直接通信,必须要知道目标主机的 MAC 地址。(链路层通信首先得知道目的地的 MAC 地址,网络层通信首先得知道目的地的 IP 地址。)

但这个目标 MAC 地址是如何获得的呢?它就是通过地址解析协议获得的。所谓“地址解析”就是主机在发送帧前将目标 IP 地址转换成目标 MAC 地址的过程。 ARP 协议的基本功能就是通过目标设备的 IP 地址,查询目标设备(所在下一跳的)的 MAC 地址,以保证通信的顺利进行。

ARP 协议主要负责将局域网中的 32 IP 地址转换为对应的 48 位物理地址 , 即网卡的 MAC 地址 , 比如 IP 地址位 192.168.0.1 网卡 MAC 地址为 00-03-0F-FD-1D-2B. 整个转换过程是一台主机先向目标主机发送包含有 IP 地址和 MAC 地址的数据包 , 通过 MAC 地址两个主机就可以实现数据传输了 .

在每台安装有 TCP/IP 协议的电脑里都有一个 ARP 缓存表(缓存都得有个老化机制),表里的 IP 地址与 MAC 地址是一一对应的,如附表所示。

(如何查找 IP 对应的 MAC 通过广播进行查找。)

附表 A 192.168.1.5 => B 192.168.1.1

我们以主机 A 192.168.1.5 )向主机 B 192.168.1.1 )发送数据为例。当发送数据时,主机 A 会在自己的 ARP 缓存表中寻找是否有目标 IP 地址。如果找到了,也就知道了目标 MAC 地址,直接把目标 MAC 地址写入帧里面发送就可以了;如果在 ARP 缓存表中没有找到相对应的 IP 地址,主机 A

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics