Solved

I was hacked - apache -webhosting

Posted on 2010-08-18
15
1,399 Views
Last Modified: 2012-05-10
Hi,

I have all websites on my server redirected to nonsense IP address.

1. It is not dns, since I have my clients on different registrars
2. it is not mysql because even simple pages are redirected
3. dns ping from my domains give me correct = my IP address

Heeeelp, please urgently or I am dead.
0
Comment
Question by:jbmd
15 Comments
 
LVL 7

Accepted Solution

by:
Milind Koyande earned 250 total points
ID: 33462036
Hello,

I would suggest you to check you website pages as it might possible that someone injected malicious scripts in them. Also scan your server for viruses or any backdoor.
0
 

Author Comment

by:jbmd
ID: 33462066
I checked my folders in my Inetpub  and noticed that all folders have the fresh date 18 August 2: and so.
0
 

Author Comment

by:jbmd
ID: 33462080
I am finding this file: .htaccess with this inside:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)? http://musikkorps.com/mainfile.php

the file is in apache, am searching for more
0
 

Author Comment

by:jbmd
ID: 33462100
this file is everywhere in my inetpub folders. i am removing it but how can I prevent it for the next time?
0
 

Author Comment

by:jbmd
ID: 33462131
QUESTION: since it is endless amount of this file spread in my inetpub directory, what is the crucial location, i.e. where should I go first to remove it so as the websites will function again?
0
 

Author Comment

by:jbmd
ID: 33462229
Ok, the answer is to remove it from the www root.

ANOTHER QUESTION:
is there a php script available I can use to dele htaccess files from todays date in one step?
0
 
LVL 3

Expert Comment

by:captainmish
ID: 33462542
To prevent this particular attack happening again, the easy fix is to add " AllowOverride None" to your apache config, this will prevent apache from using .htaccess files. If you do not use .htaccess files anywhere and want to delete them, you could just use a bash script to remove any (though it would be better to have all directories as read only for the apache user):

# find and remove all .htaccess files under /var/www
find /var/www/ -name '.htaccess' -exec rm {} \;

To make your directories read only, you could chmod ugo-w {directory} (add -r to make it recursive and change all directories). Some apps will need a few directories to be writeable, eg for cache, uploads etc, so be careful when changing directory permissions.

Have a look at http://httpd.apache.org/docs/current/misc/security_tips.html for some other good security tips.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:jbmd
ID: 33462586
unfurtonately I use Joomla with SEF-URL for almost all my clients, so .httaccess is inevitable.
0
 

Author Comment

by:jbmd
ID: 33462672
I have windows OS, so what is a shell command for removing .httaccess from inetpub?
0
 
LVL 3

Expert Comment

by:csalaski
ID: 33462683
Have you checked Joomla and any of the makers of the plugins for patches to address security issues?
0
 
LVL 3

Expert Comment

by:captainmish
ID: 33462794
On windows you could make a batch file that runs

cd \your\web\root <- replace with inetpub or your webroot path
del /S .htaccess

This will recursively delete all .htaccess files (I have not tested this as I dont have a windows computer to play with, so try it first where it wont destroy things!). You could then add this as a scheduled task to run every day/hour etc
0
 
LVL 3

Assisted Solution

by:captainmish
captainmish earned 250 total points
ID: 33462806
You could write the htaccess stuff into the virtual host configurations for apache, instead of using htaccess files, it sounds like these may have been overwritten anyway, so it may be time for restoring your backups. Another way around it would be to restore the .htaccess files, then use windows file permissions to remove write access to them. If you cannot avoid htaccess files, restore and permission is the only way I can think of to get around this.
0
 

Author Comment

by:jbmd
ID: 33463682
csalaski: -> it happened also on freshly installed joomla
0
 

Author Comment

by:jbmd
ID: 33463729
is there a way how to forbid overwritting .httaccess in general config of apache?
(I have windows).

I do not want to do it od windows folder level manualy since I have a lot of files.
0
 
LVL 3

Assisted Solution

by:captainmish
captainmish earned 250 total points
ID: 33463909
Not sure about a way to make htaccess read only at apache level, and it probably wont help as the exploit will have used a shell escape (file system level) to write to those files. You could just do a windows search for .htaccess starting at the inetpub level, select all, and make read only?
0

Featured Post

Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now