
Radare2 और Frida एक साथ बेहतर।
radare2 के लिए स्व-निहित प्लगइन जो frida को शामिल करता है और r2 कमांड का उपयोग करके स्थानीय या दूरस्थ प्रक्रियाओं को इंस्ट्रुमेंट करने की अनुमति देता है (लेकिन Frida स्क्रिप्ट तक सीमित नहीं है)।
radare प्रोजेक्ट रिवर्स इंजीनियरिंग के लिए एक संपूर्ण टूलचेन प्रदान करता है, यह सक्रिय रूप से अनुरक्षित है और अच्छी तरह से अनुरक्षित कार्यक्षमताएँ प्रदान करता है और अन्य प्रोग्रामिंग भाषाओं और टूल्स के साथ अपनी सुविधाओं का विस्तार करता है।
Frida एक डायनामिक इंस्ट्रुमेंटेशन टूलकिट है जो आपके अपने JavaScript को इंजेक्ट करके चल रही प्रक्रियाओं का निरीक्षण और हेरफेर करना आसान बनाता है, और वैकल्पिक रूप से आपकी स्क्रिप्ट के साथ संचार भी करता है।
:. कमांड का उपयोग करें):db api का उपयोग करके नेटिव ब्रेकपॉइंटr_fs api का उपयोग करके दूरस्थ फ़ाइलसिस्टम तक पहुँचेंr2frida इंस्टॉल करने का अनुशंसित तरीका r2pm के माध्यम से है:
$ r2pm -ci r2frida
बाइनरी बिल्ड जिन्हें कंपाइल करने की आवश्यकता नहीं होती, जल्द ही
r2pm और r2env में समर्थित होंगे। तब तक बेझिझक नवीनतम बिल्ड
Releases पृष्ठ से डाउनलोड करें।
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
$ meson setup build -Duser_install=true
$ ninja -C build
$ meson install -C build
विकल्प: -Dfrida_sdk=<dir>, -Dprecompiled_agent=<_agent.js>, -Dr2_plugdir=<dir>, -Dsession_debugger=false.
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 के . कमांड की तरह काम करता है, लेकिन एजेंट के अंदर चलता है।