2013-02-14 15:32:17 +04:00
|
|
|
#!/usr/bin/env python
|
2010-11-28 21:10:54 +03:00
|
|
|
|
|
|
|
"""
|
2014-01-13 21:24:49 +04:00
|
|
|
Copyright (c) 2006-2014 sqlmap developers (http://sqlmap.org/)
|
2010-11-28 21:10:54 +03:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
|
|
|
from xml.etree import ElementTree as et
|
|
|
|
|
|
|
|
from lib.core.data import conf
|
|
|
|
from lib.core.data import paths
|
2011-07-08 10:02:31 +04:00
|
|
|
from lib.core.datatype import AttribDict
|
2010-11-28 21:10:54 +03:00
|
|
|
|
2010-12-03 13:51:27 +03:00
|
|
|
def cleanupVals(text, tag):
|
|
|
|
if tag in ("clause", "where"):
|
|
|
|
text = text.split(',')
|
2010-12-01 20:09:52 +03:00
|
|
|
|
2010-12-03 13:51:27 +03:00
|
|
|
if isinstance(text, basestring):
|
2012-12-10 20:20:04 +04:00
|
|
|
text = int(text) if text.isdigit() else str(text)
|
2010-12-03 13:51:27 +03:00
|
|
|
|
|
|
|
elif isinstance(text, list):
|
|
|
|
count = 0
|
|
|
|
|
2012-12-10 20:20:04 +04:00
|
|
|
for _ in text:
|
|
|
|
text[count] = int(_) if _.isdigit() else str(_)
|
2010-12-03 13:51:27 +03:00
|
|
|
count += 1
|
2010-11-28 21:10:54 +03:00
|
|
|
|
2010-12-03 13:51:27 +03:00
|
|
|
if len(text) == 1 and tag not in ("clause", "where"):
|
|
|
|
text = text[0]
|
2010-11-28 21:10:54 +03:00
|
|
|
|
2010-12-03 13:51:27 +03:00
|
|
|
return text
|
2010-11-28 21:10:54 +03:00
|
|
|
|
|
|
|
def parseXmlNode(node):
|
|
|
|
for element in node.getiterator('boundary'):
|
2011-07-08 10:02:31 +04:00
|
|
|
boundary = AttribDict()
|
2010-11-28 21:10:54 +03:00
|
|
|
|
|
|
|
for child in element.getchildren():
|
|
|
|
if child.text:
|
2010-12-03 13:51:27 +03:00
|
|
|
values = cleanupVals(child.text, child.tag)
|
2010-11-28 21:10:54 +03:00
|
|
|
boundary[child.tag] = values
|
|
|
|
else:
|
|
|
|
boundary[child.tag] = None
|
|
|
|
|
|
|
|
conf.boundaries.append(boundary)
|
|
|
|
|
|
|
|
for element in node.getiterator('test'):
|
2011-07-08 10:02:31 +04:00
|
|
|
test = AttribDict()
|
2010-11-28 21:10:54 +03:00
|
|
|
|
|
|
|
for child in element.getchildren():
|
|
|
|
if child.text and child.text.strip():
|
2010-12-03 13:51:27 +03:00
|
|
|
values = cleanupVals(child.text, child.tag)
|
2010-11-28 21:10:54 +03:00
|
|
|
test[child.tag] = values
|
|
|
|
else:
|
|
|
|
if len(child.getchildren()) == 0:
|
|
|
|
test[child.tag] = None
|
|
|
|
continue
|
|
|
|
else:
|
2011-07-08 10:02:31 +04:00
|
|
|
test[child.tag] = AttribDict()
|
2010-11-28 21:10:54 +03:00
|
|
|
|
|
|
|
for gchild in child.getchildren():
|
|
|
|
if gchild.tag in test[child.tag]:
|
|
|
|
prevtext = test[child.tag][gchild.tag]
|
|
|
|
test[child.tag][gchild.tag] = [prevtext, gchild.text]
|
|
|
|
else:
|
|
|
|
test[child.tag][gchild.tag] = gchild.text
|
|
|
|
|
|
|
|
conf.tests.append(test)
|
|
|
|
|
|
|
|
def loadPayloads():
|
|
|
|
doc = et.parse(paths.PAYLOADS_XML)
|
|
|
|
root = doc.getroot()
|
|
|
|
parseXmlNode(root)
|