0
Good Afternoon. I am programming a script with the socket library, struct and ctypes, to sniffing the packages on the network, but I’m having trouble in the section that passes the first 20 bytes of the package.
try:
while True:
raw_buffer = sniffer.recvfrom(65565)[0]
ip_header = IP(raw_buffer[0:20])
print ("Protocolo: %s %s -> %s" % (ip_header.protocol, ip_header.src_address, ip_header.dst_address))
What problem? Edit your question and include more details to clarify the problem.
– Cmte Cardeal
Cod expects a whole and the informed type is not.
– stack.cardoso
Probably the problem is when you try to instantiate the IP class, which expects an int, but is receiving a string, should change to
IP(int(raw_buffer[0:20]))
, but they can be other things, since details are missing for a better analysis...– Felipe Avelar