Compare commits
6 Commits
239f2b1de4
...
b1b381b7a6
| Author | SHA1 | Date |
|---|---|---|
|
|
b1b381b7a6 | |
|
|
7dd5c0d661 | |
|
|
4b174c9f3e | |
|
|
0892550341 | |
|
|
1613f15825 | |
|
|
0370063b48 |
18
hook.log
18
hook.log
|
|
@ -1,18 +0,0 @@
|
||||||
____
|
|
||||||
/ _ | Frida 16.0.19 - A world-class dynamic instrumentation toolkit
|
|
||||||
| (_| |
|
|
||||||
> _ | Commands:
|
|
||||||
/_/ |_| help -> Displays the help system
|
|
||||||
. . . . object? -> Display information about 'object'
|
|
||||||
. . . . exit/quit -> Exit
|
|
||||||
. . . .
|
|
||||||
. . . . More info at https://frida.re/docs/home/
|
|
||||||
. . . .
|
|
||||||
. . . . Connected to Pixel 3 (id=89KX0AVQN)
|
|
||||||
Spawning `com.naviapp`...
|
|
||||||
Script loaded successfully
|
|
||||||
Spawned `com.naviapp`. Resuming main thread!
|
|
||||||
[Pixel 3::com.naviapp ]-> URL request: https://launches.appsflyer.com/api/v6.3/androidevent?app_id=com.naviapp&buildnumber=6.3.2
|
|
||||||
URL request: https://inapps.appsflyer.com/api/v6.3/androidevent?app_id=com.naviapp&buildnumber=6.3.2
|
|
||||||
|
|
||||||
[Pixel 3::com.naviapp ]->
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
console.log("Script loaded successfully");
|
console.log("Script loaded successfully");
|
||||||
|
|
||||||
Java.perform(function() {
|
Java.perform(function() {
|
||||||
var URL = Java.use('java.net.URL');
|
var URL = Java.use('java.net.URL');
|
||||||
URL.$init.overload('java.lang.String').implementation = function(spec) {
|
URL.$init.overload('java.lang.String').implementation = function(spec) {
|
||||||
|
|
@ -8,10 +9,3 @@ Java.perform(function() {
|
||||||
return this.$init(spec);
|
return this.$init(spec);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
46
main.py
46
main.py
|
|
@ -1,32 +1,62 @@
|
||||||
import frida
|
import frida
|
||||||
import modules.command
|
import modules.command
|
||||||
|
import modules.files_utils
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
def on_message(message, data):
|
def on_message(message, data):
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
def main(attach_process_name,package_name):
|
|
||||||
|
def attach_method(is_spawn):
|
||||||
|
if type(is_spawn) == bool:
|
||||||
|
if is_spawn:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
print(f"is_spawn type error,please check is_spawn type.")
|
||||||
|
|
||||||
|
|
||||||
|
def main(package_name,script_path,is_spawn):
|
||||||
|
js_code = modules.files_utils.read_javascript(script_path)
|
||||||
|
# print(js_code)
|
||||||
modules.command.start_frida()
|
modules.command.start_frida()
|
||||||
modules.command.clearCache(package_name)
|
modules.command.clearCache(package_name)
|
||||||
# 连接到USB设备
|
# 连接到USB设备
|
||||||
device = frida.get_usb_device()
|
device = frida.get_usb_device()
|
||||||
pid = 0
|
print(device)
|
||||||
|
if attach_method(is_spawn):
|
||||||
|
pid = device.spawn(package_name)
|
||||||
|
print(f"进程pid: {pid}")
|
||||||
|
process = device.attach(pid)
|
||||||
|
script = process.create_script(js_code)
|
||||||
|
script.on("message", on_message)
|
||||||
|
script.load()
|
||||||
|
device.resume(pid) # 加载完脚本后, 恢复进程运行
|
||||||
|
sys.stdin.read()
|
||||||
|
else:
|
||||||
# 列出设备上的所有进程
|
# 列出设备上的所有进程
|
||||||
|
pid = None
|
||||||
processes = device.enumerate_processes()
|
processes = device.enumerate_processes()
|
||||||
for process in processes:
|
for process in processes:
|
||||||
if process.name == attach_process_name:
|
if process.name == attach_process_name:
|
||||||
pid = process.pid
|
pid = process.pid
|
||||||
print(process.pid, process.name)
|
print(f"pid: {process.pid},App Name: {process.name}")
|
||||||
# 如果你想附加到一个特定的进程并注入一个脚本:
|
# 如果你想附加到一个特定的进程并注入一个脚本:
|
||||||
|
if pid is not None:
|
||||||
session = device.attach(pid)
|
session = device.attach(pid)
|
||||||
script = session.create_script("""
|
script = session.create_script(js_code)
|
||||||
console.log("Hello from Frida!");
|
|
||||||
""")
|
|
||||||
script.on('message', on_message)
|
script.on('message', on_message)
|
||||||
script.load()
|
script.load()
|
||||||
|
else:
|
||||||
|
print(f"get process error")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
is_spawn = True
|
||||||
attach_process_name = "Navi"
|
attach_process_name = "Navi"
|
||||||
package_name = "com.naviapp"
|
package_name = "com.naviapp"
|
||||||
js_script =
|
script_path = "./hook_conversions.js"
|
||||||
main(attach_process_name,package_name)
|
main(package_name,script_path, is_spawn)
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ def clearCache(package_name):
|
||||||
if stopApp(package_name):
|
if stopApp(package_name):
|
||||||
output, status_code, error = run_adb_command(['adb', 'shell', 'pm', 'clear', package_name])
|
output, status_code, error = run_adb_command(['adb', 'shell', 'pm', 'clear', package_name])
|
||||||
if status_code == 0:
|
if status_code == 0:
|
||||||
print(f"clear cache status_code: {status_code}\n output: {output}")
|
print(f"clear cache status_code: {status_code}\noutput: {output}")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(error)
|
print(error)
|
||||||
|
|
@ -89,7 +89,7 @@ def stopApp(package_name):
|
||||||
print(f"强行停止{package_name}")
|
print(f"强行停止{package_name}")
|
||||||
output, status_code, error = run_adb_command(['adb', 'shell', 'am', 'force-stop', package_name])
|
output, status_code, error = run_adb_command(['adb', 'shell', 'am', 'force-stop', package_name])
|
||||||
if status_code == 0:
|
if status_code == 0:
|
||||||
print(f"status_code: {status_code}\n output: {output}")
|
print(f"status_code: {status_code}\noutput: {output}")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(error)
|
print(error)
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ def get_path(script_name):
|
||||||
return script_path
|
return script_path
|
||||||
|
|
||||||
def read_javascript(script_path):
|
def read_javascript(script_path):
|
||||||
|
with open(script_path, "r") as file:
|
||||||
|
script_code = file.read()
|
||||||
|
return script_code
|
||||||
|
|
|
||||||
11
test.py
11
test.py
|
|
@ -0,0 +1,11 @@
|
||||||
|
import frida,sys
|
||||||
|
import modules.files_utils
|
||||||
|
|
||||||
|
js_code = modules.files_utils.read_javascript("./hook_conversions.js")
|
||||||
|
device = frida.get_usb_device()
|
||||||
|
pid = device.spawn(["com.naviapp"]) # 以挂起方式创建进程
|
||||||
|
process = device.attach(pid)
|
||||||
|
script = process.create_script(js_code)
|
||||||
|
script.load()
|
||||||
|
device.resume(pid) # 加载完脚本, 恢复进程运行
|
||||||
|
sys.stdin.read()
|
||||||
Reference in New Issue