from pathlib import Path
path = Path("/mnt/data/9c1b1aa7-8154-4f7b-9863-1cb2ebea1235.bin")
data = path.read_bytes()
strings = []
cur = []
for b in data:
if 32 <= b <= 126:
cur.append(chr(b))
else:
if len(cur) >= 4:
strings.append(''.join(cur))
cur = []
if len(cur) >= 4:
strings.append(''.join(cur))
# Save all strings
all_strings_file = Path("/mnt/data/bin_strings.txt")
all_strings_file.write_text("\n".join(strings), encoding="utf-8")
# Save notable strings (>= 20 chars)
notable = [s for s in strings if len(s) >= 20]
notable_file = Path("/mnt/data/bin_strings_notable.txt")
notable_file.write_text("\n".join(notable), encoding="utf-8")
print("All strings file:", all_strings_file.as_posix())
print("Notable strings file:", notable_file.as_posix())
Aucun commentaire:
Enregistrer un commentaire