I'm building a packet using scapy library and I want to add a certain bit string in the application layer, for example, 00110011. Unfortunately, scapy converts the string '00110011' to ASCII format. But what if I want to add these 8 bits only?
Here's the packet I try to generate
pkt = Ether(src='00:00:00:00:00:01', dst='ff:ff:ff:ff:ff:ff') /
IP(src='10.10.10.10', dst='20.20.20.20', proto=0x8F) /
UDP(dport=4321, sport=1234) / '0b1111111'
Unfortunately, hexdump(pkt) gives me this:
0000 FF FF FF FF FF FF 00 00 00 00 00 01 08 00 45 00 ..............E.
0010 00 25 00 01 00 00 40 8F 3E 0E 0A 0A 0A 0A 14 14 .%....@.>.......
0020 14 14 04 D2 10 E1 00 11 B8 69 30 62 31 31 31 31 .........i0b1111
0030 31 31 31 111
But I want FF at the end, just that.
Problem solved! I just needed to pass the string in a special hex format, like '\\xff'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.