mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-03-03 19:55:47 +03:00
refactoring
This commit is contained in:
parent
9a1a28c804
commit
e4933f0c92
|
@ -235,3 +235,9 @@ MAX_NUMBER_OF_THREADS = 10
|
|||
|
||||
# Minimum range between minimum and maximum of statistical set
|
||||
MIN_STATISTICAL_RANGE = 0.01
|
||||
|
||||
# Minimum value for comparison ratio
|
||||
MIN_RATIO = 0.0
|
||||
|
||||
# Maximum value for comparison ratio
|
||||
MAX_RATIO = 1.0
|
||||
|
|
|
@ -20,11 +20,13 @@ from lib.core.data import kb
|
|||
from lib.core.data import logger
|
||||
from lib.core.settings import CONSTANT_RATIO
|
||||
from lib.core.settings import DIFF_TOLERANCE
|
||||
from lib.core.settings import MIN_RATIO
|
||||
from lib.core.settings import MAX_RATIO
|
||||
from lib.core.settings import LOWER_RATIO_BOUND
|
||||
from lib.core.settings import UPPER_RATIO_BOUND
|
||||
from lib.core.threads import getCurrentThreadData
|
||||
|
||||
def comparison(page, getSeqMatcher=False, pageLength=None):
|
||||
def comparison(page, getRatioValue=False, pageLength=None):
|
||||
if page is None and pageLength is None:
|
||||
return None
|
||||
|
||||
|
@ -36,11 +38,13 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
|
|||
if page:
|
||||
# String to match in page when the query is valid
|
||||
if conf.string:
|
||||
return conf.string in page
|
||||
condition = conf.string in page
|
||||
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
|
||||
|
||||
# Regular expression to match in page when the query is valid
|
||||
if conf.regexp:
|
||||
return re.search(conf.regexp, page, re.I | re.M) is not None
|
||||
condition = re.search(conf.regexp, page, re.I | re.M) is not None
|
||||
return condition if not getRatioValue else (MAX_RATIO if condition else MIN_RATIO)
|
||||
|
||||
# In case of an DBMS error page return None
|
||||
if kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()):
|
||||
|
@ -76,7 +80,7 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
|
|||
|
||||
# If it has been requested to return the ratio and not a comparison
|
||||
# response
|
||||
if getSeqMatcher:
|
||||
if getRatioValue:
|
||||
return ratio
|
||||
|
||||
elif ratio > UPPER_RATIO_BOUND:
|
||||
|
|
|
@ -369,7 +369,7 @@ class Connect:
|
|||
return page, responseHeaders
|
||||
|
||||
@staticmethod
|
||||
def queryPage(value=None, place=None, content=False, getSeqMatcher=False, silent=False, method=None, timeBasedCompare=False, noteResponseTime=True, auxHeaders=None, response=False, raise404=None):
|
||||
def queryPage(value=None, place=None, content=False, getRatioValue=False, silent=False, method=None, timeBasedCompare=False, noteResponseTime=True, auxHeaders=None, response=False, raise404=None):
|
||||
"""
|
||||
This method calls a function to get the target url page content
|
||||
and returns its page MD5 hash or a boolean value in case of
|
||||
|
@ -481,9 +481,9 @@ class Connect:
|
|||
|
||||
if content or response:
|
||||
return page, headers
|
||||
elif getSeqMatcher:
|
||||
return comparison(page, getSeqMatcher=False, pageLength=pageLength), comparison(page, getSeqMatcher=True, pageLength=pageLength)
|
||||
elif getRatioValue:
|
||||
return comparison(page, getRatioValue=False, pageLength=pageLength), comparison(page, getRatioValue=True, pageLength=pageLength)
|
||||
elif pageLength or page:
|
||||
return comparison(page, getSeqMatcher, pageLength)
|
||||
return comparison(page, getRatioValue, pageLength)
|
||||
else:
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue
Block a user