Created
November 3, 2016 11:45
-
-
Save boxofrad/4511ba4357401a0ea7a04e4d394b9609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Receive every packet | |
ETH_P_ALL = 0x0300 | |
# Size in bytes of a C `sockaddr_ll` structure on a 64-bit system | |
# | |
# struct sockaddr_ll { | |
# unsigned short sll_family; /* Always AF_PACKET */ | |
# unsigned short sll_protocol; /* Physical-layer protocol */ | |
# int sll_ifindex; /* Interface number */ | |
# unsigned short sll_hatype; /* ARP hardware type */ | |
# unsigned char sll_pkttype; /* Packet type */ | |
# unsigned char sll_halen; /* Length of address */ | |
# unsigned char sll_addr[8]; /* Physical-layer address */ | |
# }; | |
# | |
SOCKADDR_LL_SIZE = 0x0014 | |
sockaddr_ll = [Socket::AF_PACKET].pack('s') | |
sockaddr_ll << [ETH_P_ALL].pack('s') | |
sockaddr_ll << index | |
sockaddr_ll << ("\x00" * (SOCKADDR_LL_SIZE - sockaddr_ll.length)) | |
socket.bind(sockaddr_ll) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment