Advertising
Is your server exploited (Part 2)

25.01.2012 - 14:00:54

ok been keeping an eye on the script whole day an not 1 ban has been added or removed from banfile

then i ran it manual and it banned 1

so im afraid that it didnt do it :(

It has to be the environments that are a problem, i know that cron can have difficulties with path and shell, which is why i choosed to use /usr/sbin/ as directory as thats for sure in path

i can see our /var/spool/cron/crontabs/root has shell = /bin/sh and that and that the script starts with bin/bash

but what to do? anyone have a suggestion/solution?

greetings Patriot

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


25.01.2012 - 14:39:40

i hope this can help

http://ubuntuforums.org/showthread.php?p=8953947


last changed by OldMan am 25.01.2012 - 14:40:50

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

1 approved this posting.


25.01.2012 - 17:09:12

well thanks for help mate it is now working

what i did was that we changed the shell in /var/spool/cron/crontabs/root to bin/bash

then i removed the sh infront of command line also made it so the script is putting the output into a file so i can check it for the next few hours that it is running, but it has banned automatic now, 4 the last 30 minutes and it has also removed bans after 30 runs, all automatic

so yeah it runs

really appreciate your help mate and also the script :)

thanks again

  Patriot
Private

User Pic

Posts: 8
Registred: 24.01.2012

  

0 approved this posting.


25.01.2012 - 17:29:28

No problem
I am glad i can help you :)

A similar problem we had here but I had forgotten it. I will add a readme to the script.

Greetings

OldMan

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


29.01.2012 - 19:17:43

For some reason the script is no longer banning any of the ip's. Debug shows the ip's found but it will not insert them into the getstatus chain. If i manually add an ip to getstatus and run the script it will echo "xxx.xxx.xxx.xxx already banned!" any ideas?

  Jun1oR
Private

User Pic

Posts: 2
Registred: 29.01.2012

  

0 approved this posting.


29.01.2012 - 19:53:21

Script running as root?

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


29.01.2012 - 20:11:49

It seems to be working again, I'm hoping it was just some temporary issue with my server. For about 2 hours it wasn't banning a new IP's. I will keep my eye on it and let you know. Also thank you.

*EDIT*
Everything is working fine again, I don't know what could have the caused the issue.


last changed by Jun1oR am 30.01.2012 - 01:32:08

  Jun1oR
Private

User Pic

Posts: 2
Registred: 29.01.2012

  

0 approved this posting.


26.02.2012 - 12:09:48

If someone have a custom iptables script, it would be a good choice to insert the getstatus rule on top the input chain

 Code
1:
  iptables -I INPUT -p udp -m udp -j getstatus

instead of the end if it
 Code
1:
 iptables -A INPUT -p udp -m udp -j getstatus


Otherwise any other rules accepting the packages could spoil the function of getstatus_ban


If someone uses the script and also tools like arnis-firewall-script a short bash script could help to enforce the getstatus_ban bans

 Code
1:
2:
3:
4:
5:
 
getexist=$(iptables -nL --line-numbers | grep getstatus | grep -v DROP | grep -v Chain | awk '{print $1}')
iptables -D INPUT $getexist
iptables -I INPUT -p udp -m udp -j getstatus



last changed by schnoog am 26.02.2012 - 17:30:41

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


26.02.2012 - 19:50:45

Versteh ich nicht ganz.

 Code
1:
2:
3:
 
$IPTABLESBIN -I getstatus 1 -s $IP -p UDP -j DROP]


Damit wird jede Drop-Rule immer an der ersten Position der Getstatus-Chain eingefügt.

Bei mir sieht das dann so aus:

 Code
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
 
DROP       udp  --  93.93.65.147                              0.0.0.0/0           
DROP       udp  --  93.93.65.248                              0.0.0.0/0           
DROP       udp  --  81.19.217.223                            0.0.0.0/0           
DROP       udp  --  81.184.165.212                          0.0.0.0/0           
DROP       udp  --  216.245.221.243                        0.0.0.0/0           
DROP       udp  --  216.133.234.127                        0.0.0.0/0           
DROP       udp  --  78.46.40.209                              0.0.0.0/0           
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:9987
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27961
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27962
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27963
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27964
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27965
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27966
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27967
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27968
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27969
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27970
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:27971




last changed by OldMan am 26.02.2012 - 19:51:51

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


26.02.2012 - 21:14:54

Das Problem ist, dass Arno's iptables-firewall den INPUT table schon befüllt, und die Pakete in einer davorstehenden Chain durchleitet. iptables -I INPUT -p udp -m udp -j getstatus sorgt dafür, dass die getstatus chain an erster Position des INPUT Tables ausgeführt wird.

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


27.02.2012 - 01:34:13

Oh, das hatte ich wohl nicht richig gelesen. Es ist richtig, der Verweis auf getstatus muss an erster Stelle stehen.

Ich werde das im Script ändern.

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


28.02.2012 - 12:43:27

Ich hab hier noch ein kleines Skript gefunden, dass via IPTables die eingehenden Attacken blockiert... hat man die IPTables u32 Erweiterung geladen, so sollte es damit auch ganz ohne Cron & Co gehen:

 Code
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
 iptables -N quake3_ddos
iptables -A quake3_ddos -m u32 ! --u32 "0x1c=0xffffffff" -j ACCEPT
iptables -A quake3_ddos -m u32 --u32 "0x20=0x67657473&&0x24=0x74617475&&0x25&0xff=0x73" -m recent --name getstatus --set

iptables -A quake3_ddos -m recent --update --name getstatus --hitcount 15 --seconds 2 -j DROP
#Das Hitcound und Seccounds muss jeder füne eigende Anzahl an Servern äern.
#Beispiel: Das o.g. Beispiel ist auf 13 Server abgestimmt.

iptables -A quake3_ddos -j ACCEPT
iptables -I INPUT 1 -p udp -j quake3_ddos

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


28.02.2012 - 14:41:31

sorry aber für so noobs wie mich: wie installier ich mir das u32modul?
ne anleitung für debian müsste doch schon das halbe forum abdecken :)
und ist dieses vorgehen dann empfehlenswerter wie der crownjob?
so wie ich das verstehe schon.

edit: oder wie erkenne ich das ich das u32 modul schon automatisch drauf hab?!


last changed by Meister Gandalf am 28.02.2012 - 15:26:34

  Meister Gandalf
Private First Class

User Pic

Posts: 32
Registred: 13.01.2011

   

0 approved this posting.


28.02.2012 - 15:12:12

ich hab beide am laufen momenten, da das Skript (vorletzter Post) nur getstatus abdeckt.

Wie man u32 installiert muss ich mal schauen.

Gruss
Volker

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


29.02.2012 - 13:37:25

Ist ne feine Sache, ich befürchte aber das dies für einige zu kompliziert ist.
Für VServer ohne eigenen Kernel wird das wohl auch nichts werden.

@Meister Gandalf

Installation:

Patch-O-Matic


Mal so am Rande, in letzter Zeit hat die Sache stark nachgelassen, geht fast gegen Null, bei euch auch?


Grüße

Lu

  OldMan
Private First Class

User Pic

Posts: 44
Registred: 28.08.2011

   

0 approved this posting.


01.03.2012 - 14:04:41

hab erst ne abuse mail bekommen allerdings ohne datumsangabe wann der angriff gewesen sein soll.
ansonsten auch eher ruhig

  Meister Gandalf
Private First Class

User Pic

Posts: 32
Registred: 13.01.2011

   

0 approved this posting.


01.03.2012 - 18:02:59

Aber nicht zufällig von exa.com.sa?

Da hab ich nämlich auch 2 bekommen, ohne Datum und Paketlänge 1500 (was nunmal absolut nicht gameservertypisch ist).

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

0 approved this posting.


02.03.2012 - 11:44:14

*hust* schnoog hallo ich bins :)
ja da hatten wirs schon drüber :)

  Meister Gandalf
Private First Class

User Pic

Posts: 32
Registred: 13.01.2011

   

0 approved this posting.


02.03.2012 - 12:53:12

Ich brauch Urlaub... mein Gedächtnis erinnert mich momentan an ein kaputtes Sieb :)

  schnoog
First Sergeant

User Pic

Posts: 294
Registred: 08.12.2010
Origin: Südbaden

    

1 approved this posting.


03.03.2012 - 19:14:25

Eine womöglich Off-topic-Frage:
Ich habe (weil auch betroffen) zunächst meinen V-Server komplett neuinstalliert. Der einzige offene Port ist derzeit 22 für SSH. Über iftop sehe ich immer noch getstatus-Anfragen über Port 27960, habe also eingehenden, aber keinen ausgehenden Traffic. Selbst wenn ich über iptables eine dieser IPs sperre (DROP), erzeugen diese weiterhin eingehenden Traffic.

Ist das normal?

Danke und Gruß!

  kraton79
Private

User Pic

Posts: 2
Registred: 03.03.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