Compare commits

...

3 Commits

Author SHA1 Message Date
wangsiyuan e358abc840 更新 files_utils.py 2023-10-18 15:13:04 +08:00
wangsiyuan 054d36b04d 更新 main.py 2023-10-18 15:13:01 +08:00
wangsiyuan 424ff95d2b 更新 hook_conversions.js 2023-10-18 15:12:58 +08:00
3 changed files with 39 additions and 22 deletions

View File

@ -2,18 +2,10 @@ console.log("Script loaded successfully");
// hook_okhttp_client()
if (Java.available) {
hook_json()
Java.perform(function () {
try {
var OkHttpClient = Java.use("okhttp3.OkHttpClient");
console.log(OkHttpClient.toString())
if (OkHttpClient != null){
hook_okhttp_client();
log_info("OkHttp detected in the app");
}
} catch (e) {
log_info("OkHttp not detected in the app");
}
});
let class_name = "okhttp3.OkHttpClient"
if (check_class(class_name)){
hook_okhttp_client()
}
Java.perform(function () {
log_info("start hook java.net.URL");
var URL = Java.use('java.net.URL');
@ -49,10 +41,6 @@ function hook_okhttp_client() {
log_info("start hook_okhttp_client.")
try {
var OkHttpClient = Java.use("okhttp3.OkHttpClient");
// log_info("OkHttpClient: " + OkHttpClient.toString());
var class_name = OkHttpClient.$className;
console.log(class_name+ "-------")
printMethods(OkHttpClient.toString());
OkHttpClient.newCall.overload('okhttp3.Request').implementation = function (request) {
var requestUrl = request.url();
if (requestUrl) {
@ -60,12 +48,11 @@ function hook_okhttp_client() {
} else {
console.log("OkHttp Request URL is not available");
}
// console.log("OkHttp Request Headers: " + request.headers().toString());
// if (request.method() == "POST") {
// console.log("OkHttp Request Body: " + request.body().contentType().toString());
// }
console.log("OkHttp Request Headers: " + request.headers().toString());
if (request.method() == "POST") {
console.log("OkHttp Request Body: " + request.body().contentType().toString());
}
var call = this.newCall(request);
var response = call.execute();
console.log("OkHttp Response: " + response.body().string());
@ -179,4 +166,23 @@ function log_info(messages) {
const timestamp = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}:${milliseconds}`;
console.log(`${timestamp} - ${messages}`);
}
function check_class(class_name) {
var classFound = false; // 默认为未找到
Java.enumerateLoadedClasses({
onMatch: function(currentClassName) {
if (currentClassName === class_name) {
classFound = true; // 如果找到了类则设置为true
}
},
onComplete: function() {
if (classFound) {
log_info(class_name + " has been loaded!");
} else {
log_info(class_name + " has not been loaded yet.");
}
}
});
return classFound;
}

View File

@ -5,8 +5,11 @@ import sys
import time
FIRST_WRITE = True # 全局变量,用于跟踪是否是首次写入
def on_message(message, data):
print(message)
modules.files_utils.write_log(message)
# print(message)
# if message['type'] == 'send':
# print(message['payload'])

View File

@ -13,3 +13,11 @@ def read_javascript(script_path):
with open(script_path, "r") as file:
script_code = file.read()
return script_code
def write_log(messages):
global FIRST_WRITE
print(f"FIRST_WRITE: {FIRST_WRITE}")
with open("frida_log.log", "a") as log_file:
if FIRST_WRITE: # 如果是首次写入
log_file.write("\n\n\n") # 空出三行
FIRST_WRITE = False # 更新状态,表明已经写过了
log_file.write(str(messages) + "\n")