Advertisement
Nickpips

Untitled

Nov 10th, 2015 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. def s12(value):
  2. return -(value & 0b10000000) | (value & 0b01111111)
  3.  
  4. def toHex(s):
  5. lst = []
  6. for ch in s:
  7. hv = hex(ord(ch)).replace('0x', '')
  8. if len(hv) == 1:
  9. hv = '0'+hv
  10. lst.append(hv)
  11.  
  12. return reduce(lambda x,y:x+y, lst)
  13.  
  14. from pcapfile import savefile
  15. testcap = open('mouse.pcap')
  16. pkts = savefile.load_savefile(testcap, verbose=False).packets
  17. for i in range(0,len(pkts)):
  18. pkts[i] = toHex(pkts[i].raw())[-12:-4]
  19.  
  20. x = 0
  21. y = 0
  22.  
  23. out = ""
  24.  
  25. for i in range(0,760):
  26. x = x + s12(int(pkts[i][2:4],16))
  27. y = y + s12(int(pkts[i][4:6],16))
  28. 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"
  29.  
  30. open("out","w").write(out)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement