From 77999fb39db1c8ab07007a4675ed6e58d0ab5999 Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Thu, 20 Jan 2011 21:49:06 +0000 Subject: [PATCH] Allow in --sql-shell to always ('a') retrieve query output. Minor bug fix in case with --columns it is not possible to retrieve a column datatype. --- plugins/generic/enumeration.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins/generic/enumeration.py b/plugins/generic/enumeration.py index a3111fbff..25c08447e 100644 --- a/plugins/generic/enumeration.py +++ b/plugins/generic/enumeration.py @@ -76,6 +76,7 @@ class Enumeration: kb.data.cachedColumns = {} kb.data.dumpedTable = {} kb.data.processChar = None + self.alwaysRetrieveSqlOutput = False def getBanner(self): if not conf.getBanner: @@ -1000,8 +1001,13 @@ class Enumeration: table = {} columns = {} - for column, colType in value: - columns[column] = colType + for columnData in value: + name = columnData[0] + + if len(columnData) == 1: + columns[name] = "" + else: + columns[name] = columnData[1] table[conf.tbl] = columns kb.data.cachedColumns[conf.db] = table @@ -1913,8 +1919,9 @@ class Enumeration: raise sqlmapMissingMandatoryOptionException, errMsg def sqlQuery(self, query): - output = None + output = None sqlType = None + getOutput = None for sqlTitle, sqlStatements in SQL_STATEMENTS.items(): for sqlStatement in sqlStatements: @@ -1923,11 +1930,15 @@ class Enumeration: break - message = "do you want to retrieve the SQL statement output? " - message += "[Y/n] " - getOutput = readInput(message, default="Y") + if not self.alwaysRetrieveSqlOutput: + message = "do you want to retrieve the SQL statement output? " + message += "[Y/n/a] " + getOutput = readInput(message, default="Y") - if not getOutput or getOutput in ("y", "Y"): + if getOutput in ("a", "A"): + self.alwaysRetrieveSqlOutput = True + + if not getOutput or getOutput in ("y", "Y") or self.alwaysRetrieveSqlOutput: infoMsg = "fetching %s query output: '%s'" % (sqlType if sqlType is not None else "SQL", query) logger.info(infoMsg)