Reputation: 1089
I know that I can append Raw
data to a scapy packet like this
>>> p=Ether()/Raw("somedata")
>>> hexdump(p)
WARNING: Mac address to reach destination not found. Using broadcast.
0000 FF FF FF FF FF FF 00 00 00 00 00 00 90 00 73 6F ..............so
0010 6D 65 64 61 74 61 medata
>>>
Here the data is appended in ASCII format.
But how could I append just numbers to a packet like this?
# Not real
>>> p = Ether()/RawNumbers(0x1234567891)
>>> hexdump(p)
WARNING: Mac address to reach destination not found. Using broadcast.
0000 FF FF FF FF FF FF 00 00 00 00 00 00 90 00 12 34 ................
0010 56 78 91 ...
>>>
Perhaps I could write a Packet-subclass which does this, but I'm not sure how to implement this. Any ideas?
Upvotes: 0
Views: 2993
Reputation: 3356
There is no need for a RawNumbers
layer as you can achieve this with python built-in functionality. Note that scapy will by default assume a raw layer if your layer is just a string.
>>> hexdump(Ether()/"\x12\x34\x56\x78\x91")
WARNING: Mac address to reach destination not found. Using broadcast.
0000 FF FF FF FF FF FF 00 00 00 00 00 00 90 00 12 34 ...............4
0010 56 78 91 Vx.
or (more convenient)
>>> hexdump(Ether()/"1234567891".decode("hex"))
WARNING: Mac address to reach destination not found. Using broadcast.
0000 FF FF FF FF FF FF 00 00 00 00 00 00 90 00 12 34 ...............4
0010 56 78 91 Vx.
Upvotes: 1