Radare2和Frida更好

Radare2的自包式插件,該插件將Frida運送,並允許使用R2命令(但不限於)Frida腳本來啟動本地或遠程進程。
Radare項目為逆向工程提供了完整的工具鏈,它是積極維護的,並且提供了良好的功能,並使用其他編程語言和工具擴展了功能。
弗里達(Frida)是一種動態的儀器工具包,可以通過注入自己的JavaScript來易於檢查和操縱運行過程,並且還可以選擇地與您的腳本進行通信。
:.命令):db API的本機斷點r_fs API訪問遠程文件系統。 安裝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-xyz)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的第一個過程(Run 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應用程序,請使用這些操作。請注意,可以用launch或attach替換spawn ,並且過程名稱可以是捆綁包或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版本頁面中獲取版本構建,請記住,只有專業版本才能匹配。
+---------+
| 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
+-------+
該插件是由Pancake aka Sergi Alvarez(radare2的作者)開發的。
我要感謝OleAndré的撰寫和維護弗里達(Frida),並非常友善地主動修復錯誤,並討論使該工會工作所需的任何事情的技術細節。榮譽