Rarun2

Rarun2 is a tool allowing to setup a specified execution environment - redefine stdin/stdout, pipes, change the environment variables and other settings useful to craft the boundary conditions you need to run a binary for debugging.

  1. $ rarun2 -h
  2. Usage: rarun2 -v|-t|script.rr2 [directive ..]

It takes the text file in key=value format to specify the execution environment. Rarun2 can be used as both separate tool or as a part of radare2. To load the rarun2 profile in radare2 you need to use either -r to load the profile from file or -R to specify the directive from string.

The format of the profile is very simple. Note the most important keys - program and arg*

One of the most common usage cases - redirect the output of debugged program in radare2. For this you need to use stdio, stdout, stdin, input, and a couple similar keys.

Here is the basic profile example:

  1. program=/bin/ls
  2. arg1=/bin
  3. # arg2=hello
  4. # arg3="hello\nworld"
  5. # arg4=:048490184058104849
  6. # arg5=:!ragg2 -p n50 -d 10:0x8048123
  7. # arg6=@arg.txt
  8. # arg7=@300@ABCD # 300 chars filled with ABCD pattern
  9. # system=r2 -
  10. # aslr=no
  11. setenv=FOO=BAR
  12. # unsetenv=FOO
  13. # clearenv=true
  14. # envfile=environ.txt
  15. timeout=3
  16. # timeoutsig=SIGTERM # or 15
  17. # connect=localhost:8080
  18. # listen=8080
  19. # pty=false
  20. # fork=true
  21. # bits=32
  22. # pid=0
  23. # pidfile=/tmp/foo.pid
  24. # #sleep=0
  25. # #maxfd=0
  26. # #execve=false
  27. # #maxproc=0
  28. # #maxstack=0
  29. # #core=false
  30. # #stdio=blah.txt
  31. # #stderr=foo.txt
  32. # stdout=foo.txt
  33. # stdin=input.txt # or !program to redirect input from another program
  34. # input=input.txt
  35. # chdir=/
  36. # chroot=/mnt/chroot
  37. # libpath=$PWD:/tmp/lib
  38. # r2preload=yes
  39. # preload=/lib/libfoo.so
  40. # setuid=2000
  41. # seteuid=2000
  42. # setgid=2001
  43. # setegid=2001
  44. # nice=5