mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-07-01 10:23:41 +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
|
# Minimum range between minimum and maximum of statistical set
|
||||||
MIN_STATISTICAL_RANGE = 0.01
|
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.data import logger
|
||||||
from lib.core.settings import CONSTANT_RATIO
|
from lib.core.settings import CONSTANT_RATIO
|
||||||
from lib.core.settings import DIFF_TOLERANCE
|
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 LOWER_RATIO_BOUND
|
||||||
from lib.core.settings import UPPER_RATIO_BOUND
|
from lib.core.settings import UPPER_RATIO_BOUND
|
||||||
from lib.core.threads import getCurrentThreadData
|
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:
|
if page is None and pageLength is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -36,11 +38,13 @@ def comparison(page, getSeqMatcher=False, pageLength=None):
|
||||||
if page:
|
if page:
|
||||||
# String to match in page when the query is valid
|
# String to match in page when the query is valid
|
||||||
if conf.string:
|
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
|
# Regular expression to match in page when the query is valid
|
||||||
if conf.regexp:
|
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
|
# In case of an DBMS error page return None
|
||||||
if kb.errorIsNone and (wasLastRequestDBMSError() or wasLastRequestHTTPError()):
|
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
|
# If it has been requested to return the ratio and not a comparison
|
||||||
# response
|
# response
|
||||||
if getSeqMatcher:
|
if getRatioValue:
|
||||||
return ratio
|
return ratio
|
||||||
|
|
||||||
elif ratio > UPPER_RATIO_BOUND:
|
elif ratio > UPPER_RATIO_BOUND:
|
||||||
|
|
|
@ -369,7 +369,7 @@ class Connect:
|
||||||
return page, responseHeaders
|
return page, responseHeaders
|
||||||
|
|
||||||
@staticmethod
|
@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
|
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
|
and returns its page MD5 hash or a boolean value in case of
|
||||||
|
@ -481,9 +481,9 @@ class Connect:
|
||||||
|
|
||||||
if content or response:
|
if content or response:
|
||||||
return page, headers
|
return page, headers
|
||||||
elif getSeqMatcher:
|
elif getRatioValue:
|
||||||
return comparison(page, getSeqMatcher=False, pageLength=pageLength), comparison(page, getSeqMatcher=True, pageLength=pageLength)
|
return comparison(page, getRatioValue=False, pageLength=pageLength), comparison(page, getRatioValue=True, pageLength=pageLength)
|
||||||
elif pageLength or page:
|
elif pageLength or page:
|
||||||
return comparison(page, getSeqMatcher, pageLength)
|
return comparison(page, getRatioValue, pageLength)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user