mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-01-23 15:54:24 +03:00
prioritization of tests based on DBMS error messages and some comments in common.py
This commit is contained in:
parent
a09716a701
commit
23dc408901
|
@ -17,6 +17,7 @@ from lib.core.agent import agent
|
||||||
from lib.core.common import beep
|
from lib.core.common import beep
|
||||||
from lib.core.common import extractRegexResult
|
from lib.core.common import extractRegexResult
|
||||||
from lib.core.common import getCompiledRegex
|
from lib.core.common import getCompiledRegex
|
||||||
|
from lib.core.common import getInjectionTests
|
||||||
from lib.core.common import getUnicode
|
from lib.core.common import getUnicode
|
||||||
from lib.core.common import popValue
|
from lib.core.common import popValue
|
||||||
from lib.core.common import pushValue
|
from lib.core.common import pushValue
|
||||||
|
@ -77,7 +78,7 @@ def checkSqlInjection(place, parameter, value):
|
||||||
# Set the flag for sql injection test mode
|
# Set the flag for sql injection test mode
|
||||||
kb.testMode = True
|
kb.testMode = True
|
||||||
|
|
||||||
for test in conf.tests:
|
for test in getInjectionTests():
|
||||||
try:
|
try:
|
||||||
title = test.title
|
title = test.title
|
||||||
stype = test.stype
|
stype = test.stype
|
||||||
|
|
|
@ -1750,6 +1750,11 @@ def aliasToDbmsEnum(value):
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def removeDynamicContent(page):
|
def removeDynamicContent(page):
|
||||||
|
"""
|
||||||
|
Removing dynamic content from supplied
|
||||||
|
page basing removal on precalculated
|
||||||
|
dynamic markings
|
||||||
|
"""
|
||||||
if page:
|
if page:
|
||||||
for item in kb.dynamicMarkings:
|
for item in kb.dynamicMarkings:
|
||||||
prefix, suffix = item
|
prefix, suffix = item
|
||||||
|
@ -1763,6 +1768,11 @@ def removeDynamicContent(page):
|
||||||
return page
|
return page
|
||||||
|
|
||||||
def filterStringValue(value, regex):
|
def filterStringValue(value, regex):
|
||||||
|
"""
|
||||||
|
Returns string value consisting only
|
||||||
|
of chars satisfying supplied regular
|
||||||
|
expressson
|
||||||
|
"""
|
||||||
retVal = ""
|
retVal = ""
|
||||||
|
|
||||||
if value:
|
if value:
|
||||||
|
@ -1773,6 +1783,10 @@ def filterStringValue(value, regex):
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def isDBMSVersionAtLeast(version):
|
def isDBMSVersionAtLeast(version):
|
||||||
|
"""
|
||||||
|
Checks if the recognized DBMS version
|
||||||
|
is at least the version specified
|
||||||
|
"""
|
||||||
retVal = None
|
retVal = None
|
||||||
|
|
||||||
if kb.dbmsVersion and kb.dbmsVersion[0] != UNKNOWN_DBMS_VERSION and kb.dbmsVersion[0] != None:
|
if kb.dbmsVersion and kb.dbmsVersion[0] != UNKNOWN_DBMS_VERSION and kb.dbmsVersion[0] != None:
|
||||||
|
@ -1802,6 +1816,10 @@ def isDBMSVersionAtLeast(version):
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def parseSqliteTableSchema(value):
|
def parseSqliteTableSchema(value):
|
||||||
|
"""
|
||||||
|
Parses table column names and types from
|
||||||
|
specified SQLite table schema
|
||||||
|
"""
|
||||||
if value:
|
if value:
|
||||||
table = {}
|
table = {}
|
||||||
columns = {}
|
columns = {}
|
||||||
|
@ -1813,6 +1831,9 @@ def parseSqliteTableSchema(value):
|
||||||
kb.data.cachedColumns[conf.db] = table
|
kb.data.cachedColumns[conf.db] = table
|
||||||
|
|
||||||
def getTechniqueData(technique=None):
|
def getTechniqueData(technique=None):
|
||||||
|
"""
|
||||||
|
Returns injection data for technique specified
|
||||||
|
"""
|
||||||
retVal = None
|
retVal = None
|
||||||
|
|
||||||
if technique and technique in kb.injection.data:
|
if technique and technique in kb.injection.data:
|
||||||
|
@ -1821,9 +1842,17 @@ def getTechniqueData(technique=None):
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def isTechniqueAvailable(technique=None):
|
def isTechniqueAvailable(technique=None):
|
||||||
|
"""
|
||||||
|
Returns True if there is injection data which
|
||||||
|
sqlmap could use for technique specified
|
||||||
|
"""
|
||||||
return getTechniqueData(technique) is not None
|
return getTechniqueData(technique) is not None
|
||||||
|
|
||||||
def initTechnique(technique=None):
|
def initTechnique(technique=None):
|
||||||
|
"""
|
||||||
|
Prepares proper page template and match ratio
|
||||||
|
for technique specified
|
||||||
|
"""
|
||||||
data = getTechniqueData(technique)
|
data = getTechniqueData(technique)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
|
@ -1835,6 +1864,24 @@ def initTechnique(technique=None):
|
||||||
logger.warn(warnMsg)
|
logger.warn(warnMsg)
|
||||||
|
|
||||||
def arrayizeValue(value):
|
def arrayizeValue(value):
|
||||||
|
"""
|
||||||
|
Makes a list out of value if it's not already
|
||||||
|
list itself
|
||||||
|
"""
|
||||||
if not isinstance(value, list):
|
if not isinstance(value, list):
|
||||||
value = [value]
|
value = [value]
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def getInjectionTests():
|
||||||
|
"""
|
||||||
|
Returns prioritized test list by eventually
|
||||||
|
detected DBMS from error messages
|
||||||
|
"""
|
||||||
|
retVal = conf.tests
|
||||||
|
if kb.htmlFp:
|
||||||
|
dbms = kb.htmlFp[-1]
|
||||||
|
retVal = sorted(retVal, key=lambda test: False\
|
||||||
|
if 'details' in test and 'dbms' in test.details\
|
||||||
|
and test.details.dbms == dbms else True)
|
||||||
|
|
||||||
|
return retVal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user