Skip to content Skip to sidebar Skip to footer

How To Spoof The Ip Address In A Udp Packet With Scapy

I'm testing the security infrastructure on my server, running an application that accepts UDP traffic on port 7777. In order to do that, I want to send UDP packets to query for inf

Solution 1:

FYI you could create a packet template, it will be much easier. Something like

class YourPacket(Packet):
    fields_desc = [
        StrFixedLenField("head", "SAMP", 4),
        IPField("ip", "0.0.0.0"),
        ShortField("port", 0),
        ByteField("opcode", 0)
    ]

Then make sure you are sending it on the correct interface. You can add iface=... to send().

Demo:

>>>x = YourPacket(ip="192.168.200.103", port=7777, opcode=ord(b"i"))>>>x
<YourPacket  ip=192.168.200.103 port=7777 opcode=105 |>
>>>hexdump(x)
0000  53 41 4D 50 C0 A8 C8 67 1E 61 69                 SAMP...g.ai
>>>send(IP()/UDP(dport=7777)/x)

Post a Comment for "How To Spoof The Ip Address In A Udp Packet With Scapy"