Solved

I was hacked - apache -webhosting

Posted on 2010-08-18
15
1,398 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

744 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

15 Experts available now in Live!

Get 1:1 Help Now