Gallopsled / pwntools

CTF framework and exploit development library
http://pwntools.com
Other
11.74k stars 1.67k forks source link

`unhex` breaks when passed odd-lengthd bytestring #2326

Closed peace-maker closed 6 months ago

peace-maker commented 6 months ago

It tries to prepend a '0' string to a bytestring.

In [5]: unhex(b'b12')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-4ac64938706a> in <module>
----> 1 unhex(b'b12')

~/tools/pwntools/pwnlib/util/fiddling.py in unhex(s)
     41     s = s.strip()
     42     if len(s) % 2 != 0:
---> 43         s = '0' + s
     44     return binascii.unhexlify(s)
     45

TypeError: can only concatenate str (not "bytes") to str
snarkyyy commented 6 months ago

Tried to fix this with https://github.com/Gallopsled/pwntools/pull/2333