-
Notifications
You must be signed in to change notification settings - Fork 83
/
findsvc.py
50 lines (48 loc) · 1.1 KB
/
findsvc.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
42
43
44
45
46
47
48
49
50
import logging
import posixpath
import sys
import os
import traceback
def find_bytes(f, target):
addrs = []
f.seek(0, 0)
step = len(target)
off = 0
while True:
b = f.read(step)
if (b == target):
addrs.append(off)
#
if (len(b) == 0):
break
off += step
#
return addrs
#
if __name__ == "__main__":
if (len(sys.argv) < 2):
print ("usage %s <soname> "%sys.argv[0])
sys.exit(1)
#
soname = sys.argv[1]
svc_arm = bytearray([00, 00, 00, 0xef])
svc_thumb = bytearray([00, 0xdf])
svc_arm64_ios = bytearray([0x01,0x10,0x00,0xD4])
with open(soname, "rb") as f:
svcs_arm = find_bytes(f, svc_arm)
print ("svc arm:")
for svc in svcs_arm:
print(hex(svc))
#
print ("svc thumb:")
svcs_thumb = find_bytes(f, svc_thumb)
for svc in svcs_thumb:
print(hex(svc))
#
print ("svc ios64:")
svcs_thumb = find_bytes(f, svc_arm64_ios)
for svc in svcs_thumb:
print(hex(svc))
#
#
#