2010-11-28 21:10:54 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
|
|
|
|
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
|
|
|
|
from lib.core.datatype import advancedDict
|
|
|
|
|
|
|
|
def cleanupVals(values, tag):
|
2010-12-01 20:09:52 +03:00
|
|
|
if isinstance(values, basestring):
|
|
|
|
return values
|
|
|
|
|
2010-11-28 21:10:54 +03:00
|
|
|
count = 0
|
|
|
|
|
|
|
|
for value in values:
|
|
|
|
if value.isdigit():
|
|
|
|
value = int(value)
|
2010-12-01 01:40:25 +03:00
|
|
|
else:
|
|
|
|
value = str(value)
|
2010-11-28 21:10:54 +03:00
|
|
|
|
|
|
|
values[count] = value
|
|
|
|
count += 1
|
|
|
|
|
|
|
|
if len(values) == 1 and tag not in ("clause", "where"):
|
|
|
|
values = values[0]
|
|
|
|
|
|
|
|
return values
|
|
|
|
|
|
|
|
def parseXmlNode(node):
|
|
|
|
for element in node.getiterator('boundary'):
|
|
|
|
boundary = advancedDict()
|
|
|
|
|
|
|
|
for child in element.getchildren():
|
|
|
|
if child.text:
|
|
|
|
values = cleanupVals(child.text.split(','), child.tag)
|
|
|
|
boundary[child.tag] = values
|
|
|
|
else:
|
|
|
|
boundary[child.tag] = None
|
|
|
|
|
|
|
|
conf.boundaries.append(boundary)
|
|
|
|
|
|
|
|
for element in node.getiterator('test'):
|
|
|
|
test = advancedDict()
|
|
|
|
|
|
|
|
for child in element.getchildren():
|
|
|
|
if child.text and child.text.strip():
|
2010-12-01 20:09:52 +03:00
|
|
|
values = cleanupVals(child.text.split(',') if child.tag != "epayload" else 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:
|
|
|
|
test[child.tag] = advancedDict()
|
|
|
|
|
|
|
|
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)
|