panda-re / panda

Platform for Architecture-Neutral Dynamic Analysis
https://panda.re
Other
2.47k stars 474 forks source link

Fix split_taps.py to work in python3 #1428

Closed Phasip closed 7 months ago

Phasip commented 7 months ago

split_taps.py does not work in python3, it mixes up byte arrays and strings and uses functionality not existing in python3.

This results in exceptions when trying to use it both for plain txt and for .gz files.

# ./split_taps.py write_tap_buffers.txt.gz out
Traceback (most recent call last):
  File "/usr/local/share/panda/scripts/split_taps.py", line 37, in <module>
    main(args.logfile, args.prefix, num_callers=args.callers)
  File "/usr/local/share/panda/scripts/split_taps.py", line 20, in main
    callers, pc, stack_kind, sid_first, sid_second, addr, n, val = line.strip().rsplit(" ", 7)
TypeError: a bytes-like object is required, not 'str'

And for non-gz:

./split_taps.py read_tap_buffers.txt out
Traceback (most recent call last):
  File "/usr/local/share/panda/scripts/split_taps.py", line 37, in <module>
    main(args.logfile, args.prefix, num_callers=args.callers)
  File "/usr/local/share/panda/scripts/split_taps.py", line 26, in main
    val = val.decode('hex')
AttributeError: 'str' object has no attribute 'decode'
lacraig2 commented 7 months ago

Looks good. Will merge after CI finishes.