<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tcpdump &#8211; My Tech Blog</title>
	<atom:link href="https://elbrav.ru/en/archives/tag/tcpdump-en/feed" rel="self" type="application/rss+xml" />
	<link>https://elbrav.ru</link>
	<description>Разная полезная информация</description>
	<lastBuildDate>Thu, 26 Jan 2023 08:46:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.2</generator>

<image>
	<url>https://elbrav.ru/wp-content/uploads/2023/01/cropped-logo-color-1-1-32x32.png</url>
	<title>tcpdump &#8211; My Tech Blog</title>
	<link>https://elbrav.ru</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>About Tcpdump</title>
		<link>https://elbrav.ru/en/archives/177</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 25 Jan 2023 10:48:36 +0000</pubDate>
				<category><![CDATA[Traffic Analysis]]></category>
		<category><![CDATA[tcpdump]]></category>
		<category><![CDATA[traffic analysis]]></category>
		<guid isPermaLink="false">https://elbrav.tech/?p=177</guid>

					<description><![CDATA[Tcpdump is a utility for capturing and traffic analysis. It is recommended to be used for network diagnostics. With this tool you can see packet [...]]]></description>
										<content:encoded><![CDATA[
<p id="tcpdhead"></p>


<nav style="background-color: #e0d2ec;" class="has-background is-responsive  is-vertical wp-block-navigation is-layout-flex wp-container-core-navigation-layout-1 wp-block-navigation-is-layout-flex" aria-label="tcpd_en" 
			data-wp-interactive
			data-wp-context='{"core":{"navigation":{"overlayOpenedBy":[],"type":"overlay","roleAttribute":"","ariaLabel":"Menu"}}}'
		><button aria-haspopup="true" aria-label="Open menu" class="wp-block-navigation__responsive-container-open " 
			data-wp-on--click="actions.core.navigation.openMenuOnClick"
			data-wp-on--keydown="actions.core.navigation.handleMenuKeydown"
		><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
			<div class="wp-block-navigation__responsive-container  " style="" id="modal-1" 
			data-wp-class--has-modal-open="selectors.core.navigation.isMenuOpen"
			data-wp-class--is-menu-open="selectors.core.navigation.isMenuOpen"
			data-wp-effect="effects.core.navigation.initMenu"
			data-wp-on--keydown="actions.core.navigation.handleMenuKeydown"
			data-wp-on--focusout="actions.core.navigation.handleMenuFocusout"
			tabindex="-1"
		>
				<div class="wp-block-navigation__responsive-close" tabindex="-1">
					<div class="wp-block-navigation__responsive-dialog" 
			data-wp-bind--aria-modal="selectors.core.navigation.ariaModal"
			data-wp-bind--aria-label="selectors.core.navigation.ariaLabel"
			data-wp-bind--role="selectors.core.navigation.roleAttribute"
			data-wp-effect="effects.core.navigation.focusFirstElement"
		>
							<button aria-label="Close menu" class="wp-block-navigation__responsive-container-close" 
			data-wp-on--click="actions.core.navigation.closeMenuOnClick"
		><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
						<div class="wp-block-navigation__responsive-container-content" id="modal-1-content">
							<ul style="background-color: #e0d2ec;" class="wp-block-navigation__container has-background is-responsive  is-vertical wp-block-navigation"><li class=" wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content"  href="#tcpdinfo"><span class="wp-block-navigation-item__label"><strong>Output Information</strong></span></a></li><li class=" wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content"  href="#tcpdflag"><span class="wp-block-navigation-item__label"><strong>TCP Flags</strong></span></a></li><li class=" wp-block-navigation-item wp-block-navigation-link"><a class="wp-block-navigation-item__content"  href="#tcpdopt"><span class="wp-block-navigation-item__label"><strong>Command Options</strong></span></a></li></ul>
						</div>
					</div>
				</div>
			</div></nav>


<p>Tcpdump is a utility for capturing and traffic analysis. It is recommended to be used for network diagnostics. With this tool you can see packet traffic and sockets of each packet.</p>



<p><a href="https://www.tcpdump.org/">https://www.tcpdump.org/</a> &#8211; official utility resource.</p>



<p>It output of tcpdump each line is a single captured packet.</p>



<p>Example of tcpdump output:</p>



<p>12:54:21.590381 IP 10.20.3.215 &gt; 10.100.1.50: ICMP echo request, id 27945, seq 1, length 64</p>



<p id="tcpdinfo"></p>



<p class="has-text-align-center"><strong>What information can be seen in the output of the command:</strong></p>



<ul>
<li>Timestamp</li>



<li>Protocol</li>



<li>Source IP address or name</li>



<li>Source Port</li>



<li>Destination IP address or name</li>



<li>Destination Port</li>



<li>Flags</li>



<li>Packet Sequence Number</li>



<li>Acknowledgement</li>



<li>Window size</li>



<li>Payload</li>
</ul>



<p>To stop utility &#8211; press Crtl+C</p>



<p><a href="#tcpdhead">Up!</a></p>



<p id="tcpdflag"></p>



<p class="has-text-align-center"><strong>TCP Flags</strong></p>



<p>There could be more than one flag in single packet.</p>



<ul>
<li>S – SYN</li>



<li>F – FIN</li>



<li>. – ACK</li>



<li>P – PUSH </li>



<li>R – RST</li>
</ul>



<p>For Example:</p>



<p>tcpdump&nbsp;&#8216;tcp[tcpflags]&nbsp;== tcp-rst&#8217;</p>



<p>Utility Tcpdump can be launced with root righs or your account must be container in sudoers file.</p>



<p><a href="#tcpdhead">Up!</a></p>



<p id="tcpdopt"></p>



<p class="has-text-align-center"><strong>Tcpdump Options</strong></p>



<p><em>tcpdump -D</em> &#8211; output of all interfaces, that could be used for capture.</p>



<p><em>tcpdump –list-interfaces</em> &#8211; the same</p>



<p>For output filtering use language BPF</p>



<p><em>sudo tcpdump port 53</em>    Here &#8220;port 53&#8221; is BPF Filter.</p>



<p>Another BPF Filters:</p>



<ul>
<li>port</li>



<li>portrange</li>



<li>net</li>



<li>mask</li>



<li>host</li>



<li>src</li>



<li>dst</li>



<li>tcp</li>



<li>udp</li>



<li>icmp</li>



<li>greater</li>



<li>ip6</li>



<li>less</li>



<li>&lt;=</li>
</ul>



<p>For combining filters you can use boolean operators:</p>



<ul>
<li>and</li>



<li>or</li>



<li>not</li>
</ul>



<p>Example:</p>



<p><em>tcpdump -A greater 1000 and \(src host amazon.com or src host tcpdump.com\)</em></p>



<p>Brackets are used here becuase we want packets greate 1000 byte for tcpdump.com also. </p>



<p>&#8220;\&#8221; &#8211; is used because brackets in shell have specific meaning</p>



<p><em>tcpdump -A greater 1000 and \(src host amazon.com or tcpdump.com\)</em>  &#8211; also correct. We exclude repeated operator.</p>



<p><em>tcpdump `greater 1000 and (src host amazon.com or tcpdump.com)`</em> &#8211; also correct.</p>



<p>If you want to use tcpdump output for analyzing through wireshark, save file in format .pcap</p>



<p><em>tcpdump -w</em>  &#8211; to save otput into file.</p>



<p><em>ssh &lt;remote.ip&gt; tcpdump -pni any -w &#8211; -s0 -U port dest_port | wireshark -k -i –</em> to translate tcpdump output into wireshark</p>



<p><em>sudo tcpdump host host_ip -w filename -c 10000</em>  &#8212; save output to file only 10000 packets.</p>



<p>-i – for interface fitering it is recommended to point interface or to use  -i any, because default interface can be wrong.</p>



<p>-A – full packet ottput in ASCII format (-X – for output in HEX). -x – Hex output of first 82 byte of packet. For ethernet-header output use -xx (add 14 byte).</p>



<p>-n – to deny IP-to-name translation. By default IP are translated into names.</p>



<p>This translation can become a problem when there is a huge flow of packets or when there is a problem with DNS Server. </p>



<p>-e &#8211; L2 information in output. For example MAC addresses. </p>



<p>-P &#8211; for certain IP address shows only packets with source IP or Destination IP equal to target IP</p>



<p> Flags -v, -vv, -vvv &#8211; define the verbosity of information.</p>



<p>-t &#8211; no timestamp in output</p>



<p>-tt &#8211; Show the time in format: the amount of seconds passed from 1.01.1970</p>



<p>-ttt &#8211; shows the time as delta between current string and the previous</p>



<p>-tttt &#8211; real time format</p>



<p>-r &#8211; to read dump file</p>



<p>-s  &#8211; size of captured packet. By default, when dump is saved there are only firts 68 byte of data, add -s 0 &#8211; to save the whole packet.</p>



<p>Examples:</p>



<p><em>tcpdump src net 10.208.148.0 mask 255.255.255.0</em></p>



<p><em>tcpdump src net 10.208.148.0/24</em></p>



<p><em>tcpdump -ni eth1 greater 1000</em></p>



<p><a href="#tcpdhead">Up!</a></p>



<p>Used sources:</p>



<p><a href="https://wizardzines.com/zines/tcpdump/">Let&#8217;s learn tcpdump!</a>&nbsp;by Julia Evans.</p>



<p><a href="https://habr.com/ru/company/alexhost/blog/531170/">https://habr.com/ru/company/alexhost/blog/531170/</a></p>



<p><a href="http://www.alexonlinux.com/tcpdump-for-dummies">http://www.alexonlinux.com/tcpdump-for-dummies</a></p>



<p><a href="https://danielmiessler.com/study/tcpdump/">https://danielmiessler.com/study/tcpdump/</a></p>



<p><a href="https://packetlife.net/media/library/12/tcpdump.pdf">https://packetlife.net/media/library/12/tcpdump.pdf</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
