Packet Sniffing using Raw Sockets in Linux in C

Sajad Bahmani picture Sajad Bahmani · Oct 28, 2009 · Viewed 11k times · Source

I need to write a packet sniffer in Linux that detects HTTPS packet that are sent and save the url from the request. I found code for this in security-freak and ran it. This code runs and only sniffs the received packet but I need to get the sent packet in the sniffer. How do I get the sent packet in this code?

I can't use any library like libcap (forbidden). The code is :sniffer.c

Answer

gte525u picture gte525u · Nov 3, 2009

You should be using ETH_P_ALL instead of ETH_P_IP as the protocol. ETH_P_IP only listens for incoming IP packets.