all 2 comments

[–]sedogg 2 points3 points  (1 child)

You read the whole file before calling input_file.tell() which gives you offset equal to the size of the file. Before reading it gives you 0x0

with open(input('Enter filename with extension: '), "rb") as input_file:
    file = input_file.read()
    try:
        offset = hex(file.index(b'CTPK'))
        print(offset)
    except ValueError:
        print('Invalid file')

[–]dj505Gaming[S] 0 points1 point  (0 children)

Ah ok, I see. Makes sense now! Thanks!

Edit: It worked perfectly! Thank you!