-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimg_analyze.py
41 lines (32 loc) · 1.01 KB
/
img_analyze.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import argparse
def get_int(number):
if number.startswith('0x'):
return int(number, 16)
else:
return int(number, 10)
def main():
parser = argparse.ArgumentParser(
prog="b01lers image analyze tool",
description="tool to analyze images dumped from flash",
)
parser.add_argument(
"-i", "--image", required=True, help="Image to analyze"
)
parser.add_argument(
"-a", "--addr", required=True, help="Address to dump"
)
parser.add_argument(
"-l", "--len", required=True, help="Length to dump"
)
args = parser.parse_args()
addr = get_int(args.addr)
index = addr - 0x1000e000
len = get_int(args.len)
with open(args.image, 'rb') as f:
data = f.read()
# print(hex(data.index(b'expand 16') + 0x1000e000))
# print(hex(data.index(b'\x13\x23') + 0x1000e000))
print(hex(data.index(b'\x3c\x0b\x00\x20') + 0x1000e000))
print(data[index:index + len])
if __name__ == '__main__':
main()