Skip to contentSkip to conversation

snort hex strings and libipt_string.c

PATCH Ian Latter 3 participants 3 messages Feb 18, 2003 netfilter

lore
Share & tools
lore

Ian Latter

author
#0 lore raw

Hi Michael,

This looks pretty cool ... do you provide any scripts to load up the snort
data into iptables automagically?

----- Original Message -----

Quoted 54 lines

From: "Michael Rash" <[email protected]>
To: <[email protected]>
Subject: [PATCH] snort hex strings and libipt_string.c
Date: Tue, 18 Feb 2003 10:14:18 -0500

(Reposting since I was not subscribed to the list at the time.)

The attached patch adds an option "--hex-string" to the string match module to allow snort-style hex strings to be specified on the command line. This is useful because there are many signatures that consist of non-printable characters and without this patch there is no way to easily tell iptables to search for them.

E.x:

iptables -I INPUT 1 -p udp --dport 53 -m string --hex-string "31 c0 b0 02 cd 80 85 c0 75 4c eb 4c 5e b0" -j LOG --log-prefix "DNS EXPLOIT x86 linux overflow attempt "

(This is my first patch to iptables so let me know if I need to do anything differently).

Thanks,

--Mike

Michael Rash
http://www.cipherdyne.com
Key fingerprint = 4EE3 816C 413A 41AA 72C8 4463 70C3 783C 1B91 F85E

extensions/libipt_string.c renamed from extensions/libipt_string.c.old +12 -0
@@ -31,6 +31,7 @@
 
 static struct option opts[] = {
 	{ "string", 1, 0, '1' },
+	{ "hex-string", 1, 0, '2' },
 	{0}
 };
 
@@ -48,6 +49,31 @@
 	else exit_error(PARAMETER_PROBLEM, "STRING too long `%s'", s);
 }
 
+static void
+parse_hex_string(const unsigned char *s, struct ipt_string_info *info)
+{
+    int slen, schar, sindex=0, i;
+    char hextmp[3];
+    slen = strlen(s);
+    if(slen <= 3*(BM_MAX_NLEN)) { /* hex input like "71 61 7a" */
+        for (i=0; i<slen; i+=3) {
+            hextmp[0] = s[i];
+            hextmp[1] = s[i+1];
+            if (s[i+2] == ' ' || s[i+2] == '
#1 lore raw
Quoted 4 lines · Ian Latter

Hi Michael,

This looks pretty cool ... do you provide any scripts to load up the snort
data into iptables automagically?

http://www.stearns.org/snort2iptables/ did most of the rules
before this patch became available.
Cheers,
- Bill

---------------------------------------------------------------------------
'Last week, one proponent of this argument, Scott Culp, manager
of Microsoft's security response center, coined the term "information anarchy" to describe the current situation, comparing it with yelling "fire" in a crowded movie house.
It appears Culp is more comfortable with an "information
dictatorship" or "information oligarchy" model, and has entirely missed the fact that the movie house is on fire.'

	-- Elias Levy, former moderator of bugtraq
	(http://www.securityfocus.com/news/270)

--------------------------------------------------------------------------
William Stearns ([email protected]). Mason, Buildkernel, freedups, p0f,
rsync-backup, ssh-keyinstall, dns-check, more at: http://www.stearns.org
Linux articles at: http://www.opensourcedigest.com
--------------------------------------------------------------------------

#2 lore raw
Quoted 9 lines · William Stearns
Quoted 4 lines · Ian Latter

Hi Michael,

This looks pretty cool ... do you provide any scripts to load up the snort
data into iptables automagically?

http://www.stearns.org/snort2iptables/ did most of the rules
before this patch became available.

Yes, and in fact snort2iptables is exactly why I wrote the patch since it is putting non-printable ascii chars into iptables shell commands. I want to be able to take the snort signature database and translate it directly into iptables rules without having to do this.

(I'm actually reworking the patch right now since it is not flexible enough to handle the various ways hex data can be included in snort signatures.)

--Mike

Michael Rash
http://www.cipherdyne.com
Key fingerprint = 4EE3 816C 413A 41AA 72C8 4463 70C3 783C 1B91 F85E