Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php session_start(); set_time_limit(0); if (!isset($_SESSION['loggedin'])) { i..
Decoded Output download
<?php
session_start();
set_time_limit(0);
if (!isset($_SESSION['loggedin'])) {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
if ($_POST['password'] === 'your_password') { // Cambia 'your_password' por tu contrasea
$_SESSION['loggedin'] = true;
} else {
echo "Contrasea incorrecta.";
}
} else {
echo '<form method="POST"><input type="password" name="password"><input type="submit" value="Login"></form>';
exit;
}
}
// Funcin para validar rutas de archivos
function isValidPath($path) {
$realBase = realpath(__DIR__);
$realUserPath = realpath($path);
return ($realUserPath && strpos($realUserPath, $realBase) === 0);
}
// Funcin para obtener permisos de archivo
function perms($file) {
$perms = fileperms($file);
$info = '';
if (($perms & 0xC000) == 0xC000) {
$info = 's'; // Socket
} elseif (($perms & 0xA000) == 0xA000) {
$info = 'l'; // Enlace simblico
} elseif (($perms & 0x8000) == 0x8000) {
$info = '-'; // Archivo regular
} elseif (($perms & 0x6000) == 0x6000) {
$info = 'b'; // Especial de bloque
} elseif (($perms & 0x4000) == 0x4000) {
$info = 'd'; // Directorio
} elseif (($perms & 0x2000) == 0x2000) {
$info = 'c'; // Especial de carcter
} elseif (($perms & 0x1000) == 0x1000) {
$info = 'p'; // Tubera con nombre (FIFO)
} else {
$info = 'u'; // Desconocido
}
// Propietario
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
// Grupo
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
// Mundo
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
return $info;
}
echo '<!DOCTYPE HTML>
<HTML>
<HEAD>
<title>File Manager</title>
<style>
body {
font-family: monospace;
font-weight: bold;
font-size: 18px;
background-color: #c5c5c5;
color: #000;
}
#content tr:hover {
background-color: #ccc;
}
#content .first {
background-color: #ccc;
}
#content .first:hover {
background-color: #ccc;
}
table {
border: 3px #000 solid;
}
a {
color: #000;
text-decoration: none;
}
a:hover {
color: #00f;
}
input, select, textarea {
border: 1px #000 solid;
border-radius: 5px;
}
input {
font-size: 18px;
font-weight: bold;
padding: 5px;
}
select {
font-size: 19px;
}
textarea {
font-size: 10px;
}
td, tr {
padding: 2px 5px;
}
</style>
</HEAD>
<BODY>
<hr width="920" color="black"/>
<hr width="920" color="black"/>
<center><p><h2>Your IP: ' . htmlspecialchars($_SERVER["REMOTE_ADDR"]) . '</h2></p></center>
<hr width="920" color="black"/>
<table width="920" border="1px" cellpadding="7" cellspacing="0" align="center">
<tr><td style="padding: 8px">Current Path: ';
$path = isset($_GET['path']) ? filter_var($_GET['path'], FILTER_SANITIZE_STRING) : getcwd();
$path = str_replace('\', '/', $path);
$paths = explode('/', $path);
foreach ($paths as $id => $pat) {
if ($pat == '' && $id == 0) {
echo '<a href="?path=/">/</a>';
continue;
}
if ($pat == '') continue;
echo '<a href="?path=';
for ($i = 0; $i <= $id; $i++) {
echo htmlspecialchars($paths[$i]);
if ($i != $id) echo "/";
}
echo '">' . htmlspecialchars($pat) . '</a>/';
}
echo '</td></tr><tr><td>';
if (isset($_FILES['file'])) {
$allowed_types = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'text/plain']; // Especifica los tipos de archivo permitidos
if (isValidPath($path)) {
$uploadFile = $path . '/' . basename($_FILES['file']['name']);
if (in_array($_FILES['file']['type'], $allowed_types)) {
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
echo "Archivo subido exitosamente.";
} else {
echo "Error al subir el archivo.";
}
} else {
echo "Tipo de archivo no permitido.";
}
} else {
echo "Ruta invlida.";
}
}
if (isset($_GET['file'])) {
$file = filter_var($_GET['file'], FILTER_SANITIZE_STRING);
$filePath = realpath($file);
if (isValidPath($filePath)) {
if (unlink($filePath)) {
echo "Archivo eliminado exitosamente.";
} else {
echo "Error al eliminar el archivo.";
}
} else {
echo "Ruta de archivo invlida.";
}
}
echo '</td></tr><tr><td>';
if (isValidPath($path)) {
$dir = opendir($path);
echo '<table id="content" width="100%" border="1px" cellpadding="3" cellspacing="0">
<tr class="first">
<td>Nombre</td><td>Tamao</td><td>Permisos</td><td>Opciones</td>
</tr>';
while (($file = readdir($dir)) !== false) {
if ($file == '.' || $file == '..') continue;
$filePath = $path . '/' . $file;
echo '<tr><td>';
if (is_dir($filePath)) {
echo '<a href="?path=' . htmlspecialchars($filePath) . '">' . htmlspecialchars($file) . '</a>';
} else {
echo htmlspecialchars($file);
}
echo '</td><td>' . filesize($filePath) . '</td><td>' . perms($filePath) . '</td><td>';
if (!is_dir($filePath)) {
echo '<a href="?file=' . htmlspecialchars($filePath) . '">Eliminar</a>';
}
echo '</td></tr>';
}
closedir($dir);
echo '</table>';
} else {
echo "Directorio invlido.";
}
echo '</td></tr></table>';
echo '<hr width="920" color="black"/>
<form enctype="multipart/form-data" action="" method="POST">
<input type="file" name="file" />
<input type="submit" value
?>
Did this file decode correctly?
Original Code
<?php
session_start();
set_time_limit(0);
if (!isset($_SESSION['loggedin'])) {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
if ($_POST['password'] === 'your_password') { // Cambia 'your_password' por tu contrasea
$_SESSION['loggedin'] = true;
} else {
echo "Contrasea incorrecta.";
}
} else {
echo '<form method="POST"><input type="password" name="password"><input type="submit" value="Login"></form>';
exit;
}
}
// Funcin para validar rutas de archivos
function isValidPath($path) {
$realBase = realpath(__DIR__);
$realUserPath = realpath($path);
return ($realUserPath && strpos($realUserPath, $realBase) === 0);
}
// Funcin para obtener permisos de archivo
function perms($file) {
$perms = fileperms($file);
$info = '';
if (($perms & 0xC000) == 0xC000) {
$info = 's'; // Socket
} elseif (($perms & 0xA000) == 0xA000) {
$info = 'l'; // Enlace simblico
} elseif (($perms & 0x8000) == 0x8000) {
$info = '-'; // Archivo regular
} elseif (($perms & 0x6000) == 0x6000) {
$info = 'b'; // Especial de bloque
} elseif (($perms & 0x4000) == 0x4000) {
$info = 'd'; // Directorio
} elseif (($perms & 0x2000) == 0x2000) {
$info = 'c'; // Especial de carcter
} elseif (($perms & 0x1000) == 0x1000) {
$info = 'p'; // Tubera con nombre (FIFO)
} else {
$info = 'u'; // Desconocido
}
// Propietario
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x' ) : (($perms & 0x0800) ? 'S' : '-'));
// Grupo
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x' ) : (($perms & 0x0400) ? 'S' : '-'));
// Mundo
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x' ) : (($perms & 0x0200) ? 'T' : '-'));
return $info;
}
echo '<!DOCTYPE HTML>
<HTML>
<HEAD>
<title>File Manager</title>
<style>
body {
font-family: monospace;
font-weight: bold;
font-size: 18px;
background-color: #c5c5c5;
color: #000;
}
#content tr:hover {
background-color: #ccc;
}
#content .first {
background-color: #ccc;
}
#content .first:hover {
background-color: #ccc;
}
table {
border: 3px #000 solid;
}
a {
color: #000;
text-decoration: none;
}
a:hover {
color: #00f;
}
input, select, textarea {
border: 1px #000 solid;
border-radius: 5px;
}
input {
font-size: 18px;
font-weight: bold;
padding: 5px;
}
select {
font-size: 19px;
}
textarea {
font-size: 10px;
}
td, tr {
padding: 2px 5px;
}
</style>
</HEAD>
<BODY>
<hr width="920" color="black"/>
<hr width="920" color="black"/>
<center><p><h2>Your IP: ' . htmlspecialchars($_SERVER["REMOTE_ADDR"]) . '</h2></p></center>
<hr width="920" color="black"/>
<table width="920" border="1px" cellpadding="7" cellspacing="0" align="center">
<tr><td style="padding: 8px">Current Path: ';
$path = isset($_GET['path']) ? filter_var($_GET['path'], FILTER_SANITIZE_STRING) : getcwd();
$path = str_replace('\\', '/', $path);
$paths = explode('/', $path);
foreach ($paths as $id => $pat) {
if ($pat == '' && $id == 0) {
echo '<a href="?path=/">/</a>';
continue;
}
if ($pat == '') continue;
echo '<a href="?path=';
for ($i = 0; $i <= $id; $i++) {
echo htmlspecialchars($paths[$i]);
if ($i != $id) echo "/";
}
echo '">' . htmlspecialchars($pat) . '</a>/';
}
echo '</td></tr><tr><td>';
if (isset($_FILES['file'])) {
$allowed_types = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'text/plain']; // Especifica los tipos de archivo permitidos
if (isValidPath($path)) {
$uploadFile = $path . '/' . basename($_FILES['file']['name']);
if (in_array($_FILES['file']['type'], $allowed_types)) {
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) {
echo "Archivo subido exitosamente.";
} else {
echo "Error al subir el archivo.";
}
} else {
echo "Tipo de archivo no permitido.";
}
} else {
echo "Ruta invlida.";
}
}
if (isset($_GET['file'])) {
$file = filter_var($_GET['file'], FILTER_SANITIZE_STRING);
$filePath = realpath($file);
if (isValidPath($filePath)) {
if (unlink($filePath)) {
echo "Archivo eliminado exitosamente.";
} else {
echo "Error al eliminar el archivo.";
}
} else {
echo "Ruta de archivo invlida.";
}
}
echo '</td></tr><tr><td>';
if (isValidPath($path)) {
$dir = opendir($path);
echo '<table id="content" width="100%" border="1px" cellpadding="3" cellspacing="0">
<tr class="first">
<td>Nombre</td><td>Tamao</td><td>Permisos</td><td>Opciones</td>
</tr>';
while (($file = readdir($dir)) !== false) {
if ($file == '.' || $file == '..') continue;
$filePath = $path . '/' . $file;
echo '<tr><td>';
if (is_dir($filePath)) {
echo '<a href="?path=' . htmlspecialchars($filePath) . '">' . htmlspecialchars($file) . '</a>';
} else {
echo htmlspecialchars($file);
}
echo '</td><td>' . filesize($filePath) . '</td><td>' . perms($filePath) . '</td><td>';
if (!is_dir($filePath)) {
echo '<a href="?file=' . htmlspecialchars($filePath) . '">Eliminar</a>';
}
echo '</td></tr>';
}
closedir($dir);
echo '</table>';
} else {
echo "Directorio invlido.";
}
echo '</td></tr></table>';
echo '<hr width="920" color="black"/>
<form enctype="multipart/form-data" action="" method="POST">
<input type="file" name="file" />
<input type="submit" value
Function Calls
None |
Stats
MD5 | 3760353cb099e6f7cde998f0bc7a044d |
Eval Count | 0 |
Decode Time | 52 ms |