1

I'm trying to use the scapy package inside of python (3.10), on Windows 10, to communicate with an embedded device over raw ethernet. When I send the device a raw packet (level 2) using the srp1 function, the value returned is the original packet I sent, rather than the response from the device.

Here's my code (the first part just locates the interface to use):

from scapy.arch.windows import *
from scapy.all import *

def get_if():
        for info in get_windows_if_list():
                if (info['description'] == 'Linksys USB3GIGV1'):
                        for k,v in info.items():
                                if (k == 'name'):
                                        name = v
                                elif (k == 'mac'):
                                        mac = v
        return (name, mac)

(interface, src_addr) = get_if()
etherType = 0x1234
dst_addr = b"\xfc\xee\xdd\xcc\xbb\xaa"
payload = bytearray.fromhex("2a0000001234567820200100") + bytearray(34)
packet = Ether(src=src_addr, dst=dst_addr, type=etherType)/payload
rsp = srp1(packet, iface=interface)
hexdump(packet)
hexdump(rsp)

When I monitor the interface with Wireshark, I can see the correct outgoing and response packets. But the script prints the following:

Begin emission: Finished sending 1 packets.

Received 1 packets, got 1 answers, remaining 0 packets

0000 FC EE DD CC BB AA 24 F5 A2 F1 BE C1 12 34 2A 00 ......$......4*. 0010 00 00 12 34 56 78 20 20 01 00 00 00 00 00 00 00 ...4Vx ........ 0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0030 00 00 00 00 00 00 00 00 00 00 00 00 ............

0000 FC EE DD CC BB AA 24 F5 A2 F1 BE C1 12 34 2A 00 ......$......4*. 0010 00 00 12 34 56 78 20 20 01 00 00 00 00 00 00 00 ...4Vx ........ 0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0030 00 00 00 00 00 00 00 00 00 00 00 00 ............

As you can see, the response is the same as the sent packet.

I have some Java code (that uses npcap) that successfully communicates with the device, so I'm sure it's something I'm doing wrong with scapy and/or python.

Rick Ball
  • 21
  • 3

0 Answers0