Skip to content
Snippets Groups Projects
Commit 1ab1cd44 authored by gpotter2's avatar gpotter2
Browse files

Fix little-big endian dissection issue

parent 695913c5
No related branches found
No related tags found
No related merge requests found
......@@ -730,9 +730,11 @@ class BitField(Field):
self.size = abs(size)
def reverse(self, val):
if self.size == 16:
val = socket.ntohs(val)
# Replaces socket.ntohs (but work on both little/big endian)
val = struct.unpack('>H',struct.pack('<H', val))[0]
elif self.size == 32:
val = socket.ntohl(val)
# Same here but for socket.ntohl
val = struct.unpack('>I',struct.pack('<I', val))[0]
return val
def addfield(self, pkt, s, val):
......
......@@ -643,6 +643,12 @@ assert(_ == b'\x00\x00\x00\x00\xe3OjYLw\xc3x_%\xd0\xcf\xdeu-\xc3pH#\x1eK\xae\xf5
Dot11WEP(_)
assert(TCP in _ and _[TCP].seq == 12345678)
= RadioTap Big-Small endian dissection
raw = b'\x00\x00\x1a\x00/H\x00\x00\xe1\xd3\xcb\x05\x00\x00\x00\x00@0x\x14@\x01\xac\x00\x00\x00'
r = RadioTap(raw)
r.show()
assert r.present == 18479
############
############
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment