pythonfile-iobinarycorruptionhex-editors

How to read binary files?


I'm trying to take a binary file and reverse the encryption on it using python.

The problem is that Python isn't reading what's actually in the file, and it seems like the internal data gets quite corrupt too.

Printing out the binary file from python yields:

b'[\xbb\x90\x92\x00\xdd\x7f\xe5\xe9\x81y\x82\x9a[\x0fOf\x19\t\xe8k\xa8R\xb5\x0c\x9f\xadZA\xb5\xd3\xef\xcd\xa9#U\xef\x996\xdc+N\xbe\xc8D\x1c?\xa8\xb3\xd7#\xbf\xb7\x18\xcd\xdf\xe5\xe5\xcf\xb5`?\xe3[J\x06\x041).'

While HxD yields:

5B BB 90 92 00 DD 7F E5 E9 81 79 82 9A 5B 0F 4F 66 19 09 E8 6B A8 52 B5 0C 9F AD 5A 41 B5 D3 EF CD A9 23 55 EF 99 36 DC 2B 4E BE C8 44 1C 3F A8 B3 D7 23 BF B7 18 CD DF E5 E5 CF B5 60 3F E3 5B 4A 06 04 31 29 2E

Python not only misses the first byte, but it starts to massively screw things up around the E9 byte.

How do I fix this?

edit: my code to read the file is as follows. The python debugger and the print function yield the error as above.

binary_file= open("Challenge-RE-Obfuscated", "rb")
full_string = binary_file.read()

Solution

  • In bytes representation, printable characters are displayed literally, so 0x5b is displayed as [, 0x79 is y etc.