|
45 | 45 | from lib.core.common import getFileItems |
46 | 46 | from lib.core.common import getFileType |
47 | 47 | from lib.core.common import getUnicode |
48 | | -from lib.core.common import isListLike |
49 | 48 | from lib.core.common import normalizePath |
50 | 49 | from lib.core.common import ntToPosixSlashes |
51 | 50 | from lib.core.common import openFile |
|
58 | 57 | from lib.core.common import resetCookieJar |
59 | 58 | from lib.core.common import runningAsAdmin |
60 | 59 | from lib.core.common import safeExpandUser |
| 60 | +from lib.core.common import saveConfig |
61 | 61 | from lib.core.common import setOptimize |
62 | 62 | from lib.core.common import setPaths |
63 | 63 | from lib.core.common import singleTimeWarnMessage |
64 | | -from lib.core.common import UnicodeRawConfigParser |
65 | 64 | from lib.core.common import urldecode |
66 | | -from lib.core.convert import base64unpickle |
67 | 65 | from lib.core.data import conf |
68 | 66 | from lib.core.data import kb |
69 | 67 | from lib.core.data import logger |
|
112 | 110 | from lib.core.settings import DEFAULT_TOR_HTTP_PORTS |
113 | 111 | from lib.core.settings import DEFAULT_TOR_SOCKS_PORTS |
114 | 112 | from lib.core.settings import DUMMY_URL |
115 | | -from lib.core.settings import IGNORE_SAVE_OPTIONS |
116 | 113 | from lib.core.settings import INJECT_HERE_MARK |
117 | 114 | from lib.core.settings import IS_WIN |
118 | 115 | from lib.core.settings import KB_CHARS_BOUNDARY_CHAR |
@@ -2107,53 +2104,7 @@ def _saveConfig(): |
2107 | 2104 | debugMsg = "saving command line options to a sqlmap configuration INI file" |
2108 | 2105 | logger.debug(debugMsg) |
2109 | 2106 |
|
2110 | | - config = UnicodeRawConfigParser() |
2111 | | - userOpts = {} |
2112 | | - |
2113 | | - for family in optDict.keys(): |
2114 | | - userOpts[family] = [] |
2115 | | - |
2116 | | - for option, value in conf.items(): |
2117 | | - for family, optionData in optDict.items(): |
2118 | | - if option in optionData: |
2119 | | - userOpts[family].append((option, value, optionData[option])) |
2120 | | - |
2121 | | - for family, optionData in userOpts.items(): |
2122 | | - config.add_section(family) |
2123 | | - |
2124 | | - optionData.sort() |
2125 | | - |
2126 | | - for option, value, datatype in optionData: |
2127 | | - if datatype and isListLike(datatype): |
2128 | | - datatype = datatype[0] |
2129 | | - |
2130 | | - if option in IGNORE_SAVE_OPTIONS: |
2131 | | - continue |
2132 | | - |
2133 | | - if value is None: |
2134 | | - if datatype == OPTION_TYPE.BOOLEAN: |
2135 | | - value = "False" |
2136 | | - elif datatype in (OPTION_TYPE.INTEGER, OPTION_TYPE.FLOAT): |
2137 | | - if option in defaults: |
2138 | | - value = str(defaults[option]) |
2139 | | - else: |
2140 | | - value = "0" |
2141 | | - elif datatype == OPTION_TYPE.STRING: |
2142 | | - value = "" |
2143 | | - |
2144 | | - if isinstance(value, basestring): |
2145 | | - value = value.replace("\n", "\n ") |
2146 | | - |
2147 | | - config.set(family, option, value) |
2148 | | - |
2149 | | - confFP = openFile(conf.saveConfig, "wb") |
2150 | | - |
2151 | | - try: |
2152 | | - config.write(confFP) |
2153 | | - except IOError, ex: |
2154 | | - errMsg = "something went wrong while trying " |
2155 | | - errMsg += "to write to the configuration file '%s' ('%s')" % (conf.saveConfig, getSafeExString(ex)) |
2156 | | - raise SqlmapSystemException(errMsg) |
| 2107 | + saveConfig(conf, conf.saveConfig) |
2157 | 2108 |
|
2158 | 2109 | infoMsg = "saved command line options to the configuration file '%s'" % conf.saveConfig |
2159 | 2110 | logger.info(infoMsg) |
@@ -2229,26 +2180,6 @@ def _mergeOptions(inputOptions, overrideOptions): |
2229 | 2180 | @type inputOptions: C{instance} |
2230 | 2181 | """ |
2231 | 2182 |
|
2232 | | - if inputOptions.pickledOptions: |
2233 | | - try: |
2234 | | - unpickledOptions = base64unpickle(inputOptions.pickledOptions, unsafe=True) |
2235 | | - |
2236 | | - if type(unpickledOptions) == dict: |
2237 | | - unpickledOptions = AttribDict(unpickledOptions) |
2238 | | - |
2239 | | - _normalizeOptions(unpickledOptions) |
2240 | | - |
2241 | | - unpickledOptions["pickledOptions"] = None |
2242 | | - for key in inputOptions: |
2243 | | - if key not in unpickledOptions: |
2244 | | - unpickledOptions[key] = inputOptions[key] |
2245 | | - |
2246 | | - inputOptions = unpickledOptions |
2247 | | - except Exception, ex: |
2248 | | - errMsg = "provided invalid value '%s' for option '--pickled-options'" % inputOptions.pickledOptions |
2249 | | - errMsg += " (%s)" % repr(ex) |
2250 | | - raise SqlmapSyntaxException(errMsg) |
2251 | | - |
2252 | 2183 | if inputOptions.configFile: |
2253 | 2184 | configFileParser(inputOptions.configFile) |
2254 | 2185 |
|
@@ -2456,6 +2387,10 @@ def _basicOptionValidation(): |
2456 | 2387 | errMsg = "switch '--dump' is incompatible with switch '--search'" |
2457 | 2388 | raise SqlmapSyntaxException(errMsg) |
2458 | 2389 |
|
| 2390 | + if conf.api and not conf.configFile: |
| 2391 | + errMsg = "switch '--api' requires usage of option '-c'" |
| 2392 | + raise SqlmapSyntaxException(errMsg) |
| 2393 | + |
2459 | 2394 | if conf.data and conf.nullConnection: |
2460 | 2395 | errMsg = "option '--data' is incompatible with switch '--null-connection'" |
2461 | 2396 | raise SqlmapSyntaxException(errMsg) |
|
0 commit comments