本人水平有限 有些地方写的较为繁琐 仅供参考
十六进制检测没有写全
****************************************
‘ or 1=1 and 1=1 'a'='a' 类型:*****************************************
((\x27|')?\s+(o|O)(r|R)|^(o|O)(r|R))\s+?[[:alnum:]]+\s*(=|>|<|<>|>=|<=)\s*[[:alnum:]]+\s*
((\x27|')?\s+(o|O)(r|R)|^(o|O)(r|R))\s+?(\x27|')[[:alnum:]]+(\x27|')\s*(=|>|<|<>|>=|<=)\s*(\x27|')[[:alnum:]]+(\x27|')\s*
((\x27|')?\s+(a|A)(n|N)(d|D)|^(a|A)(n|N)(d|D))\s+?[[:alnum:]]+\s*(=|>|<|<>|>=|<=)\s*[[:alnum:]]+\s*
((\x27|')?\s+(a|A)(n|N)(d|D)|^(a|A)(n|N)(d|D))\s+?(\x27|')[[:alnum:]]+(\x27|')\s*(=|>|<|<>|>=|<=)\s*(\x27|')[[:alnum:]]+(\x27|')\s*
*****************************************
and 0<(select count(*) from admin) 类型:
*****************************************
((\x27|')?\s+(a|A)(n|N)(d|D)|^(a|A)(n|N)(d|D))\s+?\w+(=|>|<|<>|>=|<=)\s*?\(.*\)?
((\x27|')?\s+(a|A)(n|N)(d|D)|^(a|A)(n|N)(d|D))\s+?\(.*\)\s*?(=|>|<|<>|>=|<=)\s*?\w+
*****************************************
select ..from..
*****************************************
(select|Select|SELECT)\s+.*\s+(from|From|FROM)\s+
*****************************************
关键字
*****************************************
((;|\(| )(insert|INSERT|Insert)|^(insert|INSERT|Insert))\s+(into|Into|INTO)\s+
((;|\(| )(update|Update|UPDATE)|^(update|Update|UPDATE))\s+\w+\s+(set|Set|SET)\s+\w+\s?=.*
((;|\(| )(delete|Delete|DELETE)|^(delete|Delete|DELETE))\s+(\*\s+)?(from|From|FROM)\s+.*
((;|\(|)(drop|Drop|DROP)|^(drop|Drop|DROP))\s+((table|Table|TABLE)|(index|Index|INDEX)|(database|Database|DATABASE))\s+
(\n|\s)+?(Union|union|UNION)(\n|\s)+?
*****************************************
--和#
*****************************************
--|#|\x23