java Reflection hook code
자바 리플렉션 후킹 코드
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 | Java.use("java.lang.Class").forName.overload('java.lang.String').implementation = function (param0) { console.log("forName hook : " + param0); return this.forName(param0); }; Java.use("java.lang.Class").getMethod.overload('java.lang.String', '[Ljava.lang.Class;').implementation = function (param0, param1) { console.log("getMethod hook : " + param0); return this.getMethod(param0, param1); }; var jlrmethod = Java.use("java.lang.reflect.Method") jlrmethod.invoke.implementation = function(object, parameters){ var retvalue = this.invoke(object, parameters) var type = Object.prototype.toString.call(parameters) if(type == '[object Array]'){ var arrayLength = parameters.length; // console.log(arrayLength) for (var i = 0; i < arrayLength; i++) { var parameter = parameters[i] var paramstring = String(parameter) if(paramstring.startsWith("[Ljava.lang.String;@")){ console.log("------------") console.log("string array") console.log(type + JSON.stringify(parameter)) var result = parameter console.log(type + result) console.log("------------") } else{ console.log(type + parameter) } } } else{ console.log(type + parameters) } console.log("Method.invoke(object, parameters): '" + this + "' = '" + object + "', '" + parameters + "' = '" + retvalue + "'") return retvalue } | cs |