Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import struct
- argc = len(sys.argv)
- if argc != 3:
- script = os.path.basename(__file__)
- sys.exit("usage: {} <filename> <value>".format(script))
- filename = sys.argv[1]
- value = int(sys.argv[2], 0)
- if value < 0 or value > 0xff:
- sys.exit("value must be in the range [0, 0xff]")
- with open(filename, "r+b") as file:
- # Determine the size of the file
- file.seek(0, os.SEEK_END)
- size = file.tell()
- address = 0
- while address < size:
- # Read the next byte
- file.seek(address)
- byte = struct.unpack("B", file.read(1))[0]
- # Check for a match
- if byte == value:
- print hex(address)
- address += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement