<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: How to code a Packet Sniffer in C with Linux Sockets &#8211; Part 2	</title>
	<atom:link href="https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/</link>
	<description>News, Technology, Entertainment and more</description>
	<lastBuildDate>Thu, 09 Nov 2023 07:28:06 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>
		By: Rick		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-362518</link>

		<dc:creator><![CDATA[Rick]]></dc:creator>
		<pubDate>Thu, 09 Nov 2023 07:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-362518</guid>

					<description><![CDATA[Hi... Thank you for the Excellent Tutorials and practical program examples.
I was trying to sniff only ARP/RARP and DHCP (or if needed BootP) packets on my network, because it is a mix of DHCP and static IP configurations. I was wondering what would be the values in the third option of the socket(...,...,???) function?
Help would be greatly appreciated.
Thanks..]]></description>
			<content:encoded><![CDATA[<p>Hi&#8230; Thank you for the Excellent Tutorials and practical program examples.<br />
I was trying to sniff only ARP/RARP and DHCP (or if needed BootP) packets on my network, because it is a mix of DHCP and static IP configurations. I was wondering what would be the values in the third option of the socket(&#8230;,&#8230;,???) function?<br />
Help would be greatly appreciated.<br />
Thanks..</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: agha		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-312067</link>

		<dc:creator><![CDATA[agha]]></dc:creator>
		<pubDate>Tue, 26 Jan 2021 07:00:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-312067</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-56994&quot;&gt;Silver Moon&lt;/a&gt;.

how can we check the HTTP packet type (GET and POST) of application layer]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-56994">Silver Moon</a>.</p>
<p>how can we check the HTTP packet type (GET and POST) of application layer</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alisson Oliveira Chaves		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-285892</link>

		<dc:creator><![CDATA[Alisson Oliveira Chaves]]></dc:creator>
		<pubDate>Sun, 11 Oct 2020 18:53:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-285892</guid>

					<description><![CDATA[&quot;1. Sniff both incoming and outgoing traffic.&quot;

Outgoing is only in ETH_P_ALL option? or can i set custom protocol and filter outgoing traffic ?]]></description>
			<content:encoded><![CDATA[<p>&#8220;1. Sniff both incoming and outgoing traffic.&#8221;</p>
<p>Outgoing is only in ETH_P_ALL option? or can i set custom protocol and filter outgoing traffic ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Riku		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-281502</link>

		<dc:creator><![CDATA[Riku]]></dc:creator>
		<pubDate>Wed, 23 Sep 2020 15:12:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-281502</guid>

					<description><![CDATA[Hey there !
First up: Thank you mate, you helped me alot.
But I got one question: Are you sure: 

sock_raw = socket( AF_PACKET , SOCK_RAW , htons(ETH_P_IP&#124;ETH_P_ARP)) ;

works this way ? I Tried to filter IPV4 (0x8000) and a fieldbus protocol (0x8892) but I cant seem to make it work. For some reason it only detects the fieldbus protocol. I tested each protocol seperatly and it works fine. My line of code looks like this:

sock_raw = socket( AF_PACKET , SOCK_RAW , htons(0x8000&#124;0x8892)) ;

Maybe you got an idea.]]></description>
			<content:encoded><![CDATA[<p>Hey there !<br />
First up: Thank you mate, you helped me alot.<br />
But I got one question: Are you sure: </p>
<p>sock_raw = socket( AF_PACKET , SOCK_RAW , htons(ETH_P_IP|ETH_P_ARP)) ;</p>
<p>works this way ? I Tried to filter IPV4 (0x8000) and a fieldbus protocol (0x8892) but I cant seem to make it work. For some reason it only detects the fieldbus protocol. I tested each protocol seperatly and it works fine. My line of code looks like this:</p>
<p>sock_raw = socket( AF_PACKET , SOCK_RAW , htons(0x8000|0x8892)) ;</p>
<p>Maybe you got an idea.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Silver Moon		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-268903</link>

		<dc:creator><![CDATA[Silver Moon]]></dc:creator>
		<pubDate>Thu, 30 Jul 2020 04:59:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-268903</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-267007&quot;&gt;aw&lt;/a&gt;.

thanks for the comment.
glad that you liked the post.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-267007">aw</a>.</p>
<p>thanks for the comment.<br />
glad that you liked the post.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: aw		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-267007</link>

		<dc:creator><![CDATA[aw]]></dc:creator>
		<pubDate>Tue, 21 Jul 2020 21:46:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-267007</guid>

					<description><![CDATA[you deserve a medal for this! Thank you!]]></description>
			<content:encoded><![CDATA[<p>you deserve a medal for this! Thank you!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: novice		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-152825</link>

		<dc:creator><![CDATA[novice]]></dc:creator>
		<pubDate>Fri, 26 Jan 2018 18:15:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-152825</guid>

					<description><![CDATA[Hi

I am struggling to use source code (part 2). Unfortunately I don&#039;t have experience how to use source code, so what I did was copied the code into a file using 
vi capture-
then saved the file and issued
 chmod u+x capture-

[root@server ~]# ./capture-
./capture-code: line 21: syntax error near unexpected token `(&#039;
./capture-code: line 21: `void ProcessPacket(unsigned char* , int);&#039;


Please advise how to get this working. More over can I save the captured data in a format to be opened with Wireshark  ?

Thanks]]></description>
			<content:encoded><![CDATA[<p>Hi</p>
<p>I am struggling to use source code (part 2). Unfortunately I don&#8217;t have experience how to use source code, so what I did was copied the code into a file using<br />
vi capture-<br />
then saved the file and issued<br />
 chmod u+x capture-</p>
<p>[root@server ~]# ./capture-<br />
./capture-code: line 21: syntax error near unexpected token `(&#8216;<br />
./capture-code: line 21: `void ProcessPacket(unsigned char* , int);&#8217;</p>
<p>Please advise how to get this working. More over can I save the captured data in a format to be opened with Wireshark  ?</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: crob		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-135982</link>

		<dc:creator><![CDATA[crob]]></dc:creator>
		<pubDate>Thu, 19 Oct 2017 02:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-135982</guid>

					<description><![CDATA[good example, learned!
i come here as libpcap drop udp packet, after some google, they tell me the pcap_setuserbuf not implement for linux, so I have to use raw sock, you showed a good sample code.
thank you.
my website is www.crobsoft.com]]></description>
			<content:encoded><![CDATA[<p>good example, learned!<br />
i come here as libpcap drop udp packet, after some google, they tell me the pcap_setuserbuf not implement for linux, so I have to use raw sock, you showed a good sample code.<br />
thank you.<br />
my website is <a href="http://www.crobsoft.com" rel="nofollow ugc">http://www.crobsoft.com</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: nouman		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-108435</link>

		<dc:creator><![CDATA[nouman]]></dc:creator>
		<pubDate>Sat, 04 Mar 2017 12:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-108435</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-30851&quot;&gt;Binary Tides&lt;/a&gt;.

socket error : operation failed]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-30851">Binary Tides</a>.</p>
<p>socket error : operation failed</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: fleur		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-107546</link>

		<dc:creator><![CDATA[fleur]]></dc:creator>
		<pubDate>Tue, 28 Feb 2017 23:12:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-107546</guid>

					<description><![CDATA[can someone please explain me more details about this code]]></description>
			<content:encoded><![CDATA[<p>can someone please explain me more details about this code</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ricky		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-105753</link>

		<dc:creator><![CDATA[ricky]]></dc:creator>
		<pubDate>Tue, 14 Feb 2017 15:43:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-105753</guid>

					<description><![CDATA[Hi, I think the hyperlink &quot;previous part&quot; is not working! I wanted to write a C/C++ program that make use of divert sockets (FreeBSD) which will block all incoming icmp packets. Any clue on how to do that ? Thanks in advance.]]></description>
			<content:encoded><![CDATA[<p>Hi, I think the hyperlink &#8220;previous part&#8221; is not working! I wanted to write a C/C++ program that make use of divert sockets (FreeBSD) which will block all incoming icmp packets. Any clue on how to do that ? Thanks in advance.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Narendra		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-100249</link>

		<dc:creator><![CDATA[Narendra]]></dc:creator>
		<pubDate>Wed, 14 Dec 2016 11:41:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-100249</guid>

					<description><![CDATA[Hi,

I want to capture a random tcp packet.
The program has to run as an ordinary user.
Any idea, how this can be done?
If it is not possible to capture tcp packet, is it possible to capture a http packet or any other protocol packet?
Please suggest.

Thanks,
Narendra]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>I want to capture a random tcp packet.<br />
The program has to run as an ordinary user.<br />
Any idea, how this can be done?<br />
If it is not possible to capture tcp packet, is it possible to capture a http packet or any other protocol packet?<br />
Please suggest.</p>
<p>Thanks,<br />
Narendra</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jason Chien		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-99054</link>

		<dc:creator><![CDATA[Jason Chien]]></dc:creator>
		<pubDate>Fri, 25 Nov 2016 08:50:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-99054</guid>

					<description><![CDATA[this code works on my centos 6.8 i386, but I also did some fixes.

if you just copy &#038; paste on your platform, it may show compile error.
you have to refer to your include files to fix those issues.
there are a lot of different in the struct.]]></description>
			<content:encoded><![CDATA[<p>this code works on my centos 6.8 i386, but I also did some fixes.</p>
<p>if you just copy &amp; paste on your platform, it may show compile error.<br />
you have to refer to your include files to fix those issues.<br />
there are a lot of different in the struct.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Nick		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-92130</link>

		<dc:creator><![CDATA[Nick]]></dc:creator>
		<pubDate>Tue, 23 Aug 2016 22:34:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-92130</guid>

					<description><![CDATA[Will this work on other distributions? I&#039;m about to install kali and I use this as a guide for my project so that information will be helpful to me a lot]]></description>
			<content:encoded><![CDATA[<p>Will this work on other distributions? I&#8217;m about to install kali and I use this as a guide for my project so that information will be helpful to me a lot</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sania		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-72394</link>

		<dc:creator><![CDATA[sania]]></dc:creator>
		<pubDate>Fri, 01 Apr 2016 04:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-72394</guid>

					<description><![CDATA[this program is not displaying apllication layer headers.
can you help me with this please]]></description>
			<content:encoded><![CDATA[<p>this program is not displaying apllication layer headers.<br />
can you help me with this please</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sania		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-72393</link>

		<dc:creator><![CDATA[sania]]></dc:creator>
		<pubDate>Fri, 01 Apr 2016 04:12:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-72393</guid>

					<description><![CDATA[how to display apllcation layer prtocol headers in this program?]]></description>
			<content:encoded><![CDATA[<p>how to display apllcation layer prtocol headers in this program?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ๋Jack		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-68803</link>

		<dc:creator><![CDATA[๋Jack]]></dc:creator>
		<pubDate>Thu, 25 Feb 2016 13:49:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-68803</guid>

					<description><![CDATA[If I want the program to show MAC address . Could you tell me about that . Thanks.]]></description>
			<content:encoded><![CDATA[<p>If I want the program to show MAC address . Could you tell me about that . Thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: lilington		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-68624</link>

		<dc:creator><![CDATA[lilington]]></dc:creator>
		<pubDate>Tue, 23 Feb 2016 09:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-68624</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-62206&quot;&gt;QmQ&lt;/a&gt;.

Look&#039;s like he let it like this on purpose to be useful only to those who are not just copying the code.
If you wrote it yourself you will notice and correct it.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-62206">QmQ</a>.</p>
<p>Look&#8217;s like he let it like this on purpose to be useful only to those who are not just copying the code.<br />
If you wrote it yourself you will notice and correct it.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: lilington		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-68623</link>

		<dc:creator><![CDATA[lilington]]></dc:creator>
		<pubDate>Tue, 23 Feb 2016 09:18:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-68623</guid>

					<description><![CDATA[just to tell i notice an error in your code for all Print functions you forgot to shift before writting data.

fprintf(stdout,&quot;IP Header\n&quot;);
    Print_data((pkt + sizeof(struct ethhdr)),s_iph);

    fprintf(stdout,&quot;TCP Header\n&quot;);
    Print_data(pkt + sizeof(struct ethhdr) + s_iph,tcph-&#062;doff * 4);

    fprintf(stdout,&quot;Data Payload\n&quot;);
    Print_data(pkt + sizeof(struct ethhdr) + s_iph + tcph-&#062;doff * 4, (s_pkt - tcph-&#062;doff * 4 - s_iph - sizeof(struct ethhdr)));]]></description>
			<content:encoded><![CDATA[<p>just to tell i notice an error in your code for all Print functions you forgot to shift before writting data.</p>
<p>fprintf(stdout,&#8221;IP Header\n&#8221;);<br />
    Print_data((pkt + sizeof(struct ethhdr)),s_iph);</p>
<p>    fprintf(stdout,&#8221;TCP Header\n&#8221;);<br />
    Print_data(pkt + sizeof(struct ethhdr) + s_iph,tcph-&gt;doff * 4);</p>
<p>    fprintf(stdout,&#8221;Data Payload\n&#8221;);<br />
    Print_data(pkt + sizeof(struct ethhdr) + s_iph + tcph-&gt;doff * 4, (s_pkt &#8211; tcph-&gt;doff * 4 &#8211; s_iph &#8211; sizeof(struct ethhdr)));</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rick		</title>
		<link>https://www.binarytides.com/packet-sniffer-code-in-c-using-linux-sockets-bsd-part-2/comment-page-1/#comment-68327</link>

		<dc:creator><![CDATA[Rick]]></dc:creator>
		<pubDate>Thu, 18 Feb 2016 18:47:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.binarytides.com/blog/?p=1045#comment-68327</guid>

					<description><![CDATA[Very nice piece of code.  One question - If I want to read UDP only from a single interface (eth1), but I want the full ethernet frame passed along, is that possible?]]></description>
			<content:encoded><![CDATA[<p>Very nice piece of code.  One question &#8211; If I want to read UDP only from a single interface (eth1), but I want the full ethernet frame passed along, is that possible?</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
