0
file = open('calc.exe', 'rb')
file.seek(0x3c)
data = file.read(4)
file.seek(data)

data return bytes in this form: b'\xe8\x00\x00\x00' seek needs int in this form 0xe8 how can I do it?

Eyalnir7
  • 53
  • 6
  • 1
    `file.seek(int(bytes(reversed(data)).hex(), 16))` if needed little endian or `file.seek(int(data.hex(), 16))` if needed big endian. – Arty Oct 19 '20 at 14:27
  • As it appeared to be there is even simpler one built-in function `int.from_bytes(data, 'little')` or `int.from_bytes(data, 'big')` for little and big endian. But this functions appeared only from Python 3.2. But `.hex()` mentioned above also appeared in quite recent Pythons. – Arty Oct 20 '20 at 01:47

0 Answers0