Skip to contentSkip to conversation

my new option calls httpr

DISCUSSION [email protected] 3 participants 3 messages Mar 1, 2003 – Mar 3, 2003 netfilter

lore
Share & tools
lore
#0 lore raw

When I didn't modify -string option. I created a new option -httpr (http request).

I had done a test suite above my network with this patch aplied. In Input string on NETFILTER hook, I had a 4 rules:

iptables -A INPUT -m httpr --httpr '"GET"?"cmd.exe"?"dir"?"HTTP"' -j LOG
iptables -A INPUT -m httpr --httpr '"GET"?"tftp"?"HTTP"'
-j LOG
iptables -A INPUT -m httpr --httpr '"GET"?"root.exe"?"HTTP"' -j LOG
iptables -A INPUT -m httpr --httpr '"GET"?"default.ida"?[XNO]*?"HTTP"' -j LOG

My regexp library recognices the rules before showed.

In this host (it's a gateway) is installed a ftp server (proftp server). From other host established a ftp connexion to this gate with
NETFILTER on. PUT and GET binaries files, from and to this gateway and bandwith was ok. (5000 Kb/s).

I hope that my explanation was good and people understand me.

Sorry for my horrible english.

___________________________________________________
Yahoo! Móviles
Personaliza tu móvil con tu logo y melodía favorito en http://moviles.yahoo.es

#1 lore raw

using string match - was: my new option calls httpr

Hola,

Quoted 9 lines · On Saturday 01 March 2003 19:40, [email protected] wrote:

When I didn't modify -string option. I created a new option -httpr (http request).
I had done a test suite above my network with this patch aplied. In Input string on NETFILTER hook, I had a 4 rules:
iptables -A INPUT -m httpr --httpr '"GET"?"cmd.exe"?"dir"?"HTTP"' -j LOG iptables -A INPUT -m httpr --httpr '"GET"?"tftp"?"HTTP"' -j LOG iptables -A INPUT -m httpr --httpr '"GET"?"root.exe"?"HTTP"' -j LOG iptables -A INPUT -m httpr --httpr '"GET"?"default.ida"?[XNO]*?"HTTP"' -j LOG [...]

Don't get me wrong, I'm just trying to explain why you shouldn't be doing this, please don't take it personally. This is a reminder for a lot of people, not just you.

All the HTTP rules above will be exploited trivially with Unicode encoding, or ASCII encoding (for example you can write the URL as GET /cmd.%65x%65 %65 being the hexadecimal ASCII number for 'e'). Look at the tool whisker for more informations on IDS evasion techniques, a lot of them are applicable to the string match.

Using such encoding for example, the string match (with or without regexp support) will not match, and if you rely on this match as a strong security layer to stop worms or hand exploitation for instance, then you're in trouble. Now if you think that it's difficult to browse normally
using such obfuscation, think again, since it would be trivial to write such
a proxy (provided it hasn't already been done).

Another reason why I wouldn't want to use this rule is that it will match the string _anywhere_ in the packet. As such, if you are trying to browse an archived version of this email, your firewall would drop the legitimate web page content. It wouldn't even drop the HTTP request, it would erase content from the page, and most probably kill your HTTP connection in the middle.

As Patrick has mentioned, there are _many_ reasons why you should not be doing this. And regexp is just one of them. We will never repeat enough times, that the proper way of filtering a high level protocol is to use an Application Proxy. In your case, what you really need is an HTTP filtering proxy. Look at Squid or Zorp. Not sure for Squid, but Zorp most probably will support regexps since you write the rules in python..

There was a thread some time ago highlighting speed as a reason to shift away from a filtering proxy. I do not buy the arguments (no offense (-: ) and think that there must be a way to get a proxy fast enough... If people have such a bandwith or such a need for high security, then it means they have the budget for faster machine that can run the proxy fast enough. So far, the only two reasons I understand to shift away from proxies are
1- when there is no (free) proxy available for the protocol mentioned
(packet filters are better that no filtering at all)
2- when budgets are too limited, and one cannot get a machine fast enough
for the proxy.

string match is probably useful for information purpose, information gathering or stuff like this (part of an IDS for example), where taking a hard action on the packet is not necessary. Whenever you want to take a concrete action on the packet based on a string match decision, most of the times you're jeopardizing your security _or/and_ the usability of your network. string match is a nice one, but it _must_ be used with eyes wide open,
as it's easy to shoot yourself in the foot ;-)

Have a nice day,

Fabrice.
--
Fabrice MARIE

"Silly hacker, root is for administrators"
-Unknown

#2 lore raw

Re: using string match - was: my new option calls httpr

Quoted 1 line · Fabrice MARIE

Hola,

hi

Quoted 10 lines · On Saturday 01 March 2003 19:40, [email protected] wrote:
Quoted 9 lines

When I didn't modify -string option. I created a new option -httpr (http request).
I had done a test suite above my network with this patch aplied. In Input string on NETFILTER hook, I had a 4 rules:
iptables -A INPUT -m httpr --httpr '"GET"?"cmd.exe"?"dir"?"HTTP"' -j LOG iptables -A INPUT -m httpr --httpr '"GET"?"tftp"?"HTTP"' -j LOG iptables -A INPUT -m httpr --httpr '"GET"?"root.exe"?"HTTP"' -j LOG iptables -A INPUT -m httpr --httpr '"GET"?"default.ida"?[XNO]*?"HTTP"' -j LOG [...]

Quoted 3 lines

Don't get me wrong, I'm just trying to explain why you shouldn't be doing this, please don't take it personally. This is a reminder for a lot of people, not just you.

I had a slightly similar problem to solve. I solved it by writing a daemon in perl that processes logs in realtime and if it finds out someone is hitting it with nimda, it calls iptables to DROP the IP and sends me an email with description and excerpts from the logs. The advantage is, this method can be used both for squid and httpd.

Quoted 5 lines

All the HTTP rules above will be exploited trivially with Unicode encoding, or ASCII encoding (for example you can write the URL as GET /cmd.%65x%65 %65 being the hexadecimal ASCII number for 'e'). Look at the tool whisker for more informations on IDS evasion techniques, a lot of them are applicable to the string match.

Basically you are right, but in this case it doesn't happen. Nimda hits only with non-escaped URLs. Anyway, user space daemon can take care of that as well.

Quoted 3 lines

Have a nice day,

Fabrice.

Bye,

Peter Surda (Shurdeek) <[email protected]>, ICQ 10236103, +436505122023

--
Disc space - The final frontier.