<?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; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/tcpdump/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Fri, 02 Dec 2022 07:59:12 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Wireshark Debug 遠端的機器</title>
		<link>https://richliu.com/2014/12/18/1715/wireshark-debug-%e9%81%a0%e7%ab%af%e7%9a%84%e6%a9%9f%e5%99%a8/</link>
					<comments>https://richliu.com/2014/12/18/1715/wireshark-debug-%e9%81%a0%e7%ab%af%e7%9a%84%e6%a9%9f%e5%99%a8/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 18 Dec 2014 12:40:17 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[nc]]></category>
		<category><![CDATA[tcpdump]]></category>
		<category><![CDATA[wireshark]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1715</guid>

					<description><![CDATA[<p>這個是最近從客戶那邊看到的, 回來之後覺得很有趣, 應該要學起來, 以後 debug 比較方便. 一般要 mi [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2014/12/18/1715/wireshark-debug-%e9%81%a0%e7%ab%af%e7%9a%84%e6%a9%9f%e5%99%a8/">Wireshark Debug 遠端的機器</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>這個是最近從客戶那邊看到的, 回來之後覺得很有趣, 應該要學起來, 以後 debug 比較方便.</p>



<p>一般要 mirror 遠端機器上的流量會使用具有 port mirror 的 switch, 這樣就可以得到完整的封包了, 但是如果沒有 port mirror 的機器怎麼辦呢? 這時候就只好用其他方式, 像是 ssh or nc</p>



<span id="more-1715"></span>



<p>這邊就不講 ssh 了, 很多 embedded system 是沒有 ssh 的.</p>



<p>這個方式不適用於 Windows 版的 Wireshark, 但是理論上 Windows 版的 Wireshrak 應該可以配合 Winpcap 做到同樣的事情. 以下講的是 Linux 版的</p>



<p>首先, 在 wireshark 的機器上先執行 nc , nc 沒有辦法直接輸出到 fifo 的檔案上, 所以要接個 tee 指令</p>



<pre class="wp-block-preformatted">mkfifo /tmp/temp.pcap
nc -k -l -p 9999| tee > /tmp/temp.pcap</pre>



<p>然後在 target 機器上執行</p>



<pre class="wp-block-preformatted">tcpdump -s 0 -U -n -w - -i eth0 not host 10.1.1.1 | nc 10.1.1.1 9999</pre>



<p>再回來 wireshark 的機器上執行</p>



<pre class="wp-block-preformatted">cat /tmp/temp.pcap | wireshark -k -i -</pre>



<pre class="wp-block-preformatted">這樣應該就可以順利的執行了. BUT, 人生最機車的就是還有這個 BUT.</pre>



<p>我有一組機器 Wireshark 跑在 ubuntu 12.04 上沒有辦法照上面那些指令執行, 猜想可能是 wireshark 版本的問題, 這時候請改用以下命令</p>



<p>首先, 在 wireshark 的機器上先執行 nc</p>



<pre class="wp-block-preformatted">mkfifo /tmp/temp.pcap
nc -k -l -p 9999| tee > /tmp/temp.pcap</pre>



<p>然後在 target 機器上執行</p>



<pre class="wp-block-preformatted">dumpcap -P -w - -i eth0 -f 'not host 10.1.1.1' | nc 10.1.1.1 9999</pre>



<p>再回來 wireshark 的機器上執行</p>



<pre class="wp-block-preformatted">wireshark -k -i /tmp/temp.pcap</pre>



<p>這樣, 祝各位順利.</p>



<p>如果沒有 dumpcap 可以改用 tcpdump<br />在有 GUI 的機器執行</p>



<pre class="wp-block-preformatted"><br />wireshark -k -i /tmp/temp.pcap</pre>



<p>在 Target Board 上執行</p>



<pre class="wp-block-preformatted"><br />ssh root@192.168.110.2 "tcpdump -s 0 -U -n -w - -i eth0 not port 22" > /tmp/temp.pcap;</pre>



<p></p>



<p>這樣也可以</p>



<p>ref:<br /><a href="http://d0pefishsec.blogspot.tw/2010/04/monitoring-remote-traffic-with-tcpdump.html" target="_blank" rel="noopener">Monitoring remote traffic with tcpdump and netcat </a><br /><a href="http://wiki.wireshark.org/CaptureSetup/Pipes" target="_blank" rel="noopener">Pipes</a> (ssh 可以參考這一篇)<br /><a href="https://bytefreaks.net/applications/how-to-process-tcpdump-live-data-stream-from-a-remote-machine-on-a-local-wireshark" target="_blank" rel="noopener">How to process tcpdump live data stream from a remote machine on a local WireShark</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2014/12/18/1715/wireshark-debug-%e9%81%a0%e7%ab%af%e7%9a%84%e6%a9%9f%e5%99%a8/">Wireshark Debug 遠端的機器</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2014/12/18/1715/wireshark-debug-%e9%81%a0%e7%ab%af%e7%9a%84%e6%a9%9f%e5%99%a8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
