Hier ist der Code ist:python3 - Typeerror: kann nicht Bytes concat auf str
def flip_bytes(binary_f):
i = random.randint(0, len(binary_f))
c = chr(random.randint(0, 0xFF))
return binary_f[:i] + c + binary_f[i+1:]
def copy_binary():
with open("license", "rb") as orig_f, open("license_fuzz", "wb") as fuzz_f:
fuzz_f.write(flip_bytes(orig_f.read()))
license
ist ein ELF ausführbare Datei, wenn ich das Skript ausführen bekomme ich diesen Fehler:
Traceback (most recent call last):
File "parse.py", line 30, in <module>
copy_binary()
File "parse.py", line 11, in copy_binary
fuzz_f.write(flip_bytes(orig_f.read()))
File "parse.py", line 7, in flip_bytes
return binary_f[:i] + c + binary_f[i+1:]
TypeError: can't concat bytes to str
Wie Ich repariere das?
(Hier ist die whole script nur für den Fall)