Compare commits

...

6 Commits

Author SHA1 Message Date
wangsiyuan b1b381b7a6 更新 test.py 2023-10-11 16:45:37 +08:00
wangsiyuan 7dd5c0d661 更新 files_utils.py 2023-10-11 16:45:35 +08:00
wangsiyuan 4b174c9f3e 更新 command.py 2023-10-11 16:45:33 +08:00
wangsiyuan 0892550341 更新 main.py 2023-10-11 16:45:31 +08:00
wangsiyuan 1613f15825 更新 hook_conversions.js 2023-10-11 16:45:27 +08:00
wangsiyuan 0370063b48 删除 hook.log 2023-10-11 16:45:25 +08:00
6 changed files with 64 additions and 46 deletions

View File

@ -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 ]->

View File

@ -1,4 +1,5 @@
console.log("Script loaded successfully");
Java.perform(function() {
var URL = Java.use('java.net.URL');
URL.$init.overload('java.lang.String').implementation = function(spec) {
@ -8,10 +9,3 @@ Java.perform(function() {
return this.$init(spec);
};
});

46
main.py
View File

@ -1,32 +1,62 @@
import frida
import modules.command
import modules.files_utils
import sys
import time
def on_message(message, data):
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.clearCache(package_name)
# 连接到USB设备
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()
for process in processes:
if process.name == attach_process_name:
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)
script = session.create_script("""
console.log("Hello from Frida!");
""")
script = session.create_script(js_code)
script.on('message', on_message)
script.load()
else:
print(f"get process error")
if __name__ == '__main__':
is_spawn = True
attach_process_name = "Navi"
package_name = "com.naviapp"
js_script =
main(attach_process_name,package_name)
script_path = "./hook_conversions.js"
main(package_name,script_path, is_spawn)

View File

@ -76,7 +76,7 @@ def clearCache(package_name):
if stopApp(package_name):
output, status_code, error = run_adb_command(['adb', 'shell', 'pm', 'clear', package_name])
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
else:
print(error)
@ -89,7 +89,7 @@ def stopApp(package_name):
print(f"强行停止{package_name}")
output, status_code, error = run_adb_command(['adb', 'shell', 'am', 'force-stop', package_name])
if status_code == 0:
print(f"status_code: {status_code}\n output: {output}")
print(f"status_code: {status_code}\noutput: {output}")
return True
else:
print(error)

View File

@ -10,5 +10,6 @@ def get_path(script_name):
return script_path
def read_javascript(script_path):
with open(script_path, "r") as file:
script_code = file.read()
return script_code

11
test.py
View File

@ -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()