Advertisement

04.06.2008 at 03:28AM PDT, ID: 23299307 | Points: 500
[x]
Attachment Details

Webserver with many domain names suffering http (D)DoS from spammer and I'm out of ideas

Tags: Linux, CentOS, 5, Webserver, apache, php5, MySQL
I have a dedicated server that I pay for yearly and up untill now a gig of RAM and a single processor seemed to be plenty. Sadly some **** with an overactive botnet and a need to spam the crap out of everything he/she/it sees via http is keeping my server in a state of utter uselessness.

Other specs that might be important CentOS 5, webmin 1.4, Apache2.2, MySQL+PHP5+etc, 1G RAM, 80G HDD (x2 in RAID array) (12G used), 2.66 GHz CeleronD (755)... all-in-all just a basic entry level dedi.

I have a MySQL connection limit of 150 as at 100 the MySQL server was running out of connections. This indicates that there must be over 100 connection in any given few seconds (I'm guessing) which gives a spam rate of at least ? 25+ hits a second? (I'm utterly guessing) going on for 3 days.

Given that most domains the server hosts contain blogs (and little else) it is likely to be trackback spam or comment spam. It is http I know that much.

When I use netstat or iptstate it of course resolves the target IP as the URL/domain of the server rather than the URL/domain of the attack. It does show me that a lot of proxies are being used to assault my server though.

I tried mod_evasive but even though I am quite sure it is set up correctly I can not get it react to anything. I also tried (D)Dos Deflate with fairly aggressive settings and that has done little if anything.

Short of setting a cron to restart apache every fifteen minutes it really does look like I need to identify the target and deactivate it.

I'm not exactly any expert at this but up until now there has not been an issue with a computer that I have ever been beaten by. So this is a bit of blow to my ego but at this stage (day 3) I figure that I'm just going to have to accept that I have lost a domain for the time being and "pull it" to return some sanity to the system.

Any ideas?
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: Matt_T_hat
Question Asked On: 04.06.2008
Participating Experts: 2
Points: 500
Views: 0
Translate:
Loading Advertisement...
04.06.2008 at 03:50AM PDT, ID: 21291373

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 04:40AM PDT, ID: 21291462

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 07:28AM PDT, ID: 21291849

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 05:22PM PDT, ID: 21293690

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.06.2008 at 09:45PM PDT, ID: 21294390

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.07.2008 at 12:56AM PDT, ID: 21294961

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.07.2008 at 02:34AM PDT, ID: 21295347

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.07.2008 at 02:53AM PDT, ID: 21295423

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.07.2008 at 03:52AM PDT, ID: 21295604

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.07.2008 at 05:18AM PDT, ID: 21296054

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.07.2008 at 11:24AM PDT, ID: 21299368

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.17.2008 at 02:57AM PDT, ID: 21375539

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.17.2008 at 04:27AM PDT, ID: 21375930

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.03.2008 at 12:48AM PDT, ID: 21491659

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.03.2008 at 10:14AM PDT, ID: 21493067

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
04.06.2008 at 03:50AM PDT, ID: 21291373
What is hurting me the most is the number of CLOSE_WAIT status apache child processes.
 
04.06.2008 at 04:40AM PDT, ID: 21291462
I've installed mod_security via yum (thanks to http://www.jasonlitka.com/ who's site and repository I just discovered).
 
04.06.2008 at 07:28AM PDT, ID: 21291849
Well, that mod_security was an error and no mistake (!) I've removed it again and have by a process of checking each site over found a blog with 30,000 comments in it.  I'm better all but 3 are spam as the site is not in use all that much and has a few hits a month.  (it's my wife's site).

I've disabled the commenting so hopefully the spammers will give up sooner or later.  But I still need to know how to locate the victim virtual host because there is bound to be a next time.  A good answer and I will find a way to give you extra points because I am serious about my need to get this issue addressed.
 
04.06.2008 at 05:22PM PDT, ID: 21293690

Rank: Guru

You might be able to use sysctl to change the timeout value for close_wait

     sysctl -w net.netfilter.nf_conntrack_tcp_timeout_close_wait=xx

the default it 60.  This will, may, reduce how long you have sockets in closed wait status.  You will need to set this after each re-boot. You can add to your /etc/sysctl.conf file.

You may also want to read:

http://www.windley.com/archives/2006/12/limit_simultaneous_connections_in_apache.shtml

It describes how to use a Apache mod to limit the number of connections from a single IP address.
 
04.06.2008 at 09:45PM PDT, ID: 21294390

Rank: Wizard

have you analysed your access and error log, does it show any illegal requests or other anomalies?
If so, there is a good chance to get rid of some with modsecurity.

Also set httpd.conf
  Timeout 5
  KeepAliveTimeout 2
which should reduce the amount of simutaneous connection in CLOSE_WAIT state.
 
04.07.2008 at 12:56AM PDT, ID: 21294961
giltjr, Thanks - I'll look into that.

ahoffmann, I found a single target of spam and added a script called bad_behaviour which monitors for badly formed http headers and know bad bots.  It rejected two calls inside the time for the plugin install and me to navigate to the admin page of that plugin.

I tried mod_security but the yum repository it recommends worked but caused a bunch of error messages when I restarted apache.  I'm not too keen to be that near to the bleeding edge on what is supposed to be my production server so I pulled it back off.  There were some build it yourself instructions on the mod_security website but I found them a bit overwhelming and not 100% clear.

I installed mod_evasive and had to get the apache whatnot something or the other ...xs installed (even though the mod it ships with was compiled in...) and I managed to set it up all on my own (I'm a big boy now) so it's not that my system intimidates me.  Sadly mod_evasive was useless and could not even evade it's own uselessness.  It failed the test it ships with.
 
04.07.2008 at 02:34AM PDT, ID: 21295347
Like an onion each layer is helping keep things going.  I just added mod_limitipconn and set a max of one conn to the action.php file (which the blogs on the domains use for comments, trackbacks and most other user interaction) to just a single connection per IP.  While this has stemmed the flow and kept things from dieing it has not licked it totally.  

Thanks giltjr.  I'm going to look at tweaking the CLOSE_WAIT and will report back.
 
04.07.2008 at 02:53AM PDT, ID: 21295423
I have now also made the following changes:

Was: Timeout 120
Now: Timeout 5
Was: KeepAlive Off
Now: KeepAlive On
Was: KeepAliveTimeout 10
Now: KeepAliveTimeout 5

I am figureing that as MOD_Evasive keeps data in the child that turnign this on will enhance things and allow evasive to do it's thang... ?  Would I be right?
 
04.07.2008 at 03:52AM PDT, ID: 21295604
Sigh... things were good for a while but now it is killing the MySQL server...
 
04.07.2008 at 05:18AM PDT, ID: 21296054

Rank: Wizard

> .. but now it is killing the MySQL server..
probably you should use some connection pooling (sorry, don't know of a PHP module for this)

> .. mod_security website but I found them a bit overwhelming ..
modsecurity is nothing to do plug&play, click&go. modsecurity is -as it name imples- security, and security is a process not a product. Said this, you need to get used to modsecurity and how it works, then you can do your basic configuration. After that you probably want to install the core rule set and continue to improve your setting.
As you're using PHP, modsecurity should be a first step to make your (PHP)web application a bit more stable (as PHP apps are known to have lot of vulerabilities, usually).
 
04.07.2008 at 11:24AM PDT, ID: 21299368

Rank: Guru

I have never used MOD_Evasive, so I am not sure.  I am just reading up on it.

Did you use the default settings for MOD_Evasive?
 
04.17.2008 at 02:57AM PDT, ID: 21375539
Hello,

Thanks for all the feed back.

I installed a script called bad-behaviour which is written in php.  I placed to instances on what seemed to be the hardest hit areas.  The load average dropped right back.

Also while checking my settings I noticed that keep alive was disabled so I enabled it thus allowing mod_evasive to kick in and work (it maintains it's information in the active thread)?  It now puts a temporary block on 30 to 40 IP addresses every day.

As for mod_security I've yet to install it and have it not cripple apache and stop it loading.  I'm no wizard at the advanced shell usage and only know about the methods I have used before.  As no YUM package (that works) exists I'm beaten before I start but I seem to have the problem licked with php.

> PHP apps are known to have lot of vulerabilities, usually
That's quite a broad generalization and somewhat true - most tutorials teach shocking bad habits and php is sufficiently flexible to allow you to create the most amazing vulnerabilities if you don't know what you are doing. I only run tried and tested apps or stuff I've written myself.  I have a good collection of tools that I build from designed to make the development process secure and easy to debug.

The problem was that one or more spammers were hitting two or more blogs with a massive array of junk comments.  The anti-spam methods were stopping almost all of them (aside from one blog where they had not been activated (but are now)) the problem was that by the time the anti-spam plug-ins were doing their thing the entire app had loaded and made several calls to the MySQL server and at the rate they were hitting me this killed the server.  

If I really had that much real interest I'd be bigger than digg or slashdot and would probably have a team of people and lots of servers... sadly I'm not that big.

Fortunately bad-behaviour runs before anything else and returns a simple HTTP error code and a human readable explanation of why they were blocked.  I managed to trigger it myself when using a Firefox addon that gives you a different user agent - the script spotted that I was not really Google (who I was pretending to be) and stopped me there and then.

As far as I can tell the server is still hammered day and night but now it fails to hurt things.

So how do I install mod_security - I don't suppose you could baby step me through it - I'll be using PuTTY and the shell will be BASH?
 
04.17.2008 at 04:27AM PDT, ID: 21375930

Rank: Wizard

> how do I install mod_security
install ModSecurity 2.x, then get the core rule set and install it also
This is straight forward as described in the README/INSTALL files.
I'd recommend to have all rules files in a single directory, then include these files in httpd.conf like
  include rules/*.conf
(this make some changes more comfortable later)

When you get the core rule set, edit modsecurity_crs_10_config.conf and set
  SecRuleEngine DetectionOnly
  SecAuditLogType Serial
  SecAuditLog logs/modsec_audit.log
  SecDebugLog             logs/modsec_debug.log
  SecDebugLogLevel        3

then restart apache.
Browse your application(s) and watch the logfiles (as defined above). Most likely you get some messages that request are blocked for various reasons. Each such message contains the ID of the rule which caused the blocking.
You have to analyse the request and the rule to identify if the blocking was legal or a false positive. When you come to the conclusion that it is a false positive, then create a new rules file and add

  SecRuleRemoveByID --id here--

Let me know if you need help here, then I'll give more detailed instructions.
 
05.03.2008 at 12:48AM PDT, ID: 21491659
ahoffmann - thanks for getting back to me.  Don't forget that I'm doing this by PuTTY so the instruction "install it by installing it (read the text file)" has not got me anywhere.  Where do I obtain the text file from? where do I get the package from?  How do I get it onto my server?

I am the sort of person to RTFM yet I have no idea where to start.  I'm still several skipped stage behind you looking at a black screen with a flashing cursor and a small amount of text telling me that I am now root.

More importantly to me do I actually need Mod_Security?  The PHP based Bad Behaviour seems more than able to mitigate all attacks currently.  I am of the school of thought that suggests that if it is not broken one does not fix it.  Therefore I need to know if there is any benefit in my actions specifically compare to the very real chance that I will cause my web services to stop running (as the last time I tried to install the aforementioned package).

I hope I don't seem too rude - I'm just trying to understand things better.
 
05.03.2008 at 10:14AM PDT, ID: 21493067

Rank: Wizard


http://www.modsecurity.org/
http://www.modsecurity.org/download/
http://www.modsecurity.org/projects/modsecurity/apache/index.html
http://www.modsecurity.org/projects/rules/index.html

> .. do I actually need Mod_Security?
hmm, that's the wuestion you need to answer yourself :)

> The PHP based Bad Behaviour seems more than able to mitigate all attacks currently.
I've not yet seen any PHP solution which free of vulnerabilities ;-)
If you really want to use PHP, you better protect your server and applications with something more reliable.

> .. if it is not broken one does not fix it.
you meen "never touch a running system"? Well if ther is nothing to protect, and there is nothing lost if somene breaks into your server, controls the server, use it for attacking others, or whatever ..., then ther is no need to protect anything.

> I hope I don't seem too rude
no (and be sure you read my comments including the smileys)
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628