mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-09 14:11:29 +00:00
Dealing with basesting (one baby step closer to Py3 salvation)
This commit is contained in:
@@ -117,20 +117,20 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||
firstChar = len(partialValue)
|
||||
elif re.search(r"(?i)\b(LENGTH|LEN)\(", expression):
|
||||
firstChar = 0
|
||||
elif (kb.fileReadMode or dump) and conf.firstChar is not None and (isinstance(conf.firstChar, int) or (isinstance(conf.firstChar, basestring) and conf.firstChar.isdigit())):
|
||||
elif (kb.fileReadMode or dump) and conf.firstChar is not None and (isinstance(conf.firstChar, int) or (hasattr(conf.firstChar, "isdigit") and conf.firstChar.isdigit())):
|
||||
firstChar = int(conf.firstChar) - 1
|
||||
if kb.fileReadMode:
|
||||
firstChar <<= 1
|
||||
elif isinstance(firstChar, basestring) and firstChar.isdigit() or isinstance(firstChar, int):
|
||||
elif hasattr(firstChar, "isdigit") and firstChar.isdigit() or isinstance(firstChar, int):
|
||||
firstChar = int(firstChar) - 1
|
||||
else:
|
||||
firstChar = 0
|
||||
|
||||
if re.search(r"(?i)\b(LENGTH|LEN)\(", expression):
|
||||
lastChar = 0
|
||||
elif dump and conf.lastChar is not None and (isinstance(conf.lastChar, int) or (isinstance(conf.lastChar, basestring) and conf.lastChar.isdigit())):
|
||||
elif dump and conf.lastChar is not None and (isinstance(conf.lastChar, int) or (hasattr(conf.lastChar, "isdigit") and conf.lastChar.isdigit())):
|
||||
lastChar = int(conf.lastChar)
|
||||
elif isinstance(lastChar, basestring) and lastChar.isdigit() or isinstance(lastChar, int):
|
||||
elif hasattr(lastChar, "isdigit") and lastChar.isdigit() or isinstance(lastChar, int):
|
||||
lastChar = int(lastChar)
|
||||
else:
|
||||
lastChar = 0
|
||||
@@ -143,7 +143,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||
else:
|
||||
expressionUnescaped = unescaper.escape(expression)
|
||||
|
||||
if isinstance(length, basestring) and length.isdigit() or isinstance(length, int):
|
||||
if hasattr(length, "isdigit") and length.isdigit() or isinstance(length, int):
|
||||
length = int(length)
|
||||
else:
|
||||
length = None
|
||||
|
||||
@@ -57,6 +57,7 @@ from lib.core.threads import runThreads
|
||||
from lib.core.unescaper import unescaper
|
||||
from lib.request.connect import Connect as Request
|
||||
from lib.utils.progress import ProgressBar
|
||||
from thirdparty import six
|
||||
|
||||
def _oneShotErrorUse(expression, field=None, chunkTest=False):
|
||||
offset = 1
|
||||
@@ -201,7 +202,7 @@ def _oneShotErrorUse(expression, field=None, chunkTest=False):
|
||||
|
||||
retVal = decodeHexValue(retVal) if conf.hexConvert else retVal
|
||||
|
||||
if isinstance(retVal, basestring):
|
||||
if isinstance(retVal, six.string_types):
|
||||
retVal = htmlunescape(retVal).replace("<br>", "\n")
|
||||
|
||||
retVal = _errorReplaceChars(retVal)
|
||||
@@ -277,7 +278,7 @@ def _formatPartialContent(value):
|
||||
Prepares (possibly hex-encoded) partial content for safe console output
|
||||
"""
|
||||
|
||||
if value and isinstance(value, basestring):
|
||||
if value and isinstance(value, six.string_types):
|
||||
try:
|
||||
value = hexdecode(value)
|
||||
except:
|
||||
@@ -447,7 +448,7 @@ def errorUse(expression, dump=False):
|
||||
value = _errorFields(expression, expressionFields, expressionFieldsList)
|
||||
|
||||
if value and isListLike(value):
|
||||
if len(value) == 1 and isinstance(value[0], basestring):
|
||||
if len(value) == 1 and isinstance(value[0], six.string_types):
|
||||
value = unArrayizeValue(value)
|
||||
elif len(value) > 1 and stopLimit == 1:
|
||||
value = [value]
|
||||
|
||||
@@ -59,6 +59,7 @@ from lib.core.threads import runThreads
|
||||
from lib.core.unescaper import unescaper
|
||||
from lib.request.connect import Connect as Request
|
||||
from lib.utils.progress import ProgressBar
|
||||
from thirdparty import six
|
||||
from thirdparty.odict import OrderedDict
|
||||
|
||||
def _oneShotUnionUse(expression, unpack=True, limited=False):
|
||||
@@ -163,7 +164,7 @@ def _oneShotUnionUse(expression, unpack=True, limited=False):
|
||||
|
||||
def configUnion(char=None, columns=None):
|
||||
def _configUnionChar(char):
|
||||
if not isinstance(char, basestring):
|
||||
if not isinstance(char, six.string_types):
|
||||
return
|
||||
|
||||
kb.uChar = char
|
||||
@@ -172,7 +173,7 @@ def configUnion(char=None, columns=None):
|
||||
kb.uChar = char.replace("[CHAR]", conf.uChar if conf.uChar.isdigit() else "'%s'" % conf.uChar.strip("'"))
|
||||
|
||||
def _configUnionCols(columns):
|
||||
if not isinstance(columns, basestring):
|
||||
if not isinstance(columns, six.string_types):
|
||||
return
|
||||
|
||||
columns = columns.replace(" ", "")
|
||||
@@ -261,7 +262,7 @@ def unionUse(expression, unpack=True, dump=False):
|
||||
infoMsg += "%d %s" % (stopLimit, "entries" if stopLimit > 1 else "entry")
|
||||
logger.info(infoMsg)
|
||||
|
||||
elif count and (not isinstance(count, basestring) or not count.isdigit()):
|
||||
elif count and (not isinstance(count, six.string_types) or not count.isdigit()):
|
||||
warnMsg = "it was not possible to count the number "
|
||||
warnMsg += "of entries for the SQL query provided. "
|
||||
warnMsg += "sqlmap will assume that it returns only "
|
||||
@@ -373,7 +374,7 @@ def unionUse(expression, unpack=True, dump=False):
|
||||
del threadData.shared.buffered[0]
|
||||
|
||||
if conf.verbose == 1 and not (threadData.resumed and kb.suppressResumeInfo) and not threadData.shared.showEta:
|
||||
_ = ','.join("'%s'" % _ for _ in (flattenValue(arrayizeValue(items)) if not isinstance(items, basestring) else [items]))
|
||||
_ = ','.join("'%s'" % _ for _ in (flattenValue(arrayizeValue(items)) if not isinstance(items, six.string_types) else [items]))
|
||||
status = "[%s] [INFO] %s: %s" % (time.strftime("%X"), "resumed" if threadData.resumed else "retrieved", _ if kb.safeCharEncode else safecharencode(_))
|
||||
|
||||
if len(status) > width:
|
||||
|
||||
Reference in New Issue
Block a user