mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-07-10 10:33:09 +00:00
Minor optimization
This commit is contained in:
parent
291abb0ee8
commit
0033934426
3 changed files with 10 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.7.42"
|
||||
VERSION = "1.10.7.43"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ class _ThreadData(threading.local):
|
|||
self.lastComparisonCode = None
|
||||
self.lastComparisonRatio = None
|
||||
self.lastPageTemplateCleaned = None
|
||||
self.lastPageTemplateJsonMinimized = None
|
||||
self.lastPageTemplateStructural = None
|
||||
self.lastPageTemplate = None
|
||||
self.lastErrorPage = tuple()
|
||||
self.lastHTTPError = None
|
||||
|
|
|
|||
|
|
@ -132,6 +132,11 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
|
|||
page = removeDynamicContent(page)
|
||||
if threadData.lastPageTemplate != kb.pageTemplate:
|
||||
threadData.lastPageTemplateCleaned = removeDynamicContent(kb.pageTemplate)
|
||||
# Same template-identity memoization for the structure-aware projections (§below): the
|
||||
# template is constant across an extraction, so it must not be re-parsed/re-tokenized on
|
||||
# every inference request - only seq2 (from the live page) is recomputed per response
|
||||
threadData.lastPageTemplateJsonMinimized = jsonMinimize(kb.pageTemplate)
|
||||
threadData.lastPageTemplateStructural = "\n".join(sorted(extractStructuralTokens(kb.pageTemplate)))
|
||||
threadData.lastPageTemplate = kb.pageTemplate
|
||||
|
||||
seqMatcher.set_seq1(threadData.lastPageTemplateCleaned)
|
||||
|
|
@ -178,14 +183,14 @@ def _comparison(page, headers, code, getRatioValue, pageLength):
|
|||
# only on a JSON Content-Type with both bodies parseable; any doubt (or an explicit
|
||||
# --text-only/--titles) falls back to the exact text path below.
|
||||
if _isJsonResponse(headers) and not (conf.titles or conf.textOnly or kb.nullConnection):
|
||||
seq1 = jsonMinimize(kb.pageTemplate)
|
||||
seq1 = threadData.lastPageTemplateJsonMinimized # memoized per template (see above)
|
||||
seq2 = jsonMinimize(rawPage)
|
||||
|
||||
# Structure-aware comparison for a structurally-stable (but byte-unstable) HTML page:
|
||||
# compare the value-free tag/class/id skeleton so dynamic text does not perturb the ratio
|
||||
# while a structural change (e.g. a results table appearing/disappearing) still does
|
||||
if seq1 is None and kb.pageStructurallyStable and not (conf.titles or conf.textOnly or kb.nullConnection):
|
||||
_ = "\n".join(sorted(extractStructuralTokens(kb.pageTemplate)))
|
||||
_ = threadData.lastPageTemplateStructural # memoized per template (see above)
|
||||
if _: # only engage when the page actually exposes structure (HTML tags); tagless content falls back to text
|
||||
seq1 = _
|
||||
seq2 = "\n".join(sorted(extractStructuralTokens(rawPage)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue