[Linux] Blocking Your w00tw00ts with iptables


 
Thread Tools Search this Thread
Special Forums Cybersecurity [Linux] Blocking Your w00tw00ts with iptables
# 8  
Old 12-12-2009
OK. Let's see if I can help you address some shortcomings that will impact performance...

Quote:
Originally Posted by Neo
Our experience is everything contributes to performance and applying something to the front end of the web server will definitely effect performance. When you discount performance off-hand,
I think it is great you emphasize the importance of performance but continuing to put emphasis on it begs the question why you did not see fit to address it in your OP (original post)?


Quote:
Originally Posted by Neo
I can only assume you do not operate a web server with thousands of concurrent users and millions of PVs a month.
By introducing this argument you imply that you do. Besides, you know what assumptions make.


Quote:
Originally Posted by Neo
mod_security performance quotes
Mod_security can have an impact performance-wise. I don't disagree with that (as I've stated already). But the fact that you counter by just quoting two or more year old articles (one of which used ModSecurity v1 rules instead of ModSecurity v2) and neglect to seize the offered opportunity to back up your claim by presenting numbers (like this?) doesn't help me address this part of the discussion.


Quote:
Originally Posted by Neo
I think you may be arguing for the sake of argument.
* BTW, comments like this, just like your previous "hand waving" comment, are utterly unnecessary as they do not help discussion and understanding. Perception-wise they tell readers more about you than they do about me.


Quote:
Originally Posted by Neo
Everything effects performance.
OK. Let's see if I can help you address some shortcomings that will impact performance:
0. I did not present a huge list of filters to use, not even the OWASP CRS, but the idea of using a single rule like 'SecRule REQUEST_URI "/w00tw00t"'. So while your emphasis on performance may have been justified in general it does not directly address my suggestion.
1. Grepping logs for "w00tw00t" after means your rules will always be out of date and incomplete (as opposed to say using a single raw table --hex-string "|2f 77 30 30 74|"?).
2. You're offering a list (novirusthanks dot org) that seems unvetted, evidenced by the fact that none of the major Linux security websites point to it. The dangers of using such lists, just like using unmaintained, uncontrolled or subjective RBL's, I don't need to point out.
3. Blocking IP addresses based on a single request makes it easy to deny clients access to the service. What's more is that since you block a /24 one only needs one address inside the subnet.
4. Blocking IP addresses based on a single request makes it easy to exhaust memory allocated for rules.
5. Your OP does not present any rule management. Without pointing that out rules, including obsoletes, will just be added which impacts performance.
6. Since linear filtering is in effect all rules must be traversed until a match is found. So dumping all your rules in the INPUT chain (conntrack?) will impact performance. (How about using the raw table, ipset, nf-hipac?).

Granted, you did ask for "Anyone care to combine all this into one great script?" and finding your precious post is getting commented on may hurt a bit, but you implying to "operate a web server with thousands of concurrent users and millions of PVs a month" makes me wonder if the script you wrote in your OP would have ever made it onto such a high-performance web server and if it did how long it would last before being ripped out because of aforementioned shotcomings. Then again you may safely dismiss all of the above as I am no security expert, just an average GNU/Linux user with a grain of common sense...

Good luck with fixing your script!
# 9  
Old 12-12-2009
I will reply on the technical details of your post when I have more time.

On the other hand, this comment below :

Quote:
Originally Posted by unSpawn
... your precious post is getting commented on may hurt a bit....
The only thing that "hurts a bit" is to see your reply to have childishly rude and ugly comments, like the one above, depicting a tone which is completely unacceptable in these forums.

The only "precious post" I have in my thousands of posts here is the one called the forum rules, which you have clearly violated by deviating from a techincal discussion to a snide and ugly one.

So, this has resulted in an infraction to you.

I suggest you change your tone if you want to debate here because I will not hesitate to give you an infraction again if you continue to interleave snide, sarcastic comments in your techincal discussions, with me or anyone.
# 10  
Old 12-14-2009
Gosh, I just wanted to have a little scripting fun... and I know next to nothing about running a high load web server.

The *net is a marvelous thing.
Smilie
/Lakris
# 11  
Old 04-09-2010
Im having problems with these fucking lammers bots. I have a dedicated server and I was having problems 2 months ago with my Internet Bandwith. I know now that I have this fucking bot:

Quote:
203.127.11.215 - - [09/Apr/2010:19:23:19 +0200] "GET /w00tw00t.at.ISC.SANS.test0Smilie HTTP/1.1" 400 341 "-" "-"
217.195.204.194 - - [09/Apr/2010:19:30:59 +0200] "GET /w00tw00t.at.ISC.SANS.DFindSmilie HTTP/1.1" 400 341 "-" "-"
203.127.11.215 - - [09/Apr/2010:19:38:19 +0200] "GET /w00tw00t.at.ISC.SANS.test0Smilie HTTP/1.1" 400 341 "-" "-"
217.195.204.194 - - [09/Apr/2010:19:47:44 +0200] "GET /w00tw00t.at.ISC.SANS.DFindSmilie HTTP/1.1" 400 341 "-" "-"
203.127.11.215 - - [09/Apr/2010:19:53:05 +0200] "GET /w00tw00t.at.ISC.SANS.test0Smilie HTTP/1.1" 400 341 "-" "-"
As you said, I banned lot of IP's at httpd.conf but didnt work because IPs change. Then I was looking for info and I got that its a scanner.

Now my problem is that Im a Newbiee at Linux (using Ubuntu 8.04 at moment), and I only got a script done by other people, but It doesnt work for me cause of some parameters:

Quote:
#!/bin/bash

# agregue las siguientes líneas al principio de las reglas de iptables

# Aceptar loopback
iptables -A INPUT -i lo -j ACCEPT

# Comprobando que la IP está en la lista negra de w00tlist
# Si la IP está en la lista se rechaza de inmediato y se actualiza la lista negra en 6 horas
iptables -A INPUT -p tcp -m recent --name w00tlist --update --seconds 21600 -j DROP

# Crear una cadena w00tchain que agregue la dirección IP a la Lista negra de w00tlist
# y se restablecerá la conexión (no se olvide del prámetro '-p tcp' necesario para el uso de '--reject-with tcp-reset')
iptables -N w00tchain
iptables -A w00tchain -m recent --set --name w00tlist -p tcp \ -j REJECT --reject-with tcp-reset

# Creamos nuestra cadena w00t:
iptables -N w00t

# redirigimos los paquetes TCP a nuestro canal:
iptables -A INPUT -p tcp -j w00t

################################################## ###
# Ponga aquí sus propias reglas de iptables:
# Aceptar conexiones establecidas, etc. un ejemplo en la primera línea:

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
...
...
...
...

################################################## ###

# Cadena w00t
# Buscar el primer SYN y crear la lista:
iptables -A w00t -m recent -p tcp --syn --dport 80 --set

# Buscar los paquetes SYN, ACK, y actualización de la lista:
iptables -A w00t -m recent -p tcp --tcp-flags PSH,SYN,ACK SYN,ACK --sport 80 --update

# Buscar el paquete ACK y actualización de la lista:
iptables -A w00t -m recent -p tcp --tcp-flags PSH,SYN,ACK ACK --dport 80 --update

# Busca la firma hexadecimal en el primer PSH+ACK.
# Si está presente, se redirije a la lista negra de w00tchain y
# se corta la conexión de la IP.
# Y se elimina de nuestra lista, que no queremos filtrar cualquier paquete adicional de la conexión
iptables -A w00t -m recent -p tcp --tcp-flags PSH,ACK PSH,ACK --dport 80 --remove \ -m string --to 80 --algo bm --hex-string '|485454502f312e310d0a0d0a|' -j w00tchain
Problems are with -j and -m parameters. If someone can make 1 script for me that avoid this fucking scanner, I will be so thank.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Cybersecurity

Blocking 3306 with iptables -A INPUT -p tcp --dport 3306

Just added these lines to our server firewall: iptables -A INPUT -p tcp --dport 3306 -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT iptables -A INPUT -p tcp --dport 3306 -j DROP Even though mysql is configured to correctly only listen on port 127.0.0.1 we still see these mysql log file notes on a daily... (0 Replies)
Discussion started by: Neo
0 Replies

2. Programming

Which are blocking and non-blocking api's in sockets in C ?

among the below socket programming api's, please let me know which are blocking and non-blocking. socket accept bind listen write read close (2 Replies)
Discussion started by: VSSajjan
2 Replies

3. UNIX for Dummies Questions & Answers

Linux iptables -> is it possible?

Hi! I have a dedicated hosting working with 2 ips. Is it possible to block all connections but 1 in all existing ports for only 1 of my ips? I mean like, I have 2 ips for example: 190.x.x.5 and 190.x.x.6 I want that all the connections going to 190.x.x.6 in all ports get rejected but only 1... (7 Replies)
Discussion started by: Kekox
7 Replies

4. UNIX for Advanced & Expert Users

ps blocking

Hi Folks I have been debugging a script that is called every thirty seconds. Basically it is doing a ps, well two actually, one to file (read by the getline below) and the other into a pipe. The one into the pipe is: - V_SYSVPS=/usr/sysv/bin/ps $V_SYSVPS -p$PIDLIST -o$PSARGS... (0 Replies)
Discussion started by: steadyonabix
0 Replies

5. Debian

URL blocking with iptables

we have internal network 192.168.129.x for a system hosted with pdf.xxx.xyz URL is already public accessible but when try to connect as site (/ap/p.nt) of the URL pdf.xxx.xyz/ap/p.nt restriction to be applied publicly except accessing internally can anyone guide me on this?? (1 Reply)
Discussion started by: shrinuvas
1 Replies

6. Shell Programming and Scripting

Non-blocking pipe

Hello, Would this be an acceptable way of creating a non-blocking pipe. Basically I want to create kind of a server client arch. This code would be in the server, and I don't want to have to wait for clients to read before moving on to the next client. One problem I can see is if... (4 Replies)
Discussion started by: cdlaforc
4 Replies

7. Programming

Linux BSD sockets blocking issue

I am using BSD TCP sockets under Debian Linux 2.6 and no matter what I do, the socket blocks on recv. I have set O_NONBLOCK and O_NDELAY using fcntl to no effect. Any ideas ? (3 Replies)
Discussion started by: johnmb
3 Replies

8. UNIX for Dummies Questions & Answers

Linux IPTABLES help

I'm new to Linux and I made a big mistake at work recently locking myself out of our own server :(. I did iptables -F first as the tutorial said and then entered the rules. I wanted to start over again so I did iptables -F and it locked us out. We had to get someone to physically restart... (0 Replies)
Discussion started by: nogumo
0 Replies

9. Linux

LINUX 9 IPTABLES and DNS

I have installed a linux 9 router/firewall and have issues with outside DNS queries making it in. here are my IPTABLE rules, can anyone make some suggestions? ETH1 is my outside facing Interface, ETH0 is my inside facing interface. Accept If input interface is not eth1 Accept If protocol... (6 Replies)
Discussion started by: frankkahle
6 Replies

10. UNIX for Advanced & Expert Users

LINUX 9 IPTABLES and DNS

I have installed a linux 9 router/firewall and have issues with outside DNS queries making it in. here are my IPTABLE rules, can anyone make some suggestions? ETH1 is my outside facing Interface, ETH0 is my inside facing interface. Accept If input interface is not eth1 Accept If protocol is... (1 Reply)
Discussion started by: frankkahle
1 Replies
Login or Register to Ask a Question