Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20d05cc

Browse files
committed
way to handle re.I (ignore case) while using getCompiledRegex
1 parent 5d5ebd4 commit 20d05cc

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/utils/detection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ def checkPayload(string):
5151
rules = []
5252
for xmlrule in xmlrules.getElementsByTagName("filter"):
5353
try:
54-
rule = xmlrule.getElementsByTagName('rule')[0].childNodes[0].nodeValue
54+
rule = "(?i)%s" % xmlrule.getElementsByTagName('rule')[0].childNodes[0].nodeValue
5555
desc = __adjustGrammar(xmlrule.getElementsByTagName('description')[0].childNodes[0].nodeValue)
5656
rules.append((rule, desc))
5757
except sre_constants.error: #some issues with some regex expressions in Python 2.5
5858
pass
5959

6060
for rule, desc in rules:
6161
regObj = getCompiledRegex(rule)
62-
if regObj.search(string, re.IGNORECASE):
62+
if regObj.search(string):
6363
logger.warn("highly probable IDS/IPS detection: '%s'" % desc)

plugins/generic/misc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import re
2626

27+
from lib.core.common import getCompiledRegex
2728
from lib.core.common import normalizePath
2829
from lib.core.common import ntToPosixSlashes
2930
from lib.core.common import posixToNtSlashes
@@ -57,7 +58,7 @@ def getRemoteTempPath(self):
5758
else:
5859
conf.tmpPath = "/tmp"
5960

60-
if re.search("\A[\w]:[\/\\\\]+", conf.tmpPath, re.I):
61+
if getCompiledRegex("(?i)\A[\w]:[\/\\\\]+").search(conf.tmpPath):
6162
kb.os = "Windows"
6263

6364
conf.tmpPath = normalizePath(conf.tmpPath)

0 commit comments

Comments
 (0)