Frida Tutorial

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert) के साथ!

HackTricks का समर्थन करने के अन्य तरीके:

बग बाउंटी टिप: साइन अप करें Intigriti के लिए, एक प्रीमियम बग बाउंटी प्लेटफॉर्म जो हैकर्स द्वारा बनाई गई है! आज हमारे साथ शामिल हों https://go.intigriti.com/hacktricks, और शुरू करें बाउंटी अप तक $100,000 तक कमाना!

स्थापना

फ्रिडा टूल्स स्थापित करें:

pip install frida-tools
pip install frida

एंड्रॉइड में डाउनलोड और इंस्टॉल करें फ्रिडा सर्वर (नवीनतम रिलीज़ डाउनलोड करें)। एक-लाइनर एडीबी को रूट मोड में पुनः आरंभ करने, इससे कनेक्ट करने, फ्रिडा-सर्वर अपलोड करने, एक्ज़ेक्यूशन अनुमतियाँ देने और बैकग्राउंड में चलाने के लिए:

adb root; adb connect localhost:6000; sleep 1; adb push frida-server /data/local/tmp/; adb shell "chmod 755 /data/local/tmp/frida-server"; adb shell "/data/local/tmp/frida-server &"

जांचें कि क्या यह काम कर रहा है:

frida-ps -U #List packages and processes
frida-ps -U | grep -i <part_of_the_package_name> #Get all the package name

ट्यूटोरियल

स्रोत: https://medium.com/infosec-adventures/introduction-to-frida-5a3f51595ca1 APK: https://github.com/t0thkr1s/frida-demo/releases स्रोत कोड: https://github.com/t0thkr1s/frida-demo

इसे पढ़ने के लिए लिंक पर जाएं.

स्रोत: https://11x256.github.io/Frida-hooking-android-part-2/ (भाग 2, 3 और 4) APK और स्रोत कोड: https://github.com/11x256/frida-android-examples

इसे पढ़ने के लिए लिंक पर जाएं.

स्रोत: https://joshspicer.com/android-frida-1 APK: https://github.com/OWASP/owasp-mstg/blob/master/Crackmes/Android/Level_01/UnCrackable-Level1.apk

इसे पढ़ने के लिए लिंक पर जाएं.

आप यहाँ अधिक शानदार फ्रिडा स्क्रिप्ट पा सकते हैं: https://codeshare.frida.re/

त्वरित उदाहरण

कमांड लाइन से फ्रिडा को कॉल करना

frida-ps -U

#Basic frida hooking
frida -l disableRoot.js -f owasp.mstg.uncrackable1

#Hooking before starting the app
frida -U --no-pause -l disableRoot.js -f owasp.mstg.uncrackable1
#The --no-pause and -f options allow the app to be spawned automatically,
#frozen so that the instrumentation can occur, and the automatically
#continue execution with our modified code.

मूल Python स्क्रिप्ट

import frida, sys

jscode = open(sys.argv[0]).read()
process = frida.get_usb_device().attach('infosecadventures.fridademo')
script = process.create_script(jscode)
print('[ * ] Running Frida Demo application')
script.load()
sys.stdin.read()

पैरामीटर बिना फ़ंक्शन हुक करना

कक्षा sg.vantagepoint.a.c के फ़ंक्शन a() को हुक करें

Java.perform(function () {
;  rootcheck1.a.overload().implementation = function() {
rootcheck1.a.overload().implementation = function() {
send("sg.vantagepoint.a.c.a()Z   Root check 1 HIT!  su.exists()");
return false;
};
});

Translate to Hindi:

Hook java exit()

जावा exit() को हुक करें

var sysexit = Java.use("java.lang.System");
sysexit.exit.overload("int").implementation = function(var_0) {
send("java.lang.System.exit(I)V  // We avoid exiting the application  :)");
};

Translate to Hindi:

Hook MainActivity .onStart() & .onCreate()

एमेन एक्टिविटी के .onStart() और .onCreate() को हुक करें

var mainactivity = Java.use("sg.vantagepoint.uncrackable1.MainActivity");
mainactivity.onStart.overload().implementation = function() {
send("MainActivity.onStart() HIT!!!");
var ret = this.onStart.overload().call(this);
};
mainactivity.onCreate.overload("android.os.Bundle").implementation = function(var_0) {
send("MainActivity.onCreate() HIT!!!");
var ret = this.onCreate.overload("android.os.Bundle").call(this,var_0);
};

Frida Tutorial: Hook android .onCreate()

एंड्रॉयड .onCreate() को हुक करें

var activity = Java.use("android.app.Activity");
activity.onCreate.overload("android.os.Bundle").implementation = function(var_0) {
send("Activity HIT!!!");
var ret = this.onCreate.overload("android.os.Bundle").call(this,var_0);
};

पैरामीटर के साथ फंक्शन को हुक करना और मान प्राप्त करना

एक डिक्रिप्शन फंक्शन को हुक करना। इनपुट प्रिंट करें, मूल फंक्शन को कॉल करें, इनपुट को डिक्रिप्ट करें और अंत में, प्लेन डेटा प्रिंट करें:

function getString(data){
var ret = "";
for (var i=0; i < data.length; i++){
ret += data[i].toString();
}
return ret
}
var aes_decrypt = Java.use("sg.vantagepoint.a.a");
aes_decrypt.a.overload("[B","[B").implementation = function(var_0,var_1) {
send("sg.vantagepoint.a.a.a([B[B)[B   doFinal(enc)  // AES/ECB/PKCS7Padding");
send("Key       : " + getString(var_0));
send("Encrypted : " + getString(var_1));
var ret = this.a.overload("[B","[B").call(this,var_0,var_1);
send("Decrypted : " + ret);

var flag = "";
for (var i=0; i < ret.length; i++){
flag += String.fromCharCode(ret[i]);
}
send("Decrypted flag: " + flag);
return ret; //[B
};

फ़ंक्शन को हुक करना और हमारे इनपुट को उसमें कॉल करना

एक फ़ंक्शन को हुक करें जो एक स्ट्रिंग प्राप्त करता है और उसे दूसरी स्ट्रिंग के साथ कॉल करें (यहाँ से)

var string_class = Java.use("java.lang.String"); // get a JS wrapper for java's String class

my_class.fun.overload("java.lang.String").implementation = function(x){ //hooking the new function
var my_string = string_class.$new("My TeSt String#####"); //creating a new String by using `new` operator
console.log("Original arg: " +x );
var ret =  this.fun(my_string); // calling the original function with the new String, and putting its return value in ret variable
console.log("Return value: "+ret);
return ret;
};

किसी क्लास के पहले से बनाए गए ऑब्ज

Java.choose("com.example.a11x256.frida_test.my_activity" , {
onMatch : function(instance){ //This function will be called for every instance found by frida
console.log("Found instance: "+instance);
console.log("Result of secret func: " + instance.secret());
},
onComplete:function(){}
});

अन्य फ्रिडा ट्यूटोरियल

बग बाउंटी टिप: Intigriti में साइन अप करें, एक प्रीमियम बग बाउंटी प्लेटफॉर्म जो हैकर्स द्वारा बनाया गया है! हमारे साथ जुड़ें https://go.intigriti.com/hacktricks आज ही, और शुरू करें बाउंटी कमाना जो तकनीकी त्रुटियों तक $100,000 तक हो सकता है!

जानें AWS हैकिंग को शून्य से हीरो तक htARTE (HackTricks AWS Red Team Expert) के साथ!

HackTricks का समर्थन करने के अन्य तरीके:

Last updated