Radare2とFridaは一緒に良くなります

Fridaを出荷し、R2コマンドを使用してローカルまたはリモートのプロセスを機器にすることを可能にするRadare2用の自己完結型プラグイン(ただし、これらに限定されません)。
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実行しますテストの場合は、FridaのPID0にアタッチすることはローカルで実行される特別なセッションであるためr2 frida://0を使用します。今、あなたは:?コマンドのリストを利用可能にするコマンド。
$ 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 -を実行する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 -L | grep fridaプラグインがロードされているかどうかを確認するために、何も印刷されていない場合R2_DEBUG=1環境変数を使用して、いくつかのデバッグメッセージを取得して理由を見つけます。
R2Fridaのコンパイルの問題がある場合は、 r2envを使用するか、GitHubリリースページからリリースビルドを取得できます。majour.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
+-------+
このプラグインは、Pancake別名Sergi Alvarez(Radare2の著者)によってNowsecureのために開発されました。
Fridaを書いて維持してくれたOleAndréに感謝し、バグを積極的に修正し、この組合を機能させるために必要なものに関する技術的な詳細について議論することに感謝します。称賛