mtkclient/Tools/get_preloader_values.py

37 lines
1.1 KiB
Python
Raw Normal View History

2023-06-11 13:35:12 -04:00
#!/usr/bin/env python3
import os
from struct import unpack, pack
2023-12-29 16:12:09 -05:00
2023-06-11 13:35:12 -04:00
def main():
loaders = []
2024-06-29 10:48:59 -04:00
for root, dirs, files in os.walk("", topdown=False):
2023-06-11 13:35:12 -04:00
for file in files:
loaders.append(os.path.join(root, file))
for loader in loaders:
2023-12-29 16:12:09 -05:00
data = open(loader, "rb").read()
idx = data.find(pack("<II", 0x8000004, 0x8000008))
if idx != -1:
2023-06-11 13:35:12 -04:00
print(loader)
2023-12-29 16:12:09 -05:00
v = unpack("<I", data[idx - 4:idx])[0]
if v == 0x1003C0:
v = unpack("<I", data[idx + 3 * 4:idx + 3 * 4 + 4])[0]
print("2:" + hex(v))
if v == 0x800000c:
v = unpack("<I", data[idx + 3 * 4:idx + 3 * 4 + 4])[0]
print("3:" + hex(v))
if v == 0x8825252:
v = unpack("<I", data[idx - 8:idx - 4])[0]
if v == 0x1003C0:
v = unpack("<I", data[idx + 3 * 4:idx + 3 * 4 + 4])[0]
print("5:" + hex(v))
2023-06-11 13:35:12 -04:00
else:
2023-12-29 16:12:09 -05:00
print("4:" + hex(v))
2023-06-11 13:35:12 -04:00
print(hex(v))
2023-12-29 16:12:09 -05:00
2023-06-11 13:35:12 -04:00
if __name__ == "__main__":
2023-12-29 16:12:09 -05:00
main()