May-25-2023, 08:29 PM
(This post was last modified: May-25-2023, 08:30 PM by billykid999.)
Here is a printout after some updated code:
Protocol: 1 192.168.56.1 -> 192.168.56.1
Version: 4
Header Length: 5 TTL: 128
ICMP -> Type: 0 Code: 0
It seems my headers are fine, except maybe the Type 0 code meaning unreachable.
Protocol: 1 192.168.56.1 -> 192.168.56.1
Version: 4
Header Length: 5 TTL: 128
ICMP -> Type: 0 Code: 0
It seems my headers are fine, except maybe the Type 0 code meaning unreachable.
class ICMP: def __init__(self, buff): header = struct.unpack('<BBHHH', buff) self.type = header[0] self.code = header[1] self.sum = header[2] self.id = header[3] self.seq = header[4] try: while True: raw_buffer = sniffer.recvfrom(65535)[0] ip_header = IP(raw_buffer[0:24]) print(f'Version: {ip_header.ver}') print(f'Header Length: {ip_header.ihl} TTL: {ip_header.ttl}') offset = ip_header.ihl * 4 buf = raw_buffer[offset:offset + 8] icmp_header = ICMP(buf) print('ICMP -> Type: %s Code: %s\n' % (icmp_header.type, icmp_header.code)) print('Protocol: %s %s -> %s' % (ip_header.protocol, ip_header.src_address, ip_header.dst_address))any suggestions?