Advertising
Is your server exploited (Part 2)

20.12.2011 - 07:26:40

 Quote
[*@ds*-*-*-* silent]$ /bin/bash -version
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.


awk, tcpdump,cat,iptables .. alles drin
Habe das skript von dem link von old-man heruntergeladen. Also nicht copy/paste.

Habe die Änderungen eingebaut, (mit kleiner Änderung)
 Code
1:
2:
3:
4:
5:
6:
 if [ "$COUNT" == "" ] ; then
COUNT=0
fi
if [ "$UNBCNT" == "" ] ; then
UNBCNT=0
fi


Das skript - scheint nun zu funktionieren, jedenfalls bekomme ich keine Fehlermeldung
 Quote
[root@ds*.*.*.* bin]# ./getstatus_ban.sh
Unban Counter: 3

getstatus Chain exists

getstatus Rules exists

Chain INPUT (policy ACCEPT)
target prot opt source destination
getstatus udp -- 0.0.0.0/0 0.0.0.0/0 udp

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain getstatus (1 references)
target prot opt source destination


allips1 (search pattern: getstatus and UDP):

*.*.*.*
*.*.*.*
*.*.*.*

allips2 (search pattern: getstatus and zoneRef):


Und die datei unbancnt:
 Quote
unbancounter 3

Ist der output korrekt von dem Skript usw? Weil ich würde gerne auf die modifizierte etded verzichten. Und ich wundere mich, wie kann das funktionieren mit IPtables, müsste das skript nicht permanent laufen?


last changed by ailmanki am 20.12.2011 - 07:27:53

  ailmanki
Private

User Pic

Posts: 24
Registred: 23.03.2011
Origin: Lucern

  

0 approved this posting.


20.12.2011 - 17:52:13

Sieht für mich erstmal nicht schlecht aus ;)

Das Skript setzt ja die iptable rules und damit den netfilter. Ich lasse es auf meinen Server momentan minütlich für 10s (capturetime) via Cron laufen.
Im Endeffekt ist das natürlich keine stateful inspection, sondern nur eine Stichprobe mit darauf folgender Aktion (drop oder eben unban, also Entfernen der Drop-Rule bei Inaktivität).
Jedoch laufen die Angriffe im Burst-Modus, so dass ich damit glücklich bin nur maximal 1 Minute lang zum Handlanger der Skript-Kiddies zu werden.

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


20.12.2011 - 21:49:20

Ja ich kann Schnoog nur zustimmen. Ich rate allerdings davon ab die Variablen in Script zu manipulieren ohne den Grund zu wissen weshalb die Werte nicht gesetzt werden.

Wie dem auch sei, ich hab die Nacht das Script nochmal überarbeitet. Hauptsächlich um das einstellen der Variablen zu erleichtern. Es fehlt noch eine Readme, die packe ich die Tage noch dazu.

Änderungen:

- Änderung der Variablen über getstatus.ini:

  • COUNT (0) // Zähler für Aktion Unban, Datei unbancnt entfällt
  • MYDEBUG (1) // Debugmodus on=1 / off=0
  • CAPTURETIME (8) // Aufzeichnungszeit tcpdmp
  • MAXPERSECONDS (15) // UDP Packete pro Sekunde
  • UNBCNT (30) // Limit nach dem Aktion Unban durchgeführt wird (wenn COUNT diesen Wert
    erreicht)
  • RunPart (2) // Aktion wählbar, 1= Ban / 2=Ban & Unban

Die getstatus.ini wird nach dem ersten Start des Scriptes automatisch im Scriptverzeichnis erzeugt und enthält Standartwerte. Die Werten können dann nach euren Vorstellungen angepasst werden.

weitere Änderungen:
  • Check ob alle benötigten Tools installiert sind ( nur bei Debug on)
  • Logdatei auf die Banliste beschränkt, Logger entfernt
  • Debugoption vereinfacht (on=1 / off=0)
  • farbliche Kennzeichnung Scriptcode (Debugmodus, nur Console)
  • unnötigen Scriptcode entfernt


Wichtiger Hinweis zu MAXPERSECONDS: der Wert sollte nicht kleiner der Anzahl der Gameserver auf dem Root sein (also alle Gamserver-Ports incl. Serverfacade falls benutzt) , sonst kann es zu unerwünschten Bans von Usern kommen wenn diese HLSW, XQF oder sonstige Serverbrowser benutzen !!!

Download



Bitte mal testen


Grüße

OldMan


last changed by OldMan am 24.01.2012 - 00:26:15

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


20.12.2011 - 22:17:15

Ist es nur bei mir so, oder ist es bei Euch heute auch sehr ruhig gewesen?
Hab heute nicht einen einzigen Ban.

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


20.12.2011 - 23:40:47

Ne, bei mir ist es nicht wirklich besser. Ich hatte jetzt mal 14 Tage Ruhe nachdem ich den Server gewechelt habe. Nun ist wieder massiv was los. Im Großen und Ganzen ist es aber weniger geworden, die Höhe der Pakete ist allerdings erschreckend :

46104 Requests in 10 seconds / 4610 Requests per second

von nur einer IP ... :(

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


27.12.2011 - 17:37:37

Hallo,

Leider ist mir ein Fehler im Script V1.6 unterlaufen. Dies kann zu Problemen mit max. Filesopen führen da ein Prozess nicht sauber beendet wird. Ihr könnt das Script neu herunterladen oder die Änderung selbst einbauen.

Sucht in Script nach:

function capture_data {
$TCPDUMPBIN -f -c 100000 -A >$captured_data 2>$captured_data_num & pid=$!
sleep $CAPTURETIME


fügt danach hinzu:

if [ $pid ] ; then
kill -9 $pid
fi


Grüße

OldMan

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


29.12.2011 - 19:57:50

Please someone can just translate or post what's the differences between the version 1.5 and 1.6??
Im using the version of 1.5 and its working very wel!!
Thanks in advance,
Rod.

  zer0o0
Private First Class

User Pic

Posts: 37
Registred: 26.01.2011

   

0 approved this posting.


30.12.2011 - 14:21:35

Hello,

The functionality of version 1.6 is similar to the 1.5
There is no compelling reason to upgrade V1.6 if the script works for you. But it can not hurt ;)

Mainly set of variables which should be facilitated. These can now be changed in the getstatus.ini.

changes:

- Change of variables getstatus.ini:

  • COUNT (0) / / counter for action Unban, file eliminates unbancnt
  • MYDEBUG (1) / / Debug mode on = 1 / off = 0
  • CAPTURE TIME (8) / / record time tcpdmp
  • MAXPERSECONDS (15) / / UDP packets per second
  • UNBCNT (30) / / limit after Unban action is performed (if this value COUNT
    reached)
  • RunPart (2) / / action choice, 1 = Ban / 2 = Ban & Unban


The getstatus.ini after the first start of the script automatically generates the script directory and contains default . The values can then be customized according to your ideas.

additional changes:

  • Check whether all the necessary tools are installed (only for debug on)
  • Log file is limited to the banlist, loggers removed
  • Simplifies debugging option (on = 1 / off = 0)
  • color-coded script code (debug mode only console)
  • script removes unnecessary code



Important note to MAXPERSECONDS: the value should not be less than the number of game servers to be on the root (ie all Gamserver ports incl Serverfacade if used), otherwise it can lead to unwanted bans of users when they use HLSW, XQF or other server browser! !


Create the directory /usr/sbin/getstatus.
Copy the file getstaus_ban.sh in this directory.
Change the file getstaus_ban.sh owner to root and set chmod 744.
Create a cron job and run the file as root one time per minute.
Create a new log file rotation (one pro week should suffice) and
refer to /usr/sbin /getstatus/banlist





Greetings

OldMan


last changed by OldMan am 24.01.2012 - 17:38:51

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


31.12.2011 - 18:49:51

Thanks mate!!!

  zer0o0
Private First Class

User Pic

Posts: 37
Registred: 26.01.2011

   

0 approved this posting.


24.01.2012 - 15:19:59

I have downloaded your v. 1.6 and started it.

when i run it manual it bans as it should, but when running on a cronjob it dosent ban, it does however run

i get this when i run it manual --> /usr/sbin/getstatus_ban.sh: line 425: 19761 Killed $TCPDUMPBIN -f -c 100000 -A > $captured_data 2> $captured_data_num

is that ok?

script is owned by root, and is run in cronjob as root

if you need further info just aks for it, im struggling here and its annoying :)

thanks for the script ity works like a charm when i run it manual

greetings Patriot

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


24.01.2012 - 15:55:15

Hi,

which directory is the script?

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


24.01.2012 - 16:04:25

I placed it in /usr/sbin/

i can be reached on xfire patriotqube if that makes it easier

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


24.01.2012 - 16:32:31

I have not xfire. I use only Opensuse.

for testing:

find in line 303-305

if [ $pid ] ; then
kill -9 $pid
fi

please comment out

# if [ $pid ] ; then
# kill -9 $pid
# fi

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


24.01.2012 - 18:21:53

ok mate i did that

and script ran without any comments with manual run, also banned 1

but still dosent ba[code][/code]n on cronjob


SCRIPTVERSION V1.6


COUNT 14
MYDEBUG 1
CAPTURETIME 8
MAXPERSECONDS 15
UNBCNT 30
RunPart 2
RUNUNBAN 0

search grep ok
search cat ok
search awk ok
search tcpdmp ok
search iptables ok


getstatus Chain exists 

getstatus Rules exists

Chain INPUT (policy ACCEPT)
target prot opt source destination
getstatus udp -- 0.0.0.0/0 0.0.0.0/0 udp

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain getstatus (1 references)
target prot opt source destination
DROP udp -- 71.255.95.133 0.0.0.0/0
DROP udp -- 76.77.153.135 0.0.0.0/0
DROP udp -- 94.18.6.109 0.0.0.0/0
DROP udp -- 94.145.15.87 0.0.0.0/0
DROP udp -- 84.48.166.167 0.0.0.0/0
DROP udp -- 46.30.126.114 0.0.0.0/0
DROP udp -- 204.237.37.128 0.0.0.0/0
DROP udp -- 80.161.11.178 0.0.0.0/0
DROP udp -- 90.185.110.92 0.0.0.0/0
DROP udp -- 72.20.51.145 0.0.0.0/0
DROP udp -- 217.62.1.211 0.0.0.0/0
DROP udp -- 199.30.48.242 0.0.0.0/0
DROP udp -- 187.162.134.25 0.0.0.0/0
DROP udp -- 178.33.114.103 0.0.0.0/0
DROP udp -- 178.33.112.108 0.0.0.0/0
DROP udp -- 108.59.12.34 0.0.0.0/0

allips1 (search pattern: getstatus and UDP):

108.59.12.34
178.33.112.108
178.33.114.103
187.162.134.25
199.30.48.242
217.62.1.211
46.227.108.7
62.198.248.64
71.255.95.133
77.191.240.7
79.196.199.237
80.161.11.178
81.91.242.15:5060;bra
89.245.127.232
92.229.205.163

108.59.12.34 already banned !

178.33.112.108 already banned !

178.33.114.103 already banned !

187.162.134.25 already banned !

199.30.48.242 already banned !

217.62.1.211 already banned !

71.255.95.133 already banned !

80.161.11.178 already banned !

allips2 (search pattern: getstatus and zoneRef):



  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


24.01.2012 - 18:36:16

ok, we stay first problem

Please

if [ $pid ] ; then
kill -9 $pid
fi

the line shift after line 547 (rm $mygoto/0 2>/dev/null)

(Edit: 504 to 547)

and test it.


for cron:

This line is available in the script?

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Do you use different environment variables?


last changed by OldMan am 24.01.2012 - 18:39:30

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


24.01.2012 - 21:36:11

yes that Path is at hand in the file

and no im pretty sure i dont use different environment variables

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


24.01.2012 - 22:19:36

please show

/var/spool/cron/crontabs/root

which linux distributions use you?

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


24.01.2012 - 23:46:45

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.p6zy8p/crontab installed on Tue Jan 24 20:47:57 2012)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
SHELL = /bin/sh
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

* * * * * /usr/sbin/getstatus_ban.sh #Quake3 Exploit Fix - Script (getstatus_ban.sh) - CK 20120124

and our linux is

Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.19 with Suhosin-Patch

hope thats what you asked for

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


25.01.2012 - 01:02:43

Thx for info

try this, please change entry to

* * * * * sh /usr/sbin/getstatus_ban.sh #Quake3 Exploit Fix - Script (getstatus_ban.sh) - CK 20120124


my crontab enty for exemple:

* * * * * nice -1 sh /usr/sbin/getstatus/getstatus_ban.sh > /dev/null 2>&1

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

1 approved this posting.


25.01.2012 - 08:18:47

ok i changed it as you suggested

now im going to monitor again

thx for the help mate

il be back if it still dosent work ;)

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.




Images by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Powered by IlchBB Forum 3.1 © 2010 Weblösungen Florian Körner