<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>packet capture tools on Digi Hunch</title><link>https://static.digihunch.com/tag/packet-capture-tools/</link><description>Recent content in packet capture tools on Digi Hunch</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Sat, 20 Jul 2024 22:28:27 -0400</lastBuildDate><atom:link href="https://static.digihunch.com/tag/packet-capture-tools/index.xml" rel="self" type="application/rss+xml"/><item><title>TCPdump and Wireshark configuration</title><link>https://static.digihunch.com/2018/02/tcpdump-and-wireshark/</link><pubDate>Wed, 28 Feb 2018 18:30:06 -0400</pubDate><guid>https://static.digihunch.com/2018/02/tcpdump-and-wireshark/</guid><description>&lt;p class="wp-block-paragraph"&gt;This article explains how to troubleshoot TCP packet from Linux (CentOS) and Windows with TCP dump and wireshark. Both are important tools for troubleshooting. If you are troubleshooting a Windows server and have access to it to install Wireshark then there is nothing to worry about. Even if the server to troubleshoot is a Linux one with proper desktop (KDE/GNOME), you may still install the Wireshark UI on it and work from the server. If the server is Linux without any UI, this is where this article is trying to help because you need to run tcpdump on the server and somehow download the capture to your local computer for analysis.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;If you work off of a MacOS, and need to capture in real time from a Linux server without a desktop (KDE/GNOME), then the best bet is to run tcpdump remotely from the server and pipe the result into Wireshark. This would require root access to the server. Tcpdump will require libpcap and tcpdump packages. Then from MacBook you can run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ssh root@remote-server &amp;#34;tcpdump -w - -s0 -pi eth0 dst port 443 or src port 443&amp;#34;|wireshark -k -i -&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;This will pipe the tcpdump result into Wireshark session in Mac in real time with a delay.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;If you work off a Windows computer where plink.exe is available, you can run the following command if you know the root password:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;C:&lt;span style="color:#ae81ff"&gt;\t&lt;/span&gt;ools&lt;span style="color:#ae81ff"&gt;\p&lt;/span&gt;link.exe -l root -pw rootpassword 192.168.117.12 -P &lt;span style="color:#ae81ff"&gt;22&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;tcpdump -w - -s0 -pi eth0 dst port 9042&amp;#34;&lt;/span&gt; |&lt;span style="color:#e6db74"&gt;&amp;#34;C:\Program Files\Wireshark\Wireshark.exe&amp;#34;&lt;/span&gt; -k -i -&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;Both tricks above assumes that you have direct root log-in to the server, by RSA key or password. It is because running tcpdump requires root access on the server. It is not a good security practice to run tcpdump with a non-root user because it needs to scan the interface.&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&lt;li&gt;-s: snap length in bytes. Setting to 0 is making it use default 65535&lt;/li&gt;&lt;li&gt;-i: specify the interface to listen on. e.g. eth0 or ens192&lt;/li&gt;&lt;li&gt;-p: no-promiscuous mode. this option asks tcpdump to not put interface in promiscuous mode&lt;/li&gt;&lt;li&gt;-w: write the raw packets to file rather than parsing and printing them out. a hyphen indicates standard output here.&lt;/li&gt;&lt;li&gt;-Z: drops the privileges of root and changes ownership to the specified user&lt;/li&gt;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;If you do not have direct root login access, but you can log in as a different user and su to root, you may run this once you are on root user:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &amp;#34;###Capture Begin: $(date &amp;#39;+%Y %b %d %H:%M:%S&amp;#39;)&amp;#34; &amp;amp;&amp;amp; tcpdump dst port 1524 or src port 1524 -s 0 -i eth0 -w &amp;#34;/tmp/cap.$(date +%Y%m%d_%H%M%S).cap&amp;#34; -Z linuser &amp;amp;&amp;amp; echo &amp;#34;###Capture End: $(date &amp;#39;+%Y %b %d %H:%M:%S&amp;#39;)&amp;#34; &amp;amp;&amp;amp; ls -ltr /tmp/cap*.cap&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;To stop capture, you can use Ctrl-C but make sure that is passed to the server terminal or you will leave a zombie tcpdump process&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://static.digihunch.com/2018/02/linux-tips-and-tricks-in-shell/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Linux Admin Basics 1 of 3 – Bash&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://static.digihunch.com/2018/03/bash-tricks-continued/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Linux Admin Basics 2 of 3 – shell scripting&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item></channel></rss>