|
A number of signatures are available for SQL Injection, including within the default snort rules. However, these can be bypassed by converting the malicious input into their hex equivalents, or vice versa. The signatures given below are for various levels of paranoia. The simplest among them, of course checks simply for the presence of a single-quote or the double-dash. This may however lead to a number of false positives, depending upon how your website is structured. These signatures are written using Perl-Compatible Regular Expressions. More information on PCRE is available at www.pcre.org
Signature 1 - detects single-quote and double-dash
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:"NII SQL Injection - Paranoid"; flow:to_server,established; pcre:"/(\%27)|(\')|(%2D%2D)|(\-\-)/i"; classtype:web-application-attack; sid:7002; rev:1;)
PCRE is:
/(\%27)|(\')|(%2D%2D)|(\-\-)/i
Signature 2 - detects typical SQL injection attack, such as 1'or some_boolean_expression
PCRE is:
/\w*(\%27)|'(\s|\+)*((\%6F)|o|(\%4F))((\%72)|r|(\%52))/i
Signature 3 - detects use of union - good guarantee of an attack
PCRE is:
/((\%27)|')(\s|\+)*union/i
Signature 4 - detects calling of an MS SQL stored or extended procedures
PCRE is:
/exec(\s|\+)+(s|x)p\w+/i
|