Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packet Sniffing using Raw Sockets in Linux in C

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

like image 535
Sajad Bahmani Avatar asked Oct 28 '09 15:10

Sajad Bahmani


People also ask

How use raw socket in Linux?

Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends the raw datagram not including link level headers. The IPv4 layer generates an IP header when sending a packet unless the IP_HDRINCL socket option is enabled on the socket.

Does Wireshark use raw sockets?

Wireshark can't capture raw socket only when protocol is TCP - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

What is the use of raw sockets?

The raw socket interface provides direct access to lower layer protocols, such as the Internet Protocol (IP) and Internet Control Message Protocol (ICMP or ICMPv6). You can use raw sockets to test new protocol implementations.


1 Answers

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

like image 199
gte525u Avatar answered Sep 20 '22 05:09

gte525u