
Radare2 e Frida melhores juntos.
Radare2 e Frida melhores juntos
Plugin autónomo para radare2 que inclui frida e permite instrumentar processos locais ou remotos usando comandos r2 em vez de (mas não limitado a) scripts Frida.
O projeto radare fornece uma cadeia de ferramentas completa para engenharia reversa, é mantido ativamente e fornece funcionalidades bem mantidas e estende as suas funcionalidades com outras linguagens de programação e ferramentas.
Frida é um kit de ferramentas de instrumentação dinâmica que facilita a inspeção e manipulação de processos em execução ao injetar o seu próprio JavaScript, e opcionalmente também comunicar com os seus scripts.
:.):dbr_fs.A forma recomendada de instalar o r2frida é via r2pm:
$ r2pm -ci r2frida
Compilações binárias que não requerem compilação serão brevemente suportadas no
r2pm e r2env. Entretanto, sinta-se à vontade para descarregar as últimas compilações
da página de Releases.
Em GNU/Debian precisará de instalar os seguintes pacotes:
$ 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 (em vez de radare2-x.y.z)preconfigure.bat)configure.bat e depois make.batPara testar, use r2 frida://0, pois anexar ao pid0 no frida é uma sessão
especial que corre localmente. Agora pode executar o comando :? para obter a lista
de comandos disponíveis.
$ 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
Pode anexar, gerar ou lançar para qualquer programa por nome ou pid. A seguinte linha irá anexar ao primeiro processo chamado rax2 (execute rax2 - noutro terminal para testar esta linha)
$ r2 frida://rax2 # attach to the first process named `rax2`
$ r2 frida://1234 # attach to the given pid
Usar o caminho absoluto de um binário para gerar irá gerar o processo:
$ r2 frida:///bin/ls
[0x00000000]> :dc # continue the execution of the target program
Também funciona com argumentos:
$ r2 frida://"/bin/ls -al"
Para depuração USB de apps iOS/Android use estas ações. Note que spawn
pode ser substituído por launch ou attach, e o nome do processo pode ser
o bundleid ou o 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
Estes são os comandos mais frequentes, por isso deve aprendê-los e acrescentar o sufixo ? para obter ajuda sobre 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
Os plugins r2frida correm no lado do agente e são registados com a API r2frida.pluginRegister.
Veja o diretório plugins/ para mais alguns exemplos de scripts de 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
O comando :. funciona como o comando . do r2, mas corre dentro do agente.
:. a.js # run script which registers a plugin
:. # list plugins
:.-test # unload a plugin by name
:.. a.js # eternalize script (keeps running after detach)