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

Skip to content

Commit 6acf6b1

Browse files
committed
minor update regarding boolean logic comparison mechanism
1 parent 5469186 commit 6acf6b1

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

lib/parse/html.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,23 @@ class htmlHandler(ContentHandler):
2626
def __init__(self, page):
2727
ContentHandler.__init__(self)
2828

29-
self.__dbms = None
30-
self.__page = page
29+
self._dbms = None
30+
self._page = page
3131

3232
self.dbms = None
3333

34+
def _markAsErrorPage(self):
35+
threadData = getCurrentThreadData()
36+
threadData.lastErrorPage = (threadData.lastRequestUID, self._page)
37+
3438
def startElement(self, name, attrs):
3539
if name == "dbms":
36-
self.__dbms = attrs.get("value")
40+
self._dbms = attrs.get("value")
3741

3842
elif name == "error":
39-
if re.search(attrs.get("regexp"), self.__page, re.I):
40-
self.dbms = self.__dbms
41-
threadData = getCurrentThreadData()
42-
threadData.lastErrorPage = (threadData.lastRequestUID, self.__page)
43+
if re.search(attrs.get("regexp"), self._page, re.I):
44+
self.dbms = self._dbms
45+
self._markAsErrorPage()
4346

4447
def htmlParser(page):
4548
"""
@@ -59,4 +62,8 @@ def htmlParser(page):
5962
else:
6063
kb.lastParserStatus = None
6164

65+
# generic SQL warning/error messages
66+
if re.search(r"SQL (warning|error|syntax)", page, re.I):
67+
handler._markAsErrorPage()
68+
6269
return handler.dbms

lib/request/comparison.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@
2929
from lib.core.threads import getCurrentThreadData
3030

3131
def comparison(page, headers, code=None, getRatioValue=False, pageLength=None):
32-
return _adjust(_comparison(page, headers, code, getRatioValue, pageLength), getRatioValue)
32+
_ = _adjust(_comparison(page, headers, code, getRatioValue, pageLength), getRatioValue)
33+
return _
3334

3435
def _adjust(condition, getRatioValue):
3536
if not any([conf.string, conf.regexp, conf.code]):
3637
# Negative logic approach is used in raw page comparison scheme as that what is "different" than original
3738
# PAYLOAD.WHERE.NEGATIVE response is considered as True; in switch based approach negative logic is not
3839
# applied as that what is by user considered as True is that what is returned by the comparison mechanism
3940
# itself
40-
retVal = not (condition or False) if kb.negativeLogic else condition
41+
retVal = not condition if kb.negativeLogic and condition is not None else condition
4142
else:
4243
retVal = condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
4344

@@ -67,7 +68,7 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
6768

6869
if page:
6970
# In case of an DBMS error page return None
70-
if not kb.negativeLogic and kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()):
71+
if kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()):
7172
return None
7273

7374
# Dynamic content lines to be excluded before comparison

0 commit comments

Comments
 (0)