
Radare2 और Frida एक साथ बेहतर।
radare2 के लिए स्व-निहित प्लगइन जो frida को शामिल करता है और r2 कमांड का उपयोग करके स्थानीय या दूरस्थ प्रक्रियाओं को इंस्ट्रुमेंट करने की अनुमति देता है, फ्रिडा स्क्रिप्ट तक सीमित नहीं।
radare परियोजना रिवर्स इंजीनियरिंग के लिए एक पूर्ण टूलचेन प्रदान करती है, यह सक्रिय रूप से बनाए रखा जाता है और यह अच्छी तरह से बनाए रखी गई कार्यक्षमताएँ प्रदान करता है और अन्य प्रोग्रामिंग भाषाओं और टूल्स के साथ अपनी सुविधाओं का विस्तार करता है।
Frida एक गतिशील इंस्ट्रुमेंटेशन टूलकिट है जो आपके स्वयं के JavaScript को इंजेक्ट करके चल रही प्रक्रियाओं का निरीक्षण और हेरफेर करना आसान बनाता है, और वैकल्पिक रूप से आपकी स्क्रिप्ट के साथ संवाद भी करता है।
:. कमांड का उपयोग करें):db एपीआई का उपयोग करके नेटिव ब्रेकपॉइंट्सr_fs एपीआई का उपयोग करके दूरस्थ फाइलसिस्टम तक पहुंचें।r2frida स्थापित करने का अनुशंसित तरीका r2pm के माध्यम से है:
$ r2pm -ci r2frida
बाइनरी बिल्ड जिन्हें संकलन की आवश्यकता नहीं है, जल्द ही r2pm और r2env में समर्थित होंगे। तब तक रिलीज़ पेज से नवीनतम बिल्ड डाउनलोड करने में संकोच न करें।
GNU/Debian में आपको निम्नलिखित पैकेज स्थापित करने होंगे:
$ sudo apt install -y make gcc libzip-dev nodejs npm curl pkg-config git
$ git clone https://github.com/nowsecure/r2frida.git
$ cd r2frida
$ make
$ make user-install
radare2 करें (radare2-x.y.z के बजाय)preconfigure.bat)configure.bat चलाएँ और फिर make.batपरीक्षण के लिए, r2 frida://0 का उपयोग करें, क्योंकि frida में pid0 से अटैच करना एक विशेष सत्र है जो स्थानीय रूप से चलता है। अब आप उपलब्ध कमांड की सूची प्राप्त करने के लिए :? कमांड चला सकते हैं।
$ r2 'frida://?'
r2 frida://[action]/[link]/[device]/[target]
* action = list | apps | attach | spawn | launch
* link = local | usb | remote host:port
* device = '' | host:port | device-id
* target = pid | appname | process-name | program-in-path | abspath
Local:
* frida://? # show this help
* frida:// # list local processes
* frida://0 # attach to frida-helper (no spawn needed)
* frida:///usr/local/bin/rax2 # abspath to spawn
* frida://rax2 # same as above, considering local/bin is in PATH
* frida://spawn/$(program) # spawn a new process in the current system
* frida://attach/(target) # attach to target PID in current host
USB:
* frida://list/usb// # list processes in the first usb device
* frida://apps/usb// # list apps in the first usb device
* frida://attach/usb//12345 # attach to given pid in the first usb device
* frida://spawn/usb//appname # spawn an app in the first resolved usb device
* frida://launch/usb//appname # spawn+resume an app in the first usb device
Remote:
* frida://attach/remote/10.0.0.3:9999/558 # attach to pid 558 on tcp remote frida-server
Environment: (Use the `%` command to change the environment at runtime)
R2FRIDA_SAFE_IO=0|1 # Workaround a Frida bug on Android/thumb
R2FRIDA_DEBUG=0|1 # Used to debug argument parsing behaviour
R2FRIDA_COMPILER_DISABLE=0|1 # Disable the new frida typescript compiler (`:. foo.ts`)
R2FRIDA_AGENT_SCRIPT=[file] # path to file of the r2frida agent
$ r2 frida://0 # same as frida -p 0, connects to a local session
आप किसी भी प्रोग्राम को नाम या pid द्वारा अटैच, स्पॉन या लॉन्च कर सकते हैं, निम्नलिखित पंक्ति rax2 नामक पहली प्रक्रिया से अटैच होगी (इस पंक्ति का परीक्षण करने के लिए दूसरे टर्मिनल में rax2 - चलाएँ)
$ r2 frida://rax2 # attach to the first process named `rax2`
$ r2 frida://1234 # attach to the given pid
बाइनरी का निरपेक्ष पथ उपयोग करके स्पॉन करने पर प्रक्रिया प्रारंभ होगी:
$ r2 frida:///bin/ls
[0x00000000]> :dc # continue the execution of the target program
तर्कों के साथ भी काम करता है:
$ r2 frida://"/bin/ls -al"
USB पर iOS/Android ऐप्स डीबग करने के लिए इन क्रियाओं का उपयोग करें। ध्यान दें कि spawn को launch या attach से बदला जा सकता है, और प्रक्रिया का नाम bundleid या PID हो सकता है।
$ r2 frida://spawn/usb/ # enumerate devices
$ r2 frida://spawn/usb// # enumerate apps in the first iOS device
$ r2 frida://spawn/usb//Weather # Run the weather app
:i # get information of the target (pid, name, home, arch, bits, ..)
.:i* # import the target process details into local r2
:? # show all the available commands
:dm # list maps. Use ':dm|head' and seek to the program base address
:iE # list the exports of the current binary (seek)
:dt fread # trace the 'fread' function
:dt-* # delete all traces
r2frida प्लगइन्स एजेंट पक्ष पर चलते हैं और r2frida.pluginRegister API के साथ पंजीकृत होते हैं।
कुछ और उदाहरण प्लगइन स्क्रिप्ट के लिए plugins/ निर्देशिका देखें।
[0x00000000]> cat example.js
r2frida.pluginRegister('test', function(name) {
if (name === 'test') {
return function(args) {
console.log('Hello Args From r2frida plugin', args);
return 'Things Happen';
}
}
});
[0x00000000]> :. example.js # load the plugin script
:. कमांड r2 के . कमांड की तरह काम करता है, लेकिन एजेंट के अंदर चलता है।
:. a.js # run script which registers a plugin
:. # list plugins
:.-test # unload a plugin by name
:.. a.js # eternalize script (keeps running after detach)
यदि आप Termux के माध्यम से Android पर मूल रूप से r2frida स्थापित और उपयोग करना चाहते हैं, तो कुछ प्रतीक समाधानों के कारण लाइब्रेरी निर्भरताओं के साथ कुछ चेतावनियाँ हैं। इसे काम करने का तरीका LD_LIBRARY_PATH पर्यावरण को termux libdir से पहले सिस्टम निर्देशिका को इंगित करने के लिए विस्तारित करना है।
$ LD_LIBRARY_PATH=/system/lib64:$LD_LIBRARY_PATH r2 frida://...
सुनिश्चित करें कि आप r2 का आधुनिक संस्करण (अधिमानतः अंतिम रिलीज़ या git) उपयोग कर रहे हैं।
प्लगइन लोड है या नहीं यह सत्यापित करने के लिए r2 -L | grep frida चलाएँ, यदि कुछ प्रिंट नहीं होता है तो कारण जानने के लिए कुछ डीबगिंग संदेश प्राप्त करने के लिए R2_DEBUG=1 पर्यावरण चर का उपयोग करें।
यदि आपको r2frida संकलित करने में समस्या है तो आप r2env का उपयोग कर सकते हैं या GitHub रिलीज़ पेज से रिलीज़ बिल्ड प्राप्त कर सकते हैं, ध्यान रखें कि केवल MAJOR.MINOR संस्करण मेल खाना चाहिए, अर्थात r2-5.7.6 5.7.0 और 5.7.8 के बीच किसी भी संस्करण पर संकलित किसी भी प्लगइन को लोड कर सकता है।
+---------+
| radare2 | The radare2 tool, on top of the rest
+---------+
:
+----------+
| io_frida | r2frida io plugin
+----------+
:
+---------+
| frida | Frida host APIs and logic to interact with target
+---------+
:
+-------+
| app | Target process instrumented by Frida with Javascript
+-------+
यह प्लगइन NowSecure के लिए pancake उर्फ Sergi Alvarez (radare2 के लेखक) द्वारा विकसित किया गया है।
मैं Ole André को Frida लिखने और बनाए रखने के साथ-साथ इस एकीकरण को काम करने के लिए आवश्यक किसी भी चीज़ पर सक्रिय रूप से बग फिक्स करने और तकनीकी विवरणों पर चर्चा करने के लिए इतने दयालु होने के लिए धन्यवाद देना चाहता हूँ।
बधाई।