mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-07 13:11:29 +00:00
Fixes #405
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user