mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-06 06:39:02 +00:00
Fixes #405
This commit is contained in:
@@ -72,6 +72,7 @@ from lib.core.enums import HEURISTIC_TEST
|
||||
from lib.core.enums import HTTP_HEADER
|
||||
from lib.core.enums import HTTPMETHOD
|
||||
from lib.core.enums import MKSTEMP_PREFIX
|
||||
from lib.core.enums import OPTION_TYPE
|
||||
from lib.core.enums import OS
|
||||
from lib.core.enums import PLACE
|
||||
from lib.core.enums import PAYLOAD
|
||||
@@ -112,6 +113,7 @@ from lib.core.settings import GITHUB_REPORT_OAUTH_TOKEN
|
||||
from lib.core.settings import GOOGLE_ANALYTICS_COOKIE_PREFIX
|
||||
from lib.core.settings import HASHDB_MILESTONE_VALUE
|
||||
from lib.core.settings import HOST_ALIASES
|
||||
from lib.core.settings import IGNORE_SAVE_OPTIONS
|
||||
from lib.core.settings import INFERENCE_UNKNOWN_CHAR
|
||||
from lib.core.settings import INVALID_UNICODE_CHAR_FORMAT
|
||||
from lib.core.settings import IP_ADDRESS_REGEX
|
||||
@@ -1145,7 +1147,7 @@ def banner():
|
||||
This function prints sqlmap banner with its version
|
||||
"""
|
||||
|
||||
if not any(_ in sys.argv for _ in ("--version", "--pickled-options")):
|
||||
if not any(_ in sys.argv for _ in ("--version", "--api")):
|
||||
_ = BANNER
|
||||
|
||||
if not getattr(LOGGER_HANDLER, "is_tty", False) or "--disable-coloring" in sys.argv:
|
||||
@@ -2928,6 +2930,58 @@ def setOptimize():
|
||||
debugMsg = "turning off switch '--null-connection' used indirectly by switch '-o'"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
def saveConfig(conf, filename):
|
||||
"""
|
||||
Saves conf to configuration filename
|
||||
"""
|
||||
|
||||
config = UnicodeRawConfigParser()
|
||||
userOpts = {}
|
||||
|
||||
for family in optDict.keys():
|
||||
userOpts[family] = []
|
||||
|
||||
for option, value in conf.items():
|
||||
for family, optionData in optDict.items():
|
||||
if option in optionData:
|
||||
userOpts[family].append((option, value, optionData[option]))
|
||||
|
||||
for family, optionData in userOpts.items():
|
||||
config.add_section(family)
|
||||
|
||||
optionData.sort()
|
||||
|
||||
for option, value, datatype in optionData:
|
||||
if datatype and isListLike(datatype):
|
||||
datatype = datatype[0]
|
||||
|
||||
if option in IGNORE_SAVE_OPTIONS:
|
||||
continue
|
||||
|
||||
if value is None:
|
||||
if datatype == OPTION_TYPE.BOOLEAN:
|
||||
value = "False"
|
||||
elif datatype in (OPTION_TYPE.INTEGER, OPTION_TYPE.FLOAT):
|
||||
if option in defaults:
|
||||
value = str(defaults[option])
|
||||
else:
|
||||
value = "0"
|
||||
elif datatype == OPTION_TYPE.STRING:
|
||||
value = ""
|
||||
|
||||
if isinstance(value, basestring):
|
||||
value = value.replace("\n", "\n ")
|
||||
|
||||
config.set(family, option, value)
|
||||
|
||||
with openFile(filename, "wb") as f:
|
||||
try:
|
||||
config.write(f)
|
||||
except IOError, ex:
|
||||
errMsg = "something went wrong while trying "
|
||||
errMsg += "to write to the configuration file '%s' ('%s')" % (filename, getSafeExString(ex))
|
||||
raise SqlmapSystemException(errMsg)
|
||||
|
||||
def initTechnique(technique=None):
|
||||
"""
|
||||
Prepares data for technique specified
|
||||
|
||||
@@ -274,6 +274,7 @@ DEPRECATED_OPTIONS = {
|
||||
"--auth-private": "use '--auth-file' instead",
|
||||
"--check-payload": None,
|
||||
"--check-waf": None,
|
||||
"--pickled-options": "use '--api -c ...' instead",
|
||||
}
|
||||
|
||||
DUMP_DATA_PREPROCESS = {
|
||||
|
||||
@@ -364,6 +364,7 @@ class MKSTEMP_PREFIX:
|
||||
HASHES = "sqlmaphashes-"
|
||||
CRAWLER = "sqlmapcrawler-"
|
||||
IPC = "sqlmapipc-"
|
||||
CONFIG = "sqlmapconfig-"
|
||||
TESTING = "sqlmaptesting-"
|
||||
RESULTS = "sqlmapresults-"
|
||||
COOKIE_JAR = "sqlmapcookiejar-"
|
||||
|
||||
@@ -45,7 +45,6 @@ from lib.core.common import getConsoleWidth
|
||||
from lib.core.common import getFileItems
|
||||
from lib.core.common import getFileType
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.common import isListLike
|
||||
from lib.core.common import normalizePath
|
||||
from lib.core.common import ntToPosixSlashes
|
||||
from lib.core.common import openFile
|
||||
@@ -58,12 +57,11 @@ from lib.core.common import readInput
|
||||
from lib.core.common import resetCookieJar
|
||||
from lib.core.common import runningAsAdmin
|
||||
from lib.core.common import safeExpandUser
|
||||
from lib.core.common import saveConfig
|
||||
from lib.core.common import setOptimize
|
||||
from lib.core.common import setPaths
|
||||
from lib.core.common import singleTimeWarnMessage
|
||||
from lib.core.common import UnicodeRawConfigParser
|
||||
from lib.core.common import urldecode
|
||||
from lib.core.convert import base64unpickle
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
@@ -112,7 +110,6 @@ from lib.core.settings import DEFAULT_PAGE_ENCODING
|
||||
from lib.core.settings import DEFAULT_TOR_HTTP_PORTS
|
||||
from lib.core.settings import DEFAULT_TOR_SOCKS_PORTS
|
||||
from lib.core.settings import DUMMY_URL
|
||||
from lib.core.settings import IGNORE_SAVE_OPTIONS
|
||||
from lib.core.settings import INJECT_HERE_MARK
|
||||
from lib.core.settings import IS_WIN
|
||||
from lib.core.settings import KB_CHARS_BOUNDARY_CHAR
|
||||
@@ -2107,53 +2104,7 @@ def _saveConfig():
|
||||
debugMsg = "saving command line options to a sqlmap configuration INI file"
|
||||
logger.debug(debugMsg)
|
||||
|
||||
config = UnicodeRawConfigParser()
|
||||
userOpts = {}
|
||||
|
||||
for family in optDict.keys():
|
||||
userOpts[family] = []
|
||||
|
||||
for option, value in conf.items():
|
||||
for family, optionData in optDict.items():
|
||||
if option in optionData:
|
||||
userOpts[family].append((option, value, optionData[option]))
|
||||
|
||||
for family, optionData in userOpts.items():
|
||||
config.add_section(family)
|
||||
|
||||
optionData.sort()
|
||||
|
||||
for option, value, datatype in optionData:
|
||||
if datatype and isListLike(datatype):
|
||||
datatype = datatype[0]
|
||||
|
||||
if option in IGNORE_SAVE_OPTIONS:
|
||||
continue
|
||||
|
||||
if value is None:
|
||||
if datatype == OPTION_TYPE.BOOLEAN:
|
||||
value = "False"
|
||||
elif datatype in (OPTION_TYPE.INTEGER, OPTION_TYPE.FLOAT):
|
||||
if option in defaults:
|
||||
value = str(defaults[option])
|
||||
else:
|
||||
value = "0"
|
||||
elif datatype == OPTION_TYPE.STRING:
|
||||
value = ""
|
||||
|
||||
if isinstance(value, basestring):
|
||||
value = value.replace("\n", "\n ")
|
||||
|
||||
config.set(family, option, value)
|
||||
|
||||
confFP = openFile(conf.saveConfig, "wb")
|
||||
|
||||
try:
|
||||
config.write(confFP)
|
||||
except IOError, ex:
|
||||
errMsg = "something went wrong while trying "
|
||||
errMsg += "to write to the configuration file '%s' ('%s')" % (conf.saveConfig, getSafeExString(ex))
|
||||
raise SqlmapSystemException(errMsg)
|
||||
saveConfig(conf, conf.saveConfig)
|
||||
|
||||
infoMsg = "saved command line options to the configuration file '%s'" % conf.saveConfig
|
||||
logger.info(infoMsg)
|
||||
@@ -2229,26 +2180,6 @@ def _mergeOptions(inputOptions, overrideOptions):
|
||||
@type inputOptions: C{instance}
|
||||
"""
|
||||
|
||||
if inputOptions.pickledOptions:
|
||||
try:
|
||||
unpickledOptions = base64unpickle(inputOptions.pickledOptions, unsafe=True)
|
||||
|
||||
if type(unpickledOptions) == dict:
|
||||
unpickledOptions = AttribDict(unpickledOptions)
|
||||
|
||||
_normalizeOptions(unpickledOptions)
|
||||
|
||||
unpickledOptions["pickledOptions"] = None
|
||||
for key in inputOptions:
|
||||
if key not in unpickledOptions:
|
||||
unpickledOptions[key] = inputOptions[key]
|
||||
|
||||
inputOptions = unpickledOptions
|
||||
except Exception, ex:
|
||||
errMsg = "provided invalid value '%s' for option '--pickled-options'" % inputOptions.pickledOptions
|
||||
errMsg += " (%s)" % repr(ex)
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
if inputOptions.configFile:
|
||||
configFileParser(inputOptions.configFile)
|
||||
|
||||
@@ -2456,6 +2387,10 @@ def _basicOptionValidation():
|
||||
errMsg = "switch '--dump' is incompatible with switch '--search'"
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
if conf.api and not conf.configFile:
|
||||
errMsg = "switch '--api' requires usage of option '-c'"
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
if conf.data and conf.nullConnection:
|
||||
errMsg = "option '--data' is incompatible with switch '--null-connection'"
|
||||
raise SqlmapSyntaxException(errMsg)
|
||||
|
||||
@@ -243,5 +243,10 @@ optDict = {
|
||||
"liveTest": "boolean",
|
||||
"stopFail": "boolean",
|
||||
"runCase": "string",
|
||||
},
|
||||
"API": {
|
||||
"api": "boolean",
|
||||
"taskid": "string",
|
||||
"database": "string",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
|
||||
from lib.core.enums import OS
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.1.4.11"
|
||||
VERSION = "1.1.4.12"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
||||
Reference in New Issue
Block a user