user1261273
user1261273

Reputation:

radare2: how to pass parameters to debugee?

I want to debug the program "id3v2 -c hallo test.mp3" with radare2. How can I pass the arguments "-c hallo test.mp3" to radare2?

I only found something with rarun2, but when I do r2 -d rarun2 program=/usr/bin/id3v2 arg1=-c arg2=hallo arg3=test.mp3, the debugger is in rarun2 and not in id3v2.

Upvotes: 5

Views: 13356

Answers (1)

Megabeets
Megabeets

Reputation: 1398

You can pass arguments to radare2 debugged program in several ways.

The simplest way is:

r2 -d program arg1 arg2 arg3
  • r2 is an alias for radare2.
  • -d is telling radare2 to debug the execuable.
  • arg1..3 are the arguments passed to the executable by radare2.

Another way is using the ood command inside radare2 shell:

Execute radare2 ./program, then type ood arg1 arg2 arg3. The ood command is used to "reopen in debugger mode (with args)".

You can also call ood with dynamic parameters using backticks. For example we want debug our program using the content from a file on our system as an arguments:

ood `!cat file.txt`

Say file.txt content is 'foo bar' so this equivalent to executing ood foo bar

  • backticks are used for passing the output of radare2 commands.
  • ! is running the given command as in system(3).

Another way to pass arguments to radare2 debugged program is by using rarun2 profile files:

$ r2 -R profile.rr2 -d program
$ cat profile.rr2
#!/usr/bin/rarun2
arg1=foo
arg2=bar
  • -R [rarun2] specify rarun2 profile to load.

Upvotes: 12

Related Questions