1RARUN2(1) BSD General Commands Manual RARUN2(1)
2
4 rarun2 — radare2 utility to run programs in exotic environments
5
7 rarun2 [[directives]] [[script.rr2]] [[--] [program] [args]]
8
10 This program is used as a launcher for running programs with different
11 environment, arguments, permissions, directories and overridden default
12 file descriptors.
13
14 rarun2 -t will show the terminal name and wait for a connection from an‐
15 other process. try rarun2 stdio=<ttypath> program=/bin/sh
16
17 The program just accepts a single argument which is the filename of the
18 configuration file to run the program.
19
20 It is useful when you have to run a program using long arguments or pass
21 long data to stdin or things like that usually are required for exploit‐
22 ing crackmes :)
23
25 The rr2 (rarun2) configuration file accepts the following directives, de‐
26 scribed as key=value entries and comments defined as lines starting with
27 '#'.
28
29 arg[0-N] set value for argument N passed to the program
30
31 aslr enable or disable ASLR
32
33 bits set 32 or 64 bit (if the architecture supports it)
34
35 chdir change directory before executing the program
36
37 chroot run the program in chroot. requires some previous setup
38
39 clearenv unset the whole environment
40
41 core set no limit the core file size
42
43 times boolean value (true|false) to print runtime in milliseconds
44 to stderr after program execution
45
46 connect connect stdin/stdout/stderr to a socket
47
48 pty use a pty for connection over socket (with connect/listen)
49
50 envfile set a file with lines like `var=value` to be used as env
51
52 fork used with the listen option, allow to spawn a different
53 process for each connection. Ignored when debugging.
54
55 input set string to be passed to the program via stdin
56
57 libpath override path where the dynamic loader will look for shared
58 libraries
59
60 listen bound stdin/stdout/stderr to a listening socket
61
62 maxstack set the maximum size for the stack
63
64 maxproc set the maximum number of processes
65
66 maxfd set the maximum number of file descriptors
67
68 nice set the niceness level of the process
69
70 preload preload a library (not supported on Windows, only
71 linux,osx,bsd)
72
73 daemon Set to false by default, otherwise it will run the program in
74 background, detached from the terminal.
75
76 program path to program to be executed
77
78 execve use execve instead of posix_spawn (osx tricks)
79
80 runlib path to the library to be executed
81
82 runlib.fcn function name to call from runlib library
83
84 r2preload preload with libr2, kill -USR1 to get an r2 shell or -USR2 to
85 spawn a webserver in a thread
86
87 r2preweb run the webserver in a thread just at starting the r2preload
88
89 setenv set value for given environment variable
90
91 setegid set effective process group id
92
93 seteuid set effective process uid
94
95 setgid set process group id
96
97 setuid set process uid
98
99 sleep sleep for the given amount of seconds
100
101 stdin select file to read data from stdin
102
103 stdout select file to replace stdout file descriptor
104
105 system execute the given command
106
107 timeout set a timeout
108
109 timeoutsig signal to use when killing the child because the timeout hap‐
110 pens
111
112 unsetenv unset one environment variable
113
115 Every value in this configuration file can contain a special
116
117 @filename Slurp contents of file and put them inside the key
118
119 text Escape characters useful for hex chars
120
121 'string' Escape characters useful for hex chars
122
123 !cmd Run command to store the output in the variable
124
125 :102030 Parse hexpair string and store it in the variable
126
127 :!cmd Parse hexpair string from output of command and store it in
128 the variable
129
130 %1234 Parses the input string and returns it as integer
131
133 Sample rarun2 script
134
135 $ cat foo.rr2
136 #!/usr/bin/rarun2
137 program=./pp400
138 arg0=10
139 stdin=foo.txt
140 chdir=/tmp
141 clearenv=true
142 setenv=EGG=eggsy
143 setenv=NOFUN=nogames
144 unsetenv=NOFUN
145 # EGG will be the only env variable
146 #chroot=.
147 ./foo.rr2
148
149 Connecting a program to a socket
150
151 $ nc -l 9999
152 $ rarun2 program=/bin/ls connect=localhost:9999
153
154 Debugging a program redirecting IO to another terminal
155
156 ## open a new terminal and type 'tty' to get
157 $ tty ; clear ; sleep 999999
158 /dev/ttyS010
159 ## in another terminal run r2
160 $ r2 -r foo.rr2 -d ls
161 $ cat foo.rr2
162 #!/usr/bin/rarun2
163 stdio=/dev/ttys010
164 ## Or you can use -R to set a key=value
165 r2 -R stdio=/dev/ttys010 -d ls
166
167 You can also use the -- flag to specify program and arguments in a more
168 natural way:
169
170 $ rarun2 timeout=2 -- sleep 4
171
172 Run a library function
173
174 $ rarun2 runlib=/lib/libc-2.25.so runlib.fcn=system arg1="ls /"
175
177 radare2(1)
178
180 Written by pancake <pancake@nopcode.org>
181
182 Feb 3, 2017