Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def s12(value):
- return -(value & 0b10000000) | (value & 0b01111111)
- def toHex(s):
- lst = []
- for ch in s:
- hv = hex(ord(ch)).replace('0x', '')
- if len(hv) == 1:
- hv = '0'+hv
- lst.append(hv)
- return reduce(lambda x,y:x+y, lst)
- from pcapfile import savefile
- testcap = open('mouse.pcap')
- pkts = savefile.load_savefile(testcap, verbose=False).packets
- for i in range(0,len(pkts)):
- pkts[i] = toHex(pkts[i].raw())[-12:-4]
- x = 0
- y = 0
- out = ""
- for i in range(0,760):
- x = x + s12(int(pkts[i][2:4],16))
- y = y + s12(int(pkts[i][4:6],16))
- out = out + str((x,y))+("L" if s12(int(pkts[i][0:2],16)) == 1 else ("R" if s12(int(pkts[i][0:2],16)) == 2 else ""))+"\n"
- open("out","w").write(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement