
Radare2 y Frida mejor juntos.
Radare2 y Frida, mejores juntos
Plugin autocontenido para radare2 que incluye frida y permite instrumentar procesos locales o remotos usando comandos de r2 en lugar de (pero no limitado a) scripts de Frida.
El proyecto radare proporciona una cadena de herramientas completa para ingeniería inversa, se mantiene activamente y ofrece funcionalidades bien mantenidas y amplía sus características con otros lenguajes de programación y herramientas.
Frida es un kit de herramientas de instrumentación dinámica que facilita la inspección y manipulación de procesos en ejecución mediante la inyección de tu propio JavaScript y, opcionalmente, también la comunicación con tus scripts.
:.):dbr_fs.La forma recomendada de instalar r2frida es mediante r2pm:
$ r2pm -ci r2frida
Las compilaciones binarias que no requieren compilación serán compatibles pronto en
r2pm y r2env. Mientras tanto, siéntete libre de descargar las últimas compilaciones
desde la página de Releases.
En GNU/Debian necesitarás instalar los siguientes paquetes:
$ 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
Opciones: -Dfrida_sdk=<dir>, -Dprecompiled_agent=<_agent.js>, -Dr2_plugdir=<dir>, -Dsession_debugger=false.
radare2 (en lugar de radare2-x.y.z)preconfigure.bat)configure.bat y luego make.batPara probar, use r2 frida://0, ya que adjuntarse al pid0 en frida es una sesión
especial que se ejecuta en local. Ahora puede ejecutar el comando :? para obtener la lista
de comandos disponibles.
$ 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
Puedes adjuntarte, generar o lanzar cualquier programa por nombre o pid. La siguiente línea se adjuntará al primer proceso llamado rax2 (ejecuta rax2 - en otra terminal para probar esta línea)
$ r2 frida://rax2 # attach to the first process named `rax2`
$ r2 frida://1234 # attach to the given pid
Usar la ruta absoluta de un binario para lanzarlo generará el proceso:
$ r2 frida:///bin/ls
[0x00000000]> :dc # continue the execution of the target program
También funciona con argumentos:
$ r2 frida://"/bin/ls -al"
Para la depuración USB de aplicaciones iOS/Android utilice estas acciones. Tenga en cuenta que spawn
puede reemplazarse por launch o attach, y el nombre del proceso puede ser
el bundleid o el 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
Estos son los comandos más frecuentes, por lo que debes aprenderlos y añadirles el sufijo ? para obtener la ayuda de los subcomandos.
: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
Los plugins de r2frida se ejecutan en el lado del agente y se registran con la API r2frida.pluginRegister.
Consulta el directorio plugins/ para ver más scripts de plugins de ejemplo.