{"id":201,"date":"2011-01-11T08:40:14","date_gmt":"2011-01-11T07:40:14","guid":{"rendered":"https:\/\/thebc.ch\/blog\/?p=201"},"modified":"2013-02-01T13:18:26","modified_gmt":"2013-02-01T12:18:26","slug":"remote-sniffing-with-whireshark-and-netcat","status":"publish","type":"post","link":"https:\/\/thebc.ch\/blog\/?p=201","title":{"rendered":"Remote sniffing with whireshark and netcat"},"content":{"rendered":"<p><div class='toc toc'>\n<h2>Contents<\/h2>\n<ul class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#The_problem\">The problem<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#The_tools\">The tools<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#The_solution\">The solution<\/a>\n\t\t<ul class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Start_the_netcat_listener\">Start the netcat listener<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Start_wireshark\">Start wireshark<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Start_the_sniffing_on_the_sniffer_host\">Start the sniffing on the sniffer host<\/a>\n\t\t\t<\/li>\n\t\t<\/ul>\n\t<li>\n\t\t<a href=\"#Todo\">Todo<\/a>\n\t<\/li>\n<\/ul>\n<\/ul>\n<\/div>\n<div class='toc-end'>&nbsp;<\/div><br \/>\n<a id=\"The_problem\" name=\"The_problem\"><\/a><\/p>\n<span id=\"The_problem\"><h2>The problem<\/h2><\/span>\n<p>You like to sniff your firewall. The problem is that the firewall is  (of course) a headless linux box without a gui. After half of an hour  you&#8217;ll get headache from starring at the characters fly bye the screen  and you really wish you could look at the beauty of whireshark. This  document is going to tell you how this dream could get reality\u00c2\u00a0\ud83d\ude42<\/p>\n<p>Below is the basic setup:<\/p>\n<p><a href=\"https:\/\/thebc.ch\/blog\/201\/remote-sniffing-with-whireshark-and-netcat\/remote-sniffing-thetereal-nc\/\" rel=\"attachment wp-att-399\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/thebc.ch\/upload\/2011\/01\/Remote-sniffing-thetereal-nc.png\" alt=\"\" title=\"Remote-sniffing-thetereal-nc\" width=\"334\" height=\"341\" class=\"alignleft size-full wp-image-399\" srcset=\"https:\/\/thebc.ch\/upload\/2011\/01\/Remote-sniffing-thetereal-nc.png 334w, https:\/\/thebc.ch\/upload\/2011\/01\/Remote-sniffing-thetereal-nc-293x300.png 293w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><\/a><\/p>\n<p><a id=\"The_tools\" name=\"The_tools\"><\/a><\/p>\n<span id=\"The_tools\"><h2>The tools<\/h2><\/span>\n<ul>\n<li> To transport the data from our sniffing box we will use the &#8220;<a title=\"http:\/\/en.wikipedia.org\/wiki\/Netcat\" rel=\"nofollow\" href=\"http:\/\/en.wikipedia.org\/wiki\/Netcat\">TCP\/IP Swiss Army Knife<\/a>&#8221; netcat. You can get it from <a title=\"http:\/\/netcat.sourceforge.net\/\" rel=\"nofollow\" href=\"http:\/\/netcat.sourceforge.net\/\">here<\/a> but it is installed with most *ux distributions.<\/li>\n<\/ul>\n<ul>\n<li> And of course <a title=\"http:\/\/www.wireshark.org\" rel=\"nofollow\" href=\"http:\/\/www.wireshark.org\/\">wireshark<\/a> (formerly ethereal).<\/li>\n<\/ul>\n<p><a id=\"The_solution\" name=\"The_solution\"><\/a><\/p>\n<span id=\"The_solution\"><h2>The solution<\/h2><\/span>\n<p><a id=\"Start_the_netcat_listener\" name=\"Start_the_netcat_listener\"><\/a><\/p>\n<span id=\"Start_the_netcat_listener\"><h3>Start the netcat listener<\/h3><\/span>\n<p>First you have to start a netcat listener on the viewer host.<\/p>\n<p>On linux you have to use the while-loop (hard-listening) because  otherways the listener will die if the connection gets interupted. The  WIN32 version has the -L flag to archive this.<\/p>\n<p>One other thing is that with the GUI version of ethereal you have  to use a little trick, since it does not seem to read from stdin; but  it can read from pipes. So you have to create a FIFO pipe first where  the netcat listener can write to:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co0\">### viewer ###<\/span><br \/>\n<span class=\"kw2\">mkfifo<\/span> ~<span class=\"sy0\">\/<\/span>mypipe<br \/>\n<span class=\"kw1\">while<\/span> <span class=\"br0\">&#40;<\/span><span class=\"kw2\">true<\/span><span class=\"br0\">&#41;<\/span>; <span class=\"kw1\">do<\/span> nc <span class=\"re5\">-l<\/span> 192.168.24.254 <span class=\"nu0\">4711<\/span> <span class=\"sy0\">&gt;&gt;<\/span> ~<span class=\"sy0\">\/<\/span>mypipe; <span class=\"kw1\">done<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><a id=\"Start_wireshark\" name=\"Start_wireshark\"><\/a><\/p>\n<span id=\"Start_wireshark\"><h3>Start wireshark<\/h3><\/span>\n<p>Then we have to start wireshark. Then go to Capture-&gt;Options and  write the name of your FIFO-pipe into the &#8220;Interface&#8221; field. Don&#8217;t  select &#8220;Capture packets in promiscuous mode&#8221; since we define these  things on the sniffer host!<\/p>\n<p><a id=\"Start_the_sniffing_on_the_sniffer_host\" name=\"Start_the_sniffing_on_the_sniffer_host\"><\/a><\/p>\n<span id=\"Start_the_sniffing_on_the_sniffer_host\"><h3>Start the sniffing on the sniffer host<\/h3><\/span>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co0\">### sniffer ### <\/span><br \/>\ntethereal <span class=\"re5\">-l<\/span> <span class=\"re5\">-F<\/span> libpcap <span class=\"re5\">-w<\/span> - not port <span class=\"nu0\">4711<\/span> and not port <span class=\"nu0\">22<\/span> <span class=\"sy0\">|<\/span> nc &nbsp;192.168.24.254 <span class=\"nu0\">4711<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Happy sniffing!!!<\/p>\n<p><a id=\"Todo\" name=\"Todo\"><\/a><\/p>\n<span id=\"Todo\"><h2>Todo<\/h2><\/span>\n<ul>\n<li> Try the netcat in UDP-mode. Wireshark crashes after a view packages with the UDP mode. Don&#8217;t know the reason nor the solution<\/li>\n<li> Encrypt the sniffed traffic. This should be easy with <a title=\"http:\/\/farm9.org\/Cryptcat\/\" rel=\"nofollow\" href=\"http:\/\/farm9.org\/Cryptcat\/\">cryptcat<\/a>.<\/li>\n<li> Find a more stable solution. Sometime it doesn&#8217;t really work. It doesn&#8217;t work if the steps get out of the right order.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The problem You like to sniff your firewall. The problem is that the firewall is (of course) a headless linux box without a gui. After half of an hour you&#8217;ll get headache from starring at the characters fly bye the &hellip; <a href=\"https:\/\/thebc.ch\/blog\/?p=201\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-security"],"_links":{"self":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":38,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":2736,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions\/2736"}],"wp:attachment":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}