forked from iamtorsten/SherlockElf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibc.py
45 lines (36 loc) · 1.35 KB
/
libc.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
# Hook strlen method
import frida
import sys
from emu.injector import Inject
target = "" # Enter the name of the app to be monitored here.
def on_message(message, data):
if message['type'] == 'send':
print(f"[Message from SherlockElf]: {message['payload']}")
with open("dump/strlen_dump.txt", "a") as f:
f.write(f'{message}\n')
elif message['type'] == 'error':
print(f"[Error]: {message['stack']}")
def on_destroyed():
print("[*] Script destroyed.")
def main():
try:
# Load the Frida script
with open("hook/strlen.js") as f:
script_code = f.read()
# Attach to the target process
device, session = Inject(target=target).attach()
script = session.create_script(script_code)
script.on('message', on_message)
script.on('destroyed', on_destroyed)
script.load()
# Keep the script running
print(f"[*] Hooking {target}. Press Ctrl+C to stop.")
sys.stdin.read()
except frida.ServerNotRunningError:
print("Frida server is not running. Please start the frida-server on your device.")
except frida.ProcessNotFoundError:
print(f"Process '{target}' not found. Make sure the app is running.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
if __name__ == "__main__":
main()