.Dd Jan 24, 2024 .Dt RZ_RUN 1 .Sh NAME .Nm rz-run .Nd rizin utility to run programs in custom environments .Sh SYNOPSIS .Nm rz-run .Op [directives] .Op [script.rz] .Op [--] [program] [args] .Sh DESCRIPTION This command is part of the Rizin project. .Pp This program is used as a launcher for running programs with different environment, arguments, permissions, directories and overridden default filedescriptors. .Pp .Bl -tag -width Fl .It Fl l List all the supported profile options. .Pp .It Fl t Output a base template profile. Try rz-run -d > profile.rz .Pp .It Fl w Show the terminal name and wait for a connection from another process. Try rz-run stdio= program=/bin/sh .El .Pp The program just accepts a single argument which is the filename of the configuration file to run the program. .Pp It is useful when you have to run a program using long arguments or pass long data to stdin or things like that usually required for exploiting crackmes :) .Sh DIRECTIVES .Pp The rrz (rz-run) configuration file accepts the following directives, described as key=value entries and comments defined as lines starting with '#'. .Bl -tag -width Fl .It Ar arg[0-511] Set value for argument N passed to the program .It Ar aslr Enable or disable ASLR .It Ar bits Set 32 or 64 bit (if the architecture supports it) .It Ar chdir Change directory before executing the program .It Ar chroot Run the program in chroot. requires some previous setup .It Ar core Set no limit the core file size .It Ar connect Connect stdin/stdout/stderr to a socket .It Ar pty Use a pty for connection over socket (with connect/listen) .It Ar envfile Set a file with lines like `var=value` to be used as env .It Ar fork Used with the listen option, allow to spawn a different process for each connection. Ignored when debugging. .It Ar input Set string to be passed to the program via stdin .It Ar libpath Override path where the dynamic loader will look for shared libraries .It Ar listen Bound stdin/stdout/stderr to a listening socket .It Ar maxstack Set the maximum size for the stack .It Ar maxproc Set the maximum number of processes .It Ar maxfd Set the maximum number of file descriptors .It Ar nice Set the niceness level of the process .It Ar preload Preload a library (not supported on Windows, only linux,osx,bsd) .It Ar daemon Set to false by default, otherwise it will run the program in background, detached from the terminal. .It Ar program Path to program to be executed .It Ar pid Set to true to print the PID of the process to stderr .It Ar pidfile Print the PID of the process to the specified file .It Ar runlib Path to the library to be executed .It Ar runlib.fcn Function name to call from runlib library .It Ar rzpreload Preload with librz, kill -USR1 to get an rizin shell or -USRZ to spawn a webserver in a thread .It Ar setenv Set value for given environment variable .It Ar setegid Set effective process group id .It Ar seteuid Set effective process uid .It Ar setgid Set process group id .It Ar setuid Set process uid .It Ar sleep Sleep for the given amount of seconds .It Ar stdio=value Set io streams (stdin, stdout, stderr) to a value .It Ar stdio=!cmd Redirect input/output to the process created by the specified command .It Ar stdin Set stdin, stdout, and stderr streams to the specified value .It Ar stdout Select file to replace stdout file descriptor .It Ar stderr Select file to replace stderr file descriptor .It Ar system Execute the given command .It Ar timeout Set a timeout .It Ar timeoutsig Signal to use when killing the child because the timeout happens .It Ar unsetenv Unset one environment variable .El .Sh VALUE PREFIXES Every value in this configuration file can contain a special .Pp .Bl -tag -width Fl .It Ar @filename Slurp contents of file and put them inside the key .It Ar "text" Escape characters useful for hex chars .It Ar 'string' Escape characters useful for hex chars .It Ar !cmd Run command to store the output in the variable .It Ar :102030 Parse hexpair string and store it in the variable .It Ar :!cmd Parse hexpair string from output of command and store it in the variable .It Ar %1234 Parses the input string and returns it as integer .El .Sh EXAMPLES Sample rz-run script .Pp $ cat foo.rrz #!/usr/bin/rz-run program=./pp400 arg0=10 stdin=foo.txt chdir=/tmp clearenv=true setenv=EGG=eggsy setenv=NOFUN=nogames unsetenv=NOFUN # EGG will be the only env variable #chroot=. ./foo.rrz .Pp Connecting a program to a socket .Pp .Nm nc Fl l Cm 9999 .Pp .Nm rz-run Cm program=/bin/ls Cm connect=localhost:9999 .Pp Debugging a program redirecting io to another terminal .Pp ## open a new terminal and type 'tty' to get $ tty ; clear ; sleep 999999 /dev/ttyS010 ## in another terminal run rizin $ rizin \-r foo.rrz -d ls $ cat foo.rrz #!/usr/bin/rz-run stdio=/dev/ttys010 ## Or you can use -R to set a key=value rizin \-R stdio=/dev/ttys010 -d ls .Pp You can also use the -- flag to specify program and arguments in a more natural way: .Pp .Nm rz-run Cm timeout=2 Ar -- sleep 4 .Pp Run a library function .Pp .Nm rz-run Cm runlib=/lib/libc-2.25.so Cm runlib.fcn=system Cm arg1="ls /" .Sh SEE ALSO .Pp .Xr rizin(1) , .Xr rz-hash(1) , .Xr rz-find(1) , .Xr rz-bin(1) , .Xr rz-diff(1) , .Xr rz-gg(1) , .Xr rz-asm(1) , .Sh AUTHORS .Pp pancake .Pp byteninjaa0