minor optimization

This commit is contained in:
Miroslav Stampar 2011-12-22 15:42:21 +00:00
parent 8585107e3d
commit 094129a656
2 changed files with 8 additions and 2 deletions

View File

@ -112,6 +112,7 @@ from lib.core.settings import DYNAMICITY_MARK_LENGTH
from lib.core.settings import REFLECTIVE_MISS_THRESHOLD from lib.core.settings import REFLECTIVE_MISS_THRESHOLD
from lib.core.settings import SENSITIVE_DATA_REGEX from lib.core.settings import SENSITIVE_DATA_REGEX
from lib.core.settings import SUPPORTED_OS from lib.core.settings import SUPPORTED_OS
from lib.core.settings import UNION_UNIQUE_FIFO_LENGTH
from lib.core.settings import URI_INJECTION_MARK_CHAR from lib.core.settings import URI_INJECTION_MARK_CHAR
from lib.core.settings import URI_QUESTION_MARKER from lib.core.settings import URI_QUESTION_MARKER
from lib.core.threads import getCurrentThreadData from lib.core.threads import getCurrentThreadData
@ -1336,7 +1337,7 @@ def parseUnionPage(output, unique=True):
if output.startswith(kb.chars.start) and output.endswith(kb.chars.stop): if output.startswith(kb.chars.start) and output.endswith(kb.chars.stop):
regExpr = '%s(.*?)%s' % (kb.chars.start, kb.chars.stop) regExpr = '%s(.*?)%s' % (kb.chars.start, kb.chars.stop)
output = re.finditer(regExpr, output, re.DOTALL | re.IGNORECASE) output = re.finditer(regExpr, output, re.DOTALL | re.IGNORECASE)
_ = set() _ = []
for entry in output: for entry in output:
entry = entry.group(1) entry = entry.group(1)
@ -1344,7 +1345,9 @@ def parseUnionPage(output, unique=True):
if unique: if unique:
key = entry.lower() key = entry.lower()
if key not in _: if key not in _:
_.add(key) _.append(key)
if len(_) > UNION_UNIQUE_FIFO_LENGTH:
_.pop(0)
else: else:
continue continue

View File

@ -115,6 +115,9 @@ UNKNOWN_DBMS_VERSION = "Unknown"
# dynamicity mark length used in dynamicity removal engine # dynamicity mark length used in dynamicity removal engine
DYNAMICITY_MARK_LENGTH = 32 DYNAMICITY_MARK_LENGTH = 32
# length of FIFO buffer for removing possible duplicates in union/inband data retrieval
UNION_UNIQUE_FIFO_LENGTH = 10
# dummy user prefix used in dictionary attack # dummy user prefix used in dictionary attack
DUMMY_USER_PREFIX = "__dummy__" DUMMY_USER_PREFIX = "__dummy__"