更新 hook_conversions.js
parent
358c51a054
commit
7dc4eb24fd
|
|
@ -1,101 +1,118 @@
|
||||||
console.log("Script loaded successfully");
|
console.log("Script loaded successfully");
|
||||||
|
// hook_okhttp_client()
|
||||||
if (Java.available) {
|
if (Java.available) {
|
||||||
Java.perform(function () {
|
Java.perform(function() {
|
||||||
console.log("start hook java.net.URL");
|
try {
|
||||||
get_request_info()
|
var OkHttpClient = Java.use("okhttp3.OkHttpClient");
|
||||||
var URL = Java.use('java.net.URL');
|
console.log("OkHttp detected in the app");
|
||||||
URL.$init.overload('java.lang.String').implementation = function (spec) {
|
} catch (e) {
|
||||||
if (spec.includes("appsflyer")) {
|
console.log("OkHttp not detected in the app");
|
||||||
console.log("URL request: " + spec);
|
|
||||||
if (spec.includes("conversions")){
|
|
||||||
// check_conversion_loaded()
|
|
||||||
var stackTrace = Java.use('java.lang.Exception').$new().getStackTrace().toString();
|
|
||||||
console.log(stackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.$init(spec);
|
|
||||||
};
|
|
||||||
// JSONObject.$init.overload('java.lang.String').implementation = function (jsonString) {
|
|
||||||
// var result = this.$init.overload('java.lang.String').call(this, jsonString);
|
|
||||||
// if (typeof result.toString !== "undefined") {
|
|
||||||
// console.log("result: " + result.toString())
|
|
||||||
// var msgData = jsonString.toString();
|
|
||||||
//
|
|
||||||
// if (msgData.contains("install_time") &&
|
|
||||||
// (msgData.contains("af_siteid") || msgData.contains("af_channel") ||
|
|
||||||
// msgData.contains("af_status") || msgData.contains("af_message")) &&
|
|
||||||
// (!msgData.contains("is_first_launch"))) {
|
|
||||||
// console.log("msgdata: " + msgData)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// };
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_conversion_loaded() {
|
|
||||||
Java.perform(function() {
|
|
||||||
var found = false;
|
|
||||||
Java.enumerateLoadedClasses({
|
|
||||||
onMatch: function(className) {
|
|
||||||
if (className.includes("AppsFlyer2dXConversionCallback")) {
|
|
||||||
console.log("Found: " + className);
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onComplete: function() {
|
|
||||||
if (!found) {
|
|
||||||
console.log("AppsFlyer2dXConversionCallback class not loaded.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
Java.perform(function () {
|
||||||
|
console.log("start hook java.net.URL");
|
||||||
}
|
var URL = Java.use('java.net.URL');
|
||||||
|
URL.$init.overload('java.lang.String').implementation = function (spec) {
|
||||||
function get_request_info() {
|
if (spec.includes("appsflyer")) {
|
||||||
console.log("start running get_request_info")
|
console.log("URL request: " + spec);
|
||||||
var HttpURLConnection = Java.use('java.net.HttpURLConnection');
|
if (spec.includes("conversions")) {
|
||||||
var ByteArrayOutputStream = Java.use('java.io.ByteArrayOutputStream');
|
var stackTrace = Java.use('java.lang.Exception').$new().getStackTrace().toString();
|
||||||
console.log(HttpURLConnection,ByteArrayOutputStream)
|
console.log(stackTrace);
|
||||||
printMethods('java.net.HttpURLConnection');
|
}
|
||||||
printMethods('java.io.ByteArrayOutputStream');
|
}
|
||||||
HttpURLConnection.getRequestMethod.implementation = function () {
|
return this.$init(spec);
|
||||||
var url = this.getURL().toString();
|
};
|
||||||
var method = this.getRequestMethod();
|
});
|
||||||
console.log("URL: " + url + " | Request Method: " + method);
|
|
||||||
return method;
|
|
||||||
};
|
|
||||||
HttpURLConnection.setRequestProperty.implementation = function (key, value) {
|
|
||||||
if (this.getURL().toString().includes("conversions")){
|
|
||||||
console.log("Header: " + key + ": " + value);
|
|
||||||
}
|
|
||||||
return this.setRequestProperty(key, value);
|
|
||||||
};
|
|
||||||
HttpURLConnection.getOutputStream.implementation = function() {
|
|
||||||
var outputStream = this.getOutputStream();
|
|
||||||
var byteArrayOutputStream = ByteArrayOutputStream.$new();
|
|
||||||
var bytes = Java.array('byte', [1024]);
|
|
||||||
var len;
|
|
||||||
while ((len = outputStream.read(bytes)) != -1) {
|
|
||||||
byteArrayOutputStream.write(bytes, 0, len);
|
|
||||||
}
|
|
||||||
var requestBody = byteArrayOutputStream.toString();
|
|
||||||
if (this.getURL().toString().includes("conversions")) {
|
|
||||||
console.log("Request Body: " + requestBody);
|
|
||||||
}
|
|
||||||
return outputStream;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function printMethods(className) {
|
function printMethods(className) {
|
||||||
var jclass = Java.use(className);
|
var jclass = Java.use(className);
|
||||||
var methods = jclass.class.getDeclaredMethods();
|
var methods = jclass.class.getDeclaredMethods();
|
||||||
console.log("Printing methods of " + className + ":\n");
|
console.log("Printing methods of " + className + ":\n");
|
||||||
methods.forEach(function(method) {
|
methods.forEach(function (method) {
|
||||||
console.log(method);
|
console.log(method);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hook_okhttp_client() {
|
||||||
|
if (Java.available) {
|
||||||
|
Java.perform(function () {
|
||||||
|
try {
|
||||||
|
var OkHttpClient = Java.use("okhttp3.OkHttpClient");
|
||||||
|
|
||||||
|
OkHttpClient.newCall.overload('okhttp3.Request').implementation = function (request) {
|
||||||
|
console.log("OkHttp Request URL: " + request.url().toString());
|
||||||
|
console.log("OkHttp Request Headers: " + request.headers().toString());
|
||||||
|
|
||||||
|
if (request.method() == "POST") {
|
||||||
|
console.log("OkHttp Request Body: " + request.body().contentType().toString());
|
||||||
|
// Here you can further extract the request body if needed.
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = this.newCall(request).execute();
|
||||||
|
console.log("OkHttp Response: " + response.body().string());
|
||||||
|
|
||||||
|
// Note: Calling response.body().string() consumes the response body.
|
||||||
|
// You might need to recreate the response if the app expects to read it again.
|
||||||
|
|
||||||
|
return this.newCall(request);
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error hooking OkHttp: " + e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function hook_HttpURLConnection_stream() {
|
||||||
|
console.log("start hook_HttpURLConnection_stream")
|
||||||
|
if (Java.available) {
|
||||||
|
Java.perform(function () {
|
||||||
|
var HttpURLConnection = Java.use("java.net.HttpURLConnection");
|
||||||
|
|
||||||
|
HttpURLConnection.getOutputStream.implementation = function () {
|
||||||
|
var outputStream = this.getOutputStream();
|
||||||
|
var OutputStreamWrapper = Java.use("java.io.OutputStream");
|
||||||
|
|
||||||
|
var newOutputStream = Java.registerClass({
|
||||||
|
name: "CustomOutputStream",
|
||||||
|
superClass: OutputStreamWrapper,
|
||||||
|
methods: {
|
||||||
|
write: function (buffer, byteOffset, byteCount) {
|
||||||
|
var data = Array.prototype.slice.call(buffer.slice(byteOffset, byteOffset + byteCount));
|
||||||
|
console.log("Request data: " + String.fromCharCode.apply(null, data));
|
||||||
|
outputStream.write(buffer, byteOffset, byteCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return newOutputStream.$new(outputStream);
|
||||||
|
};
|
||||||
|
|
||||||
|
HttpURLConnection.getInputStream.implementation = function () {
|
||||||
|
var inputStream = this.getInputStream();
|
||||||
|
var InputStreamWrapper = Java.use("java.io.InputStream");
|
||||||
|
|
||||||
|
var newInputStream = Java.registerClass({
|
||||||
|
name: "CustomInputStream",
|
||||||
|
superClass: InputStreamWrapper,
|
||||||
|
methods: {
|
||||||
|
read: function (buffer, byteOffset, byteCount) {
|
||||||
|
var bytesRead = inputStream.read(buffer, byteOffset, byteCount);
|
||||||
|
if (bytesRead != -1) {
|
||||||
|
var data = Array.prototype.slice.call(buffer.slice(byteOffset, byteOffset + bytesRead));
|
||||||
|
console.log("Response data: " + String.fromCharCode.apply(null, data));
|
||||||
|
}
|
||||||
|
return bytesRead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return newInputStream.$new(inputStream);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue