def __saveCmdline(): """ Saves the command line options on a sqlmap configuration INI file format. """ if not conf.saveCmdline: return debugMsg = "saving command line options on 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 isinstance(datatype, (list, tuple, set)): datatype = datatype[0] if value is None: if datatype == "boolean": value = "False" elif datatype in ( "integer", "float" ): if option in ( "threads", "verbose" ): value = "1" elif option == "timeout": value = "10" else: value = "0" elif datatype == "string": value = "" if isinstance(value, basestring): value = value.replace("\n", "\n ") config.set(family, option, value) confFP = codecs.open(paths.SQLMAP_CONFIG, "wb", conf.dataEncoding) config.write(confFP) infoMsg = "saved command line options on '%s' configuration file" % paths.SQLMAP_CONFIG logger.info(infoMsg)
def __saveCmdline(): """ Saves the command line options on a sqlmap configuration INI file format. """ if not conf.saveCmdline: return debugMsg = "saving command line options on a sqlmap configuration INI file" logger.debug(debugMsg) 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])) confFP = open(paths.SQLMAP_CONFIG, "w") for family, optionData in userOpts.items(): confFP.write("[%s]\n" % family) optionData.sort() for option, value, datatype in optionData: if value == None: if datatype == "boolean": value = "False" elif datatype in ("integer", "float"): if option in ("threads", "verbose"): value = "1" elif option == "timeout": value = "10" else: value = "0" elif datatype == "string": value = "" if isinstance(value, str): value = value.replace("\n", "\n ") confFP.write("%s = %s\n" % (option, value)) confFP.write("\n") confFP.flush() confFP.close() infoMsg = "saved command line options on '%s' configuration file" % paths.SQLMAP_CONFIG logger.info(infoMsg)
def __saveCmdline(): """ Saves the command line options on a sqlmap configuration INI file format. """ if not conf.saveCmdline: return debugMsg = "saving command line options on a sqlmap configuration INI file" logger.debug(debugMsg) 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])) confFP = open(paths.SQLMAP_CONFIG, "w") for family, optionData in userOpts.items(): confFP.write("[%s]\n" % family) optionData.sort() for option, value, datatype in optionData: if value == None: if datatype == "boolean": value = "False" elif datatype in ( "integer", "float" ): if option in ( "threads", "verbose" ): value = "1" elif option == "timeout": value = "10" else: value = "0" elif datatype == "string": value = "" if isinstance(value, str): value = value.replace("\n", "\n ") confFP.write("%s = %s\n" % (option, value)) confFP.write("\n") confFP.flush() confFP.close() infoMsg = "saved command line options on '%s' configuration file" % paths.SQLMAP_CONFIG logger.info(infoMsg)
def configFileParser(configFile): """ Parse configuration file and save settings into the configuration advanced dictionary. """ global config debugMsg = "parsing configuration file" logger.debug(debugMsg) checkFile(configFile) configFP = codecs.open(configFile, "rb", UNICODE_ENCODING) try: config = UnicodeRawConfigParser() config.readfp(configFP) except MissingSectionHeaderError: errMsg = "you have provided an invalid configuration file" raise sqlmapSyntaxException, errMsg if not config.has_section("Target"): errMsg = "missing a mandatory section 'Target' in the configuration file" raise sqlmapMissingMandatoryOptionException, errMsg condition = not config.has_option("Target", "url") condition &= not config.has_option("Target", "logFile") condition &= not config.has_option("Target", "bulkFile") condition &= not config.has_option("Target", "googleDork") condition &= not config.has_option("Target", "requestFile") condition &= not config.has_option("Target", "wizard") if condition: errMsg = "missing a mandatory option in the configuration file " errMsg += "(url, logFile, bulkFile, googleDork, requestFile or wizard)" raise sqlmapMissingMandatoryOptionException, errMsg for family, optionData in optDict.items(): for option, datatype in optionData.items(): boolean = False integer = False if isinstance(datatype, (list, tuple, set)): datatype = datatype[0] if datatype == "boolean": boolean = True elif datatype == "integer": integer = True configFileProxy(family, option, boolean, integer)
def configFileParser(configFile): """ Parse configuration file and save settings into the configuration advanced dictionary. """ global config debugMsg = "parsing configuration file" logger.debug(debugMsg) checkFile(configFile) configFP = codecs.open(configFile, "rb", UNICODE_ENCODING) try: config = UnicodeRawConfigParser() config.readfp(configFP) except MissingSectionHeaderError: errMsg = "you have provided an invalid configuration file" raise SqlmapSyntaxException(errMsg) if not config.has_section("Target"): errMsg = "missing a mandatory section 'Target' in the configuration file" raise SqlmapMissingMandatoryOptionException(errMsg) condition = not config.has_option("Target", "url") condition &= not config.has_option("Target", "logFile") condition &= not config.has_option("Target", "bulkFile") condition &= not config.has_option("Target", "googleDork") condition &= not config.has_option("Target", "requestFile") condition &= not config.has_option("Target", "wizard") if condition: errMsg = "missing a mandatory option in the configuration file " errMsg += "(url, logFile, bulkFile, googleDork, requestFile or wizard)" raise SqlmapMissingMandatoryOptionException(errMsg) for family, optionData in optDict.items(): for option, datatype in optionData.items(): datatype = unArrayizeValue(datatype) boolean = datatype == "boolean" integer = datatype == "integer" configFileProxy(family, option, boolean, integer)
def configFileParser(configFile): """ Parse configuration file and save settings into the configuration advanced dictionary. """ global config debugMsg = "parsing configuration file" logger.debug(debugMsg) checkFile(configFile) configFP = openFile(configFile, "rb") try: config = UnicodeRawConfigParser() config.readfp(configFP) except Exception as ex: errMsg = "you have provided an invalid and/or unreadable configuration file ('%s')" % getSafeExString( ex) raise SqlmapSyntaxException(errMsg) if not config.has_section("Target"): errMsg = "missing a mandatory section 'Target' in the configuration file" raise SqlmapMissingMandatoryOptionException(errMsg) mandatory = False for option in ("direct", "url", "logFile", "bulkFile", "googleDork", "requestFile", "sitemapUrl", "wizard"): if config.has_option("Target", option) and config.get( "Target", option) or cmdLineOptions.get(option): mandatory = True break if not mandatory: errMsg = "missing a mandatory option in the configuration file " errMsg += "(direct, url, logFile, bulkFile, googleDork, requestFile, sitemapUrl or wizard)" raise SqlmapMissingMandatoryOptionException(errMsg) for family, optionData in list(optDict.items()): for option, datatype in list(optionData.items()): datatype = unArrayizeValue(datatype) configFileProxy(family, option, datatype)
def configFileParser(configFile): """ Parse configuration file and save settings into the configuration advanced dictionary. """ global config debugMsg = "parsing configuration file" logger.debug(debugMsg) checkFile(configFile) configFP = codecs.open(configFile, "rb", UNICODE_ENCODING) config = UnicodeRawConfigParser() config.readfp(configFP) if not config.has_section("Target"): raise NoSectionError, "Target in the configuration file is mandatory" condition = not config.has_option("Target", "url") condition &= not config.has_option("Target", "list") condition &= not config.has_option("Target", "googleDork") if condition: errMsg = "missing a mandatory option in the configuration " errMsg += "file (url, list or googleDork)" raise sqlmapMissingMandatoryOptionException, errMsg for family, optionData in optDict.items(): for option, datatype in optionData.items(): boolean = False integer = False if isinstance(datatype, (list, tuple, set)): datatype = datatype[0] if datatype == "boolean": boolean = True elif datatype == "integer": integer = True configFileProxy(family, option, boolean, integer)
def configFileParser(configFile): """ Parse configuration file and save settings into the configuration advanced dictionary. """ global config debugMsg = "parsing configuration file" logger.debug(debugMsg) checkFile(configFile) configFP = openFile(configFile, "rb") try: config = UnicodeRawConfigParser() config.readfp(configFP) except Exception as ex: errMsg = "you have provided an invalid and/or unreadable configuration file ('%s')" % getSafeExString(ex) raise SqlmapSyntaxException(errMsg) if not config.has_section("Target"): errMsg = "missing a mandatory section 'Target' in the configuration file" raise SqlmapMissingMandatoryOptionException(errMsg) mandatory = False for option in ("direct", "url", "logFile", "bulkFile", "googleDork", "requestFile", "sitemapUrl", "wizard"): if config.has_option("Target", option) and config.get("Target", option) or cmdLineOptions.get(option): mandatory = True break if not mandatory: errMsg = "missing a mandatory option in the configuration file " errMsg += "(direct, url, logFile, bulkFile, googleDork, requestFile, sitemapUrl or wizard)" raise SqlmapMissingMandatoryOptionException(errMsg) for family, optionData in optDict.items(): for option, datatype in optionData.items(): datatype = unArrayizeValue(datatype) configFileProxy(family, option, datatype)
def configFileParser(configFile): """ Parse configuration file and save settings into the configuration advanced dictionary. """ global config debugMsg = "parsing configuration file" logger.debug(debugMsg) checkFile(configFile) config = ConfigParser() config.read(configFile) if not config.has_section("Target"): raise NoSectionError, "Target in the configuration file is mandatory" condition = not config.has_option("Target", "url") condition &= not config.has_option("Target", "list") condition &= not config.has_option("Target", "googleDork") if condition: errMsg = "missing a mandatory option in the configuration " errMsg += "file (url, list or googleDork)" raise sqlmapMissingMandatoryOptionException, errMsg for family, optionData in optDict.items(): for option, data in optionData.items(): boolean = False integer = False if data == "boolean": boolean = True elif data == "integer": integer = True configFileProxy(family, option, boolean, integer)
config.readfp(configFP) except (MissingSectionHeaderError, ParsingError), ex: errMsg = "you have provided an invalid configuration file ('%s')" % str(ex) raise SqlmapSyntaxException(errMsg) if not config.has_section("Target"): errMsg = "missing a mandatory section 'Target' in the configuration file" raise SqlmapMissingMandatoryOptionException(errMsg) condition = not config.has_option("Target", "direct") condition &= not config.has_option("Target", "url") condition &= not config.has_option("Target", "logFile") condition &= not config.has_option("Target", "bulkFile") condition &= not config.has_option("Target", "googleDork") condition &= not config.has_option("Target", "requestFile") condition &= not config.has_option("Target", "wizard") if condition: errMsg = "missing a mandatory option in the configuration file " errMsg += "(direct, url, logFile, bulkFile, googleDork, requestFile or wizard)" raise SqlmapMissingMandatoryOptionException(errMsg) for family, optionData in optDict.items(): for option, datatype in optionData.items(): datatype = unArrayizeValue(datatype) boolean = datatype == "boolean" integer = datatype == "integer" configFileProxy(family, option, boolean, integer)