LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-09-2010, 03:55 AM   #1
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Rep: Reputation: 22
How to use .htaccess to redirect Chinese hacking attempts?


My server (CentOS 5.4) is being bombarded 24x7 with IP addresses from China trying to exploit phpMyAdmin. For every one I block on the firewall, half a dozen come to the funeral! It's a pity these morons don't have something better to occupy their time. I'm getting page after page of this (see below) every day and it's been going on for weeks. I don't even have phpMyAdmin on the server. I don't use it and I deleted it.

I've read that you can use .htaccess and / or mod_rewrite to redirect / block them based on any query for phpMyAdmin (they try all letters in upper and lower case, leading to page after page). Unfortunately, I have no idea of how to do this. I already have an .htaccess file. Maybe someone can suggest what to add to stop these pests from wasting my bandwidth and suggest somewhere I could redirect them to to cause them maximum problems. I don't want to block the entire country, seems a bit like overkill, not all Chinese are morons. we aren't even in the USA, so why they are doing this is beyond me.

A TINY sample!
[Sun Aug 08 13:29:08 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.2
[Sun Aug 08 13:29:08 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.3
[Sun Aug 08 13:29:08 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.4
[Sun Aug 08 13:29:09 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.5
[Sun Aug 08 13:29:09 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.6
[Sun Aug 08 13:29:09 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.7
[Sun Aug 08 13:29:10 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.8
[Sun Aug 08 13:29:10 2010] [error] [client 61.191.41.53] File does not exist: /var/www/corp/phpMyAdmin-2.7.9
 
Old 08-09-2010, 04:20 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You can use:
Code:
RewriteEngine On

RewriteCond %{REQUEST_URI} ^/phpmyadmin [NC,OR]
RewriteCond %{REQUEST_URI} ^/pma [NC]
RewriteRule (.*) - [F]
The 2nd condition is because from what I see in my logs, these bots are also looking for /PMA
 
1 members found this post helpful.
Old 08-09-2010, 05:45 AM   #3
chiragrk
Member
 
Registered: Nov 2009
Location: India
Distribution: Xandros, Ubuntu
Posts: 74

Rep: Reputation: 16
I had a similar problem with SSH attempts to my server. I used a tool called DenyHosts to get past this. I blogged the howto here: http://technologyrnd.blogspot.com/20...s-attacks.html
 
0 members found this post helpful.
Old 08-09-2010, 10:12 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
+1 for rewriting (or using mod_security?).
-1 for using DenyHosts (in the default setup). See why.


Quote:
Originally Posted by baldur2630 View Post
Maybe someone can suggest what to add to stop these pests from wasting my bandwidth and suggest somewhere I could redirect them to to cause them maximum problems.
Sure you may be pissed of but that's not the way to handle things.
 
1 members found this post helpful.
Old 08-10-2010, 12:02 AM   #5
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 22
I'm already using Denyhosts for SSH, but I only use SSH on rare occasions so most of the time the Port isn't open. I use a Smoothwall Express Firewall as well as IPTables.

I've put Bathory's offering into my .htaccess file. I'll check over the next day or two and let you know if it works, but it looks good.

Pissed off isn't a word I would use, I passed that already a few weeks ago. If I had MY way, it would be the death penalty for spammers and these spotty-faced morons with nothing better to do than try to deface other people's work.
 
Old 08-10-2010, 10:28 AM   #6
unixfool
Member
 
Registered: May 2005
Location: Northern VA
Distribution: Slackware, Ubuntu, FreeBSD, OpenBSD, OS X
Posts: 782
Blog Entries: 8

Rep: Reputation: 158Reputation: 158
IMO, the best tool for the job would be modsecurity (or any other IPS-like application).

And, no matter how you look at it, you're going to be wasting bandwidth...blocking is about the only thing you can do. Such traffic nowadays doesn't really constitute a huge waste issue, not when talking about web servers and the traffic they typically handle.
 
Old 08-11-2010, 04:04 PM   #7
baldur2630
Member
 
Registered: Jan 2007
Location: Belgium
Distribution: CentOS & Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 22
I tried Bathory's additions to my .htaccess file. It didn't work. Attacks and error messages are still the same.

Seems like it may have to be mod_security. What exactly must I put into the .conf file. I assume that then I can take out the lines from .htaccess.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache htaccess redirect Jorkim Kustafin Linux - Server 2 07-23-2009 12:32 PM
Determine IP address blocks owned an ISP to stop hacking attempts TigerOC Linux - Security 5 09-09-2006 03:52 PM
htaccess 'redirect permanent' failing mikeindo Linux - Networking 0 07-07-2005 01:05 AM
Htaccess with a redirect Diode Linux - Networking 0 10-28-2003 06:23 PM
Tools to trick hacking attempts? LionKing Linux - Security 5 07-01-2001 02:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration