way to handle re.I (ignore case) while using getCompiledRegex

This commit is contained in:
Miroslav Stampar 2010-05-21 15:03:40 +00:00
parent 5d5ebd49b6
commit 20d05cc404
2 changed files with 4 additions and 3 deletions

View File

@ -51,7 +51,7 @@ def checkPayload(string):
rules = []
for xmlrule in xmlrules.getElementsByTagName("filter"):
try:
rule = xmlrule.getElementsByTagName('rule')[0].childNodes[0].nodeValue
rule = "(?i)%s" % xmlrule.getElementsByTagName('rule')[0].childNodes[0].nodeValue
desc = __adjustGrammar(xmlrule.getElementsByTagName('description')[0].childNodes[0].nodeValue)
rules.append((rule, desc))
except sre_constants.error: #some issues with some regex expressions in Python 2.5
@ -59,5 +59,5 @@ def checkPayload(string):
for rule, desc in rules:
regObj = getCompiledRegex(rule)
if regObj.search(string, re.IGNORECASE):
if regObj.search(string):
logger.warn("highly probable IDS/IPS detection: '%s'" % desc)

View File

@ -24,6 +24,7 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import re
from lib.core.common import getCompiledRegex
from lib.core.common import normalizePath
from lib.core.common import ntToPosixSlashes
from lib.core.common import posixToNtSlashes
@ -57,7 +58,7 @@ class Miscellaneous:
else:
conf.tmpPath = "/tmp"
if re.search("\A[\w]:[\/\\\\]+", conf.tmpPath, re.I):
if getCompiledRegex("(?i)\A[\w]:[\/\\\\]+").search(conf.tmpPath):
kb.os = "Windows"
conf.tmpPath = normalizePath(conf.tmpPath)