Werk jy by 'n cybersekuriteitsmaatskappy? Wil jy jou maatskappy geadverteer sien in HackTricks? of wil jy toegang hê tot die nuutste weergawe van die PEASS of HackTricks aflaai in PDF-formaat? Kyk na die INSKRYWINGSPLANNE!
Bugsbounty wenk: teken aan vir Intigriti, 'n premium bugsbounty platform geskep deur hackers, vir hackers! Sluit by ons aan by https://go.intigriti.com/hacktricks vandag, en begin om belonings te verdien tot $100,000!
Sommige dele van die oorspronklike kode werk nie en is hier gewysig.
Deel 2
Hier kan jy 'n voorbeeld sien van hoe om 2 funksies met dieselfde naam maar verskillende parameters te hook.
Verder gaan jy leer hoe om 'n funksie te roep met jou eie parameters.
En laastens, is daar 'n voorbeeld van hoe om 'n instansie van 'n klas te vind en dit 'n funksie te laat roep.
//s2.jsconsole.log("Script loaded successfully ");Java.perform(functionx() {console.log("Inside java perform function");var my_class =Java.use("com.example.a11x256.frida_test.my_activity");//Hook "fun" with parameters (int, int)my_class.fun.overload("int","int").implementation=function (x, y) { //hooking the old functionconsole.log("original call: fun("+ x +", "+ y +")");var ret_value =this.fun(2,5);return ret_value;};//Hook "fun" with paramater(String)var string_class =Java.use("java.lang.String");my_class.fun.overload("java.lang.String").implementation=function (x) { //hooking the new functionconsole.log("*")//Create a new String and call the function with your input.var my_string =string_class.$new("My TeSt String#####");console.log("Original arg: "+ x);var ret =this.fun(my_string);console.log("Return value: "+ ret);console.log("*")return ret;};//Find an instance of the class and call "secret" function.Java.choose("com.example.a11x256.frida_test.my_activity", {onMatch:function (instance) {console.log(tring, and the it has"Found instance: "+ instance);console.log("Result of secret func: "+instance.secret());},onComplete:function () { }});});
Jy kan sien dat om 'n String te skep, dit eers die klas java.lang.String verwys het en toe 'n $new voorwerp van daardie klas met 'n String as inhoud geskep het. Dit is die korrekte manier om 'n nuwe voorwerp van 'n klas te skep. Maar, in hierdie geval, kon jy net enige String deurgee aan this.fun() soos: this.fun("hey there!")
Python
//loader.pyimport fridaimport timedevice = frida.get_usb_device()pid = device.spawn(["com.example.a11x256.frida_test"])device.resume(pid)time.sleep(1)#Without it Java.perform silently failssession = device.attach(pid)script = session.create_script(open("s2.js").read())script.load()#prevent the python script from terminatingraw_input()
python loader.py
Deel 3
Python
Nou gaan jy sien hoe om bevele na die gehookte program te stuur via Python om 'n funksie te roep:
Die bevel "1" sal afsluit, die bevel "2" sal 'n instansie van die klas vind en die private funksiesecret() aanroep en die bevel "3" sal die funksie secret()hook sodat dit 'n verskillende string teruggee.
Dan, as jy "2" aanroep, sal jy die werklike geheim kry, maar as jy "3" en dan "2" aanroep, sal jy die vals geheim kry.
JS
console.log("Script loaded successfully ");var instances_array = [];functioncallSecretFun() {Java.perform(function () {if (instances_array.length==0) { // if array is emptyJava.choose("com.example.a11x256.frida_test.my_activity", {onMatch:function (instance) {console.log("Found instance: "+ instance);instances_array.push(instance)console.log("Result of secret func: "+instance.secret());},onComplete:function () { }});}else {//else if the array has some valuesconsole.log("Result of secret func: "+ instances_array[0].secret());}});}functionhookSecret() {Java.perform(function () {var my_class =Java.use("com.example.a11x256.frida_test.my_activity");var string_class =Java.use("java.lang.String");my_class.secret.overload().implementation=function(){var my_string =string_class.$new("TE ENGANNNNEEE");return my_string;}});}rpc.exports = {callsecretfunction: callSecretFun,hooksecretfunction: hookSecret};
Deel 4
Hier sal jy sien hoe om Python en JS te laat interakteer deur JSON-voorwerpe te gebruik. JS gebruik die send()-funksie om data na die Python-klient te stuur, en Python gebruik post()-funksies om data na die JS-skrip te stuur. Die JS sal die uitvoering blokkeer totdat dit 'n respons van Python ontvang.
Bug bounty wenk: teken aan vir Intigriti, 'n premium bug bounty platform geskep deur hackers, vir hackers! Sluit by ons aan by https://go.intigriti.com/hacktricks vandag, en begin om belonings te verdien tot $100,000!
Werk jy in 'n cybersecurity maatskappy? Wil jy jou maatskappy geadverteer sien in HackTricks? of wil jy toegang hê tot die nuutste weergawe van die PEASS of laai HackTricks af in PDF? Kyk na die INSKRYWINGSPLANNE!