Hello guys;
I need to send ARP request but I m facing with some socket problem . While I m searching about it , the AF_PACKET family is used to solve it but these packet is not involved in the socket module then I tried to use SOCK_RAW but I think I cant open it truely.
import socket
from struct import pack
from uuid import getnode as get_mac
l
Thanks.....
I need to send ARP request but I m facing with some socket problem . While I m searching about it , the AF_PACKET family is used to solve it but these packet is not involved in the socket module then I tried to use SOCK_RAW but I think I cant open it truely.
import socket
from struct import pack
from uuid import getnode as get_mac
l
ocal_mac = [int(("%x" % get_mac())[i:i+2], 16) for i in range(0, 12, 2)] local_ip = [int(x) for x in socket.gethostbyname(socket.gethostname()).split('.')] Socket=socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.htons(0x0003)) ip='169.254.126.85' print (local_mac,local_ip) port=8000 dest_ip=[192,168,137,1] Socket.bind((ip,port)) ARP_FRAME = [ pack('!H', 0x0001), pack('!H', 0x0806), pack('!B', 0x06), pack('!B', 0x04), pack('!H', 0x0001), pack('!6B', *local_mac), pack('!4B', *local_ip), pack('!6B', *(0x00,)*6), pack('!4B', *dest_ip), ] print(ARP_FRAME) Socket.sendto(b''.join(ARP_FRAME), ('ff.ff.ff.ff.ff.ff',8000))This is my code , some of them taking from the Internet ,What Am I doing wrong ? Or can you suggest better way to do this .
Thanks.....
Moderator: Added code tags for you this time. Pleas add as a matter of course going foreard. Thanks - Larz60+