
Radare2 и Frida — лучше вместе.
Самодостаточный плагин для radare2, который включает в себя frida и позволяет инструментировать локальные или удалённые процессы с помощью команд r2 вместо (но не ограничиваясь) скриптов Frida.
Проект radare предоставляет полный набор инструментов для обратной разработки, он активно поддерживается, предоставляет хорошо поддерживаемые функциональные возможности и расширяет их с помощью других языков программирования и инструментов.
Frida — это набор инструментов для динамической инструментации, который упрощает исследование и манипулирование работающими процессами путём внедрения вашего собственного JavaScript, а также, при желании, взаимодействие с вашими скриптами.
:.):dbr_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, так как присоединение к pid0 в frida — это специальная
сессия, которая выполняется локально. Теперь вы можете выполнить команду :?, чтобы получить список
доступных команд.
$ 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 выполняются на стороне агента и регистрируются с помощью API r2frida.pluginRegister.
Смотрите каталог 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, но выполняется внутри агента.