Raw socket Paket-sniffer in Python 3.6 für Windows

Ich versuche zu schnuppern-Pakete, aber ich bin immer eine merkwürdige Ausgabe, und ich verstehe nicht den Grund..
So das ist mein code bitte mir helfen

(Ich bin mit Python 3.6 auf Windows 8.1)

Code:

import socket
import struct
import binascii
import textwrap

def main():
    # Get host
    host = socket.gethostbyname(socket.gethostname())
    print('IP: {}'.format(host))

    # Create a raw socket and bind it
    conn = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
    conn.bind((host, 0))

    # Include IP headers
    conn.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
    # Enable promiscuous mode
    conn.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

    while True:
        # Recive data
        raw_data, addr = conn.recvfrom(65536)

        # Unpack data
        dest_mac, src_mac, eth_proto, data = ethernet_frame(raw_data)

        print('\nEthernet Frame:')
        print("Destination MAC: {}".format(dest_mac))
        print("Source MAC: {}".format(src_mac))
        print("Protocol: {}".format(eth_proto))

# Unpack ethernet frame
def ethernet_frame(data):
    dest_mac, src_mac, proto = struct.unpack('!6s6s2s', data[:14])
    return get_mac_addr(dest_mac), get_mac_addr(src_mac), get_protocol(proto), data[14:]

# Return formatted MAC address AA:BB:CC:DD:EE:FF
def get_mac_addr(bytes_addr):
    bytes_str = map('{:02x}'.format, bytes_addr)
    mac_address = ':'.join(bytes_str).upper()
    return mac_address

# Return formatted protocol ABCD
def get_protocol(bytes_proto):
    bytes_str = map('{:02x}'.format, bytes_proto)
    protocol = ''.join(bytes_str).upper()
    return protocol

main()

Aus diesem code bekomme ich diese Ausgabe:

IP: 192.168.1.12

Ethernet-Frame:

Ziel-MAC -: 45:00:00:43:00:00

Quell-MAC: 40:00:2C:11:48:D3

Protokoll: 4266

Ethernet-Frame:

Ziel-MAC -: 45:00:00:42:11: E7

Quell-MAC: 00:00:80:11:00:00

Protokoll: C0A8

Ethernet-Frame:

Ziel-MAC -: 45:00:00:33:04: D6

Quell-MAC: 00:00:80:11:00:00

Protokoll: C0A8

.
.
.

Laut EtherType-Liste diese Protokolle nicht existieren, und mein traffic Analyse mit Wireshark bin ich mir sicher, dass diese MACs existieren nicht in meinem LAN

So, ich bin definitiv etwas falsch, aber ich verstehe nicht, was

Vielen Dank im Voraus

Schreibe einen Kommentar