mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-21 05:39:16 +00:00
code refactoring: split boundaries and payloads XML files
This commit is contained in:
@@ -1085,6 +1085,7 @@ def setPaths():
|
||||
paths.SQLMAP_UDF_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "udf")
|
||||
paths.SQLMAP_XML_PATH = os.path.join(paths.SQLMAP_ROOT_PATH, "xml")
|
||||
paths.SQLMAP_XML_BANNER_PATH = os.path.join(paths.SQLMAP_XML_PATH, "banner")
|
||||
paths.SQLMAP_XML_PAYLOADS_PATH = os.path.join(paths.SQLMAP_XML_PATH, "payloads")
|
||||
|
||||
_ = os.path.join(os.path.expanduser("~"), ".sqlmap")
|
||||
paths.SQLMAP_OUTPUT_PATH = getUnicode(paths.get("SQLMAP_OUTPUT_PATH", os.path.join(_, "output")), encoding=sys.getfilesystemencoding())
|
||||
@@ -1105,7 +1106,7 @@ def setPaths():
|
||||
paths.USER_AGENTS = os.path.join(paths.SQLMAP_TXT_PATH, "user-agents.txt")
|
||||
paths.WORDLIST = os.path.join(paths.SQLMAP_TXT_PATH, "wordlist.zip")
|
||||
paths.ERRORS_XML = os.path.join(paths.SQLMAP_XML_PATH, "errors.xml")
|
||||
paths.PAYLOADS_XML = os.path.join(paths.SQLMAP_XML_PATH, "payloads.xml")
|
||||
paths.BOUNDARIES_XML = os.path.join(paths.SQLMAP_XML_PATH, "boundaries.xml")
|
||||
paths.LIVE_TESTS_XML = os.path.join(paths.SQLMAP_XML_PATH, "livetests.xml")
|
||||
paths.QUERIES_XML = os.path.join(paths.SQLMAP_XML_PATH, "queries.xml")
|
||||
paths.GENERIC_XML = os.path.join(paths.SQLMAP_XML_BANNER_PATH, "generic.xml")
|
||||
|
||||
@@ -130,6 +130,7 @@ from lib.core.settings import WEBSCARAB_SPLITTER
|
||||
from lib.core.threads import getCurrentThreadData
|
||||
from lib.core.update import update
|
||||
from lib.parse.configfile import configFileParser
|
||||
from lib.parse.payloads import loadBoundaries
|
||||
from lib.parse.payloads import loadPayloads
|
||||
from lib.parse.sitemap import parseSitemap
|
||||
from lib.request.basic import checkCharEncoding
|
||||
@@ -2400,6 +2401,7 @@ def init():
|
||||
_setWriteFile()
|
||||
_setMetasploit()
|
||||
_setDBMSAuthentication()
|
||||
loadBoundaries()
|
||||
loadPayloads()
|
||||
_setPrefixSuffix()
|
||||
update()
|
||||
|
||||
@@ -5,6 +5,8 @@ Copyright (c) 2006-2015 sqlmap developers (http://sqlmap.org/)
|
||||
See the file 'doc/COPYING' for copying permission
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from xml.etree import ElementTree as et
|
||||
|
||||
from lib.core.data import conf
|
||||
@@ -67,14 +69,32 @@ def parseXmlNode(node):
|
||||
|
||||
conf.tests.append(test)
|
||||
|
||||
def loadPayloads():
|
||||
def loadBoundaries():
|
||||
try:
|
||||
doc = et.parse(paths.PAYLOADS_XML)
|
||||
doc = et.parse(paths.BOUNDARIES_XML)
|
||||
except Exception, ex:
|
||||
errMsg = "something seems to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (paths.PAYLOADS_XML, ex)
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (paths.BOUNDARIES_XML, ex)
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
|
||||
root = doc.getroot()
|
||||
parseXmlNode(root)
|
||||
|
||||
def loadPayloads():
|
||||
payloadFiles = os.listdir(paths.SQLMAP_XML_PAYLOADS_PATH)
|
||||
payloadFiles.sort()
|
||||
|
||||
for payloadFile in payloadFiles:
|
||||
payloadFilePath = os.path.join(paths.SQLMAP_XML_PAYLOADS_PATH, payloadFile)
|
||||
|
||||
try:
|
||||
doc = et.parse(payloadFilePath)
|
||||
except Exception, ex:
|
||||
errMsg = "something seems to be wrong with "
|
||||
errMsg += "the file '%s' ('%s'). Please make " % (payloadFilePath, ex)
|
||||
errMsg += "sure that you haven't made any changes to it"
|
||||
raise SqlmapInstallationException, errMsg
|
||||
|
||||
root = doc.getroot()
|
||||
parseXmlNode(root)
|
||||
|
||||
Reference in New Issue
Block a user