The first thing with radare2 is to make sure that you're running the latest git version.
To get help about commands in radare2, you can use the ?
character. For help about configuration variables, you can use e??
(since e?
would give you help about how to use them, not list them). Since there are many variables, you can filter them with the internal grep command : ~
.
[0x00000000]> e??dbg
dbg.args: Set the args of the program to debug
dbg.backend: Select the debugger backend
dbg.bep: break on entrypoint (loader, entry, constructor, main)
dbg.bpinmaps: Force breakpoints to be inside a valid map
dbg.bpsize: Size of software breakpoints
dbg.btalgo: Select backtrace algorithm
dbg.btdepth: Depth of backtrace
dbg.clone: Stop execution if new thread is created
dbg.execs: Stop execution if new thread is created
dbg.follow: Follow program counter when pc > core->offset + dbg.follow
dbg.forks: Stop execution if fork() is done (see dbg.threads)
dbg.libs: If set stop when loading matching libname
dbg.profile: Path to RRunProfile file
dbg.shallow_trace: While tracing, avoid following calls outside specified range
dbg.slow: Show stack and regs in visual mode in a slow but verbose mode
dbg.status: Set cmd.prompt to '.dr*' or '.dr*;drd;sr PC;pi 1;s-'
dbg.swstep: Force use of software steps (code analysis+breakpoint)
dbg.threads: Stop all threads when debugger breaks (see dbg.forks)
dbg.trace: Trace program execution (see asm.trace)
dbg.trace.tag: Trace tag
dbg.unlibs: If set stop when unloading matching libname
[0x00000000]>
You could aslo have use e dbg.<tab>
, since there is autocompletion.
Obviously, the variale you're looking for is dbg.fork
, to set it to true: this will stop the process when it encounters a fork()
. You can the change the pid with a d
-command:
[0x00000000]> d?~process
| dH [handler] Transplant process to a new handler
| do Open process (reload, alias for 'oo')
| dp[?] List, attach to process or thread id
| dx[?] Inject and run code on target process (See gs)
[0x00000000]> dp?
|Usage: dp # Process commands
| dp List current pid and childrens
| dp List children of pid
| dp* List all attachable pids
| dp= Select pid
| dp- Dettach select pid
| dpa Attach and select pid
| dpe Show path to executable
| dpf Attach to pid like file fd // HACK
| dpk Send signal to process
| dpn Create new process (fork)
| dpnt Create new thread (clone)
| dpt List threads of current pid
| dpt List threads of process
| dpt= Attach to thread
[0x00000000]