MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _comparison

Function _comparison

lib/request/comparison.py:61–220  ·  view source on GitHub ↗
(page, headers, code, getRatioValue, pageLength)

Source from the content-addressed store, hash-verified

59 return retVal
60
61def _comparison(page, headers, code, getRatioValue, pageLength):
62 threadData = getCurrentThreadData()
63
64 if kb.testMode:
65 threadData.lastComparisonHeaders = listToStrValue(_ for _ in headers.headers if not _.startswith("%s:" % URI_HTTP_HEADER)) if headers else ""
66 threadData.lastComparisonPage = page
67 threadData.lastComparisonCode = code
68
69 if page is None and pageLength is None:
70 return None
71
72 if any((conf.string, conf.notString, conf.regexp)):
73 rawResponse = "%s%s" % (listToStrValue(_ for _ in headers.headers if not _.startswith("%s:" % URI_HTTP_HEADER)) if headers else "", page)
74
75 # String to match in page when the query is True
76 if conf.string:
77 return conf.string in rawResponse
78
79 # String to match in page when the query is False
80 if conf.notString:
81 if conf.notString in rawResponse:
82 return False
83 else:
84 if kb.errorIsNone and (wasLastResponseDBMSError() or wasLastResponseHTTPError()):
85 return None
86 else:
87 return True
88
89 # Regular expression to match in page when the query is True and/or valid
90 if conf.regexp:
91 return re.search(conf.regexp, rawResponse, re.I | re.M) is not None
92
93 # HTTP code to match when the query is valid
94 if conf.code:
95 return conf.code == code
96
97 seqMatcher = threadData.seqMatcher
98 seqMatcher.set_seq1(kb.pageTemplate)
99
100 if page:
101 # In case of an DBMS error page return None
102 if kb.errorIsNone and (wasLastResponseDBMSError() or wasLastResponseHTTPError()) and not kb.negativeLogic:
103 if not (wasLastResponseHTTPError() and getLastRequestHTTPError() in (conf.ignoreCode or [])):
104 return None
105
106 # Dynamic content lines to be excluded before comparison
107 if not kb.nullConnection:
108 page = removeDynamicContent(page)
109 if threadData.lastPageTemplate != kb.pageTemplate:
110 threadData.lastPageTemplateCleaned = removeDynamicContent(kb.pageTemplate)
111 threadData.lastPageTemplate = kb.pageTemplate
112
113 seqMatcher.set_seq1(threadData.lastPageTemplateCleaned)
114
115 if not pageLength:
116 pageLength = len(page)
117
118 if kb.nullConnection and pageLength:

Callers 1

comparisonFunction · 0.85

Calls 14

getCurrentThreadDataFunction · 0.90
listToStrValueFunction · 0.90
wasLastResponseDBMSErrorFunction · 0.90
wasLastResponseHTTPErrorFunction · 0.90
getLastRequestHTTPErrorFunction · 0.90
removeDynamicContentFunction · 0.90
getBytesFunction · 0.90
extractRegexResultFunction · 0.90
getFilteredPageContentFunction · 0.90
roundFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…