{"id":2033,"date":"2014-04-09T11:13:43","date_gmt":"2014-04-09T10:13:43","guid":{"rendered":"http:\/\/mccltd.net\/blog\/?p=2033"},"modified":"2014-04-09T12:36:45","modified_gmt":"2014-04-09T11:36:45","slug":"tshark-capturing-packets-from-the-windows-command-line","status":"publish","type":"post","link":"http:\/\/darenmatthews.com\/blog\/?p=2033","title":{"rendered":"tshark &#8211; Capturing Packets from the Windows Command Line"},"content":{"rendered":"<p>A quick aide-memoir about how to go about capturing traffic from the Windows command line.\u00a0 You must be in the Wireshark directory (or have the location in your PATH environment settings):<\/p>\n<p><strong>1. Find interface Index:<\/strong><\/p>\n<blockquote><p>C:\\Program Files (x86)\\Wireshark&gt;tshark -D<br \/>\n1. \\Device\\NPF_{B3BA19B1-3083-4FF5-9CA5-09E33CABEC93} (Microsoft)<br \/>\n2. \\Device\\NPF_{E7CE2EDC-D965-44DF-A7F2-A14B4A762B40} (Sun)<br \/>\n3. \\Device\\NPF_{B88703B3-2E09-4FC7-A061-21A94A22BBBE} (Intel(R) 82579LM Gigabit<br \/>\nNetwork Connection)<!--more--><\/p><\/blockquote>\n<p><strong>2. Capture traffic<\/strong>:<\/p>\n<blockquote><p>C:\\Program Files (x86)\\Wireshark&gt;tshark -i 3 -c 10 -w testing.pcap<br \/>\nCapturing on Intel(R) 82579LM Gigabit Network Connection<br \/>\n10<\/p><\/blockquote>\n<p><strong>3. read in the file:<\/strong><\/p>\n<blockquote><p>C:\\Program Files (x86)\\Wireshark&gt;tshark -r testing.pcap<br \/>\n1\u00a0\u00a0 0.000000 fe80::89d1:db93:6fe0:93c4 -&gt; ff02::c\u00a0\u00a0\u00a0\u00a0\u00a0 SSDP\u00a0 208 M-SEARCH * HTTP\/1.1<br \/>\n2\u00a0\u00a0 0.007155 fe80::5177:2132:f23f:323d -&gt; ff02::1:ff2d:47f8 ICMPv6\u00a0 86 Neighbor Solicitation<br \/>\n3\u00a0\u00a0 0.009462 fe80::a57f:a2c0:4175:8a37 -&gt; ff02::c\u00a0\u00a0\u00a0\u00a0\u00a0 SSDP\u00a0 208 M-SEARCH * HTTP\/1.1<br \/>\n4\u00a0\u00a0 0.012513 192.168.200.173 -&gt; 100.23.52.74\u00a0 CFLOW\u00a0 1458 total: 29 (v9) records<br \/>\n5\u00a0\u00a0 0.030965 fe80::8884:585c:94f1:a93 -&gt; ff02::1:ffb2:2b1a ICMPv6\u00a0 86 Neighbor Solicitation<br \/>\n6\u00a0\u00a0 0.054857 100.23.52.188 -&gt; 100.23.255.255 NBNS\u00a0 92 Name query NB NET-MASTER&lt;1b&gt;<br \/>\n7\u00a0\u00a0 0.082469 100.23.15.101 -&gt; 224.0.0.2\u00a0\u00a0\u00a0 HSRP\u00a0 62 Hello (state Active)<br \/>\n8\u00a0\u00a0 0.095470\u00a0 100.23.53.31 -&gt; 100.23.255.255 NBNS\u00a0 92 Name query NB FS03&lt;20&gt;<br \/>\n9\u00a0\u00a0 0.101973 172.23.16.252 -&gt; 224.0.0.2\u00a0\u00a0\u00a0 HSRP\u00a0 62 Hello (state Standby)<br \/>\n10\u00a0\u00a0 0.117974 fe80::3c5b:61f0:4cac:4620 -&gt; ff02::1:ff95:5811 ICMPv6\u00a0 86 Neighbor Solicitation<\/p><\/blockquote>\n<p><strong>3a. Read in the file with a Wireshark Display Filter:<\/strong><\/p>\n<blockquote><p>C:\\Program Files (x86)\\Wireshark&gt;tshark -r testing.pcap -R &#8220;ip.addr eq 224.0.0.2<br \/>\n&#8221;<br \/>\n7\u00a0\u00a0 0.082469 100.23.15.101 -&gt; 224.0.0.2\u00a0\u00a0\u00a0 HSRP\u00a0 62 Hello (state Active)<br \/>\n9\u00a0\u00a0 0.101973 172.23.16.252 -&gt; 224.0.0.2\u00a0\u00a0\u00a0 HSRP\u00a0 62 Hello (state Standby)<\/p><\/blockquote>\n<p><span style=\"text-decoration: underline;\"><strong>COMMAND LINE HELP:<\/strong><\/span><\/p>\n<p>TShark 1.6.8 (SVN Rev 42761 from \/trunk-1.6)<br \/>\nDump and analyze network traffic.<br \/>\nSee http:\/\/www.wireshark.org for more information.<\/p>\n<p>Copyright 1998-2012 Gerald Combs &lt;gerald@wireshark.org&gt; and contributors.<br \/>\nThis is free software; see the source for copying conditions. There is NO<br \/>\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<\/p>\n<p>Usage: tshark [options] &#8230;<\/p>\n<p>Capture interface:<br \/>\n-i &lt;interface&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name or idx of interface (def: first non-loopback)<br \/>\n-f &lt;capture filter&gt;\u00a0\u00a0\u00a0\u00a0\u00a0 packet filter in libpcap filter syntax<br \/>\n-s &lt;snaplen&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 packet snapshot length (def: 65535)<br \/>\n-p\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 don&#8217;t capture in promiscuous mode<br \/>\n-B &lt;buffer size&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 size of kernel buffer (def: 1MB)<br \/>\n-y &lt;link type&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 link layer type (def: first appropriate)<br \/>\n-D\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print list of interfaces and exit<br \/>\n-L\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 print list of link-layer types of iface and exit<\/p>\n<p>Capture stop conditions:<br \/>\n-c &lt;packet count&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 stop after n packets (def: infinite)<br \/>\n-a &lt;autostop cond.&gt; &#8230;\u00a0 duration:NUM &#8211; stop after NUM seconds<br \/>\nfilesize:NUM &#8211; stop this file after NUM KB<br \/>\nfiles:NUM &#8211; stop after NUM files<br \/>\nCapture output:<br \/>\n-b &lt;ringbuffer opt.&gt; &#8230; duration:NUM &#8211; switch to next file after NUM secs<br \/>\nfilesize:NUM &#8211; switch to next file after NUM KB<br \/>\nfiles:NUM &#8211; ringbuffer: replace after NUM files<br \/>\nInput file:<br \/>\n-r &lt;infile&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 set the filename to read from (no pipes or stdin!)<\/p>\n<p>Processing:<br \/>\n-R &lt;read filter&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 packet filter in Wireshark display filter syntax<br \/>\n-n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 disable all name resolutions (def: all enabled)<br \/>\n-N &lt;name resolve flags&gt;\u00a0 enable specific name resolution(s): &#8220;mntC&#8221;<br \/>\n-d &lt;layer_type&gt;==&lt;selector&gt;,&lt;decode_as_protocol&gt; &#8230;<br \/>\n&#8220;Decode As&#8221;, see the man page for details<br \/>\nExample: tcp.port==8888,http<br \/>\n-H &lt;hosts file&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 read a list of entries from a hosts file, which will<br \/>\nthen be written to a capture file. (Implies -W n)<br \/>\nOutput:<br \/>\n-w &lt;outfile|-&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 write packets to a pcap-format file named &#8220;outfile&#8221;<br \/>\n(or to the standard output for &#8220;-&#8220;)<br \/>\n-C &lt;config profile&gt;\u00a0\u00a0\u00a0\u00a0\u00a0 start with specified configuration profile<br \/>\n-F &lt;output file type&gt;\u00a0\u00a0\u00a0 set the output file type, default is libpcap<br \/>\nan empty &#8220;-F&#8221; option will list the file types<br \/>\n-V\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 add output of packet tree\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (Packet Details)<br \/>\n-O &lt;protocols&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Only show packet details of these protocols, comma<br \/>\nseparated<br \/>\n-S\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 display packets even when writing to a file<br \/>\n-x\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 add output of hex and ASCII dump (Packet Bytes)<br \/>\n-T pdml|ps|psml|text|fields<br \/>\nformat of text output (def: text)<br \/>\n-e &lt;field&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 field to print if -Tfields selected (e.g. tcp.port);<br \/>\nthis option can be repeated to print multiple fields<br \/>\n-E&lt;fieldsoption&gt;=&lt;value&gt; set options for output when -Tfields selected:<br \/>\nheader=y|n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 switch headers on and off<br \/>\nseparator=\/t|\/s|&lt;char&gt; select tab, space, printable character as separator<br \/>\noccurrence=f|l|a\u00a0\u00a0\u00a0\u00a0\u00a0 print first, last or all occurrences of each field<br \/>\naggregator=,|\/s|&lt;char&gt; select comma, space, printable character as<br \/>\naggregator<br \/>\nquote=d|s|n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 select double, single, no quotes for values<br \/>\n-t ad|a|r|d|dd|e\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 output format of time stamps (def: r: rel. to first)<br \/>\n-u s|hms\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 output format of seconds (def: s: seconds)<br \/>\n-l\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 flush standard output after each packet<br \/>\n-q\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 be more quiet on stdout (e.g. when using statistics)<br \/>\n-W n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Save extra information in the file, if supported.<br \/>\nn = write network address resolution information<br \/>\n-X &lt;key&gt;:&lt;value&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 eXtension options, see the man page for details<br \/>\n-z &lt;statistics&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 various statistics, see the man page for details<\/p>\n<p>Miscellaneous:<br \/>\n-h\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 display this help and exit<br \/>\n-v\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 display version info and exit<br \/>\n-o &lt;name&gt;:&lt;value&gt; &#8230;\u00a0\u00a0\u00a0 override preference setting<br \/>\n-K &lt;keytab&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 keytab file to use for kerberos decryption<br \/>\n-G [report]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 dump one of several available reports and exit<br \/>\ndefault report=&#8221;fields&#8221;<br \/>\nuse &#8220;-G ?&#8221; for more help<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A quick aide-memoir about how to go about capturing traffic from the Windows command line.\u00a0 You must be in the Wireshark directory (or have the location in your PATH environment settings): 1. Find interface Index: C:\\Program Files (x86)\\Wireshark&gt;tshark -D 1. \\Device\\NPF_{B3BA19B1-3083-4FF5-9CA5-09E33CABEC93} (Microsoft) 2. \\Device\\NPF_{E7CE2EDC-D965-44DF-A7F2-A14B4A762B40} (Sun) 3. \\Device\\NPF_{B88703B3-2E09-4FC7-A061-21A94A22BBBE} (Intel(R) 82579LM Gigabit Network Connection)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[53],"tags":[37],"_links":{"self":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2033"}],"collection":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2033"}],"version-history":[{"count":2,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2033\/revisions"}],"predecessor-version":[{"id":2035,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2033\/revisions\/2035"}],"wp:attachment":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2033"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}