Search code examples
linuxsocketsiparpraw-sockets

Linux Socket and ARP spoofing


I have been experimenting with ARP spoofing on my local LAN. Now, I would like to try to write in C a simple sniffer, but I have some questions:

  1. If the ARP spoofing has been a success my NIC will receive and not drop packets that have my MAC ADDRESS (Layer 2) but a DST IP (Layer 3) which is not mine. What kind of sockets can I use to take those packets? I think some sort of RAW sockets, but an example or a good reference would be appreciated.
  2. Is there a way (throw C) to put my NIC in promiscuous mode in order to force it to pick up packets with different MAC?

Solution

  • After some investigation I think the best way is to use libcap http://man7.org/linux/man-pages/man3/libcap.3.html, which comes with good routine to call.