forked from verygenericname/SSHRD_Script
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kerneldiff.py
32 lines (29 loc) · 815 Bytes
/
kerneldiff.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
#!/usr/local/bin/python3
import os
import sys
if __name__ == "__main__":
args = sys.argv
if len(args) < 4:
print("Usage: kernelcache_raw kernelcache_patched kc.bpatch")
sys.exit(0)
patched = args[2]
original = args[1]
sizeP = os.path.getsize(patched)
sizeO = os.path.getsize(original)
if sizeP != sizeO:
print("size does not match, can't compare files! exiting...")
sys.exit(1)
p = open(patched, "rb").read()
o = open(original, "rb").read()
diff = []
for i in range(sizeO):
originalByte = o[i]
patchedByte = p[i]
if originalByte != patchedByte:
diff.append([hex(i),hex(originalByte), hex(patchedByte)])
diffFile = open(args[3], 'w+')
diffFile.write('#AMFI\n\n')
for d in diff:
data = str(d[0]) + " " + (str(d[1])) + " " + (str(d[2]))
diffFile.write(data+ '\n')
print(data)