How to find and kill Abusers on OpenVZ Linux hosted Virtual Machines (Few bash scripts to protect OpenVZ CentOS server from script kiddies and easify the daily admin job)

Friday, 22nd July 2011

OpenVZ Logo - Anti Denial Of Service shell scripts

These days, I’m managing a number of OpenVZ Virtual Machine host servers. Therefore constantly I’m facing a lot of problems with users who run shit scripts inside their Linux Virtual Machines.

Commonly user Virtual Servers are used as a launchpad to attack hosts do illegal hacking activities or simply DDoS a host..
The virtual machines users (which by the way run on top of the CentOS OpenVZ Linux) are used to launch a Denial service scripts like kaiten.pl, trinoo, shaft, tfn etc.

As a consequence of their malicious activities, oftenly the Data Centers which colocates the servers are either null routing our server IPs until we suspend the Abusive users, or the servers go simply down because of a server overload or a kernel bug hit as a result of the heavy TCP/IP network traffic or CPU/mem overhead.

Therefore to mitigate this abusive attacks, I’ve written few bash shell scripts which, saves us a lot of manual check ups and prevents in most cases abusers to run the common DoS and “hacking” script shits which are now in the wild.

The first script I’ve written is kill_abusers.sh , what the script does is to automatically look up for a number of listed processes and kills them while logging in /var/log/abusers.log about the abusive VM user procs names killed.

I’ve set this script to run 4 times an hour and it currently saves us a lot of nerves and useless ticket communication with Data Centers (DCs), not to mention that reboot requests (about hanged up servers) has reduced significantly.
Therefore though the scripts simplicity it in general makes the servers run a way more stable than before.

Here is OpenVZ kill/suspend Abusers procs script kill_abusers.sh ready for download

Another script which later on, I’ve written is doing something similar and still different, it does scan the server hard disk using locate and find commands and tries to identify users which has script kiddies programs in their Virtual machines and therefore are most probably crackers.
The scripts looks up for abusive network scanners, DoS scripts, metasploit framework, ircds etc.

After it registers through scanning the server hdd, it lists only files which are preliminary set in the script to be dangerous, and therefore there execution inside the user VM should not be.

search_for_abusers.sh then logs in a files it’s activity as well as the OpenVZ virtual machines user IDs who owns hack related files. Right after it uses nail mailing command to send email to a specified admin email and reports the possible abusers whose VM accounts might need to either be deleted or suspended.

search_for_abusers can be download here

Honestly I truly liked my search_for_abusers.sh script as it became quite nice and I coded it quite quickly.
I’m intending now to put the Search for abusers script on a cronjob on the servers to check periodically and report the IDs of OpenVZ VM Users which are trying illegal activities on the servers.

I guess now our beloved Virtual Machine user script kiddies are in a real trouble ;P
 

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

29 Responses to “How to find and kill Abusers on OpenVZ Linux hosted Virtual Machines (Few bash scripts to protect OpenVZ CentOS server from script kiddies and easify the daily admin job)”

  1. Josh says:

    Thankyou for these scripts, I have installed them and ran them to test, and they do what they are suppose to do!

    🙂

  2. Josh says:

    I ran them and it listed the clients that should be suspended, what is IRCd, idnt it a chat client?

    • admin says:

      Heya Josh,

      IRCd is a chat (irc) server.
      You might not need it to be in the list of processes to be killed, in my case I thought it’s better if it’s there since. Sometimes people who are devoted to irc get in quarrels and their services might later be a target of DoS.

  3. Josh says:

    Thanks for the description.

    🙂

    • admin says:

      Two more processes which is good to enter the scripts list of abusive processes are:

      ‘pscan2 SpyEyeCollector’
      My current PROCS file variable, looks like so:

      PROCS=’ircd kaiten dos.pl exploit msfconsole ddos tfn-child tfn-daemon trinoo slap.pl brute pscan2 SpyEyeCollector’;

      Best!
      Georgi
      🙂

  4. jack says:

    Any way to make one for cpanel server for dos.php ect?

    • admin says:

      Hi Jack,

      One can surely, be written. If you’re looking for someone to write you the script I can offer you my services for some fee?

      Best!
      Georgi

  5. Josh says:

    I use these scripts quite often, so thanks again ^___^

    However, the kill_abusers.sh script doesnt seem to work for me, tried two nodes it just goes blank :S

    • admin says:

      Hello Josh,

      The script works, I don’t know what you’re doing. Do you use the last version of the script. Previously I’ve by mistaken put online a version of the script which does echo the proccesses to kill instead of killing them, open the script and check your’re not using this old version.

      regards,
      Georgi

  6. Josh says:

    Hi there,

    I wget the latest one and it did the same :S

    Do you have teamviewer?

  7. Josh says:

    Care to take a look on my TV to see what could be the issue? :S

  8. Josh says:

    Oops, spoke to soon.

    Having issues with skype, can you add my MSN/AIM/Yahoo?

    support [at] Dotvps.net

    • admin says:

      I was travelling, now I’m very tired and probably soon go to sleep, I’ve added you in ICQ but you seen unavailable. Whenever I’m online you should add me as well. Then I’ll quickly take a look.

      Best!
      Georgi

  9. QuentinM says:

    Hello

    Thanks for that.
    We also often have a DDoS script named lool.

    Cheers.

  10. Mark says:

    How would i install this on centos

  11. Java Tomcat Hosting India says:

    So far ….so good great experience !!! Thanks!!!

  12. Victor says:

    How do I install this script? I need help please.

    My e-mail ; Victor@SpetsnazHost.com

Leave a Reply