Hi,
I'd like to share with you a solution to a problem I was solving for a customer.
The goal is to make SNORT able to catch a Microsoft SQL Server injection made by querystring. Honestly, I was searching and searching in the Snort and EmergingThreats rules, but I didn't find anything similar, so I had to make a couple of rules by myself.
First of all, we have to create a "local.rules" file and to store it in a place that will not be rewritten by the normal rules update.
So just create a "local.rules" text file withe the following content:
# ------------
# LOCAL RULES
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:"NT2-SQL Injection-Varchar"; flow:to_server,established;uricontent: "?";http_uri;content:"varchar";nocase; resp: rst_all; classtype:web-application-attack; sid:9990001; rev:1;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:"NT2-SQL Injection-Declare"; flow:to_server,established;uricontent: "?";http_uri;content:"declare";nocase; resp: rst_all; classtype:web-application-attack; sid:9990002; rev:1;)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:"NT2-SQL Injection-Exec"; flow:to_server,established;uricontent: "?";http_uri;content:"exec"; nocase; resp: rst_all; classtype:web-application-attack; sid:9990003; rev:1;)
Then upload the file in the directory:
/usr/local/etc
and step 1 is done.
Finally, we just have to open the Snort interface, in the "Advanced configuration pass through" just add:
include /usr/local/etc/local.rules
and that's it, just save, restart Snort and you'll be able to catch (and ban) the SQL injections.
Just a couple of things:
1) If you have a "global threshold" rule in your suppress list, just remember to add an exception for the events 9990001, 9990002 and 9990003
2) Unfortunately the 1st malicious request reach the web server. So just install or update URLScan to version 3.1 and you'll be able to add the strings to exclude the same sequences from your QueryString ([DenyQueryStringSequences] section of the UrlScan.ini file).
I hope what I wrote will be useful to someone else...
Ciao,
Michele