mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-03 22:31:34 +00:00
Rewrite from scratch the detection engine. Now it performs checks defined in payload.xml. User can specify its own.
All (hopefully) functionalities should still be working. Added two switches, --level and --risk to specify which injection tests and boundaries to use. The main advantage now is that sqlmap is able to identify initially which injection types are present so for instance if boolean-based blind is not supported, but error-based is, sqlmap will keep going and work!
This commit is contained in:
parent
a8b38ba76b
commit
7e3b24afe6
24 changed files with 1968 additions and 333 deletions
|
|
@ -183,6 +183,14 @@ def cmdLineParser():
|
|||
"HTTP responses when using blind SQL "
|
||||
"injection technique.")
|
||||
|
||||
detection.add_option("--level", dest="level", default=1, type="int",
|
||||
help="Level of tests to perform (1-5, "
|
||||
"default 1)")
|
||||
|
||||
detection.add_option("--risk", dest="risk", default=1, type="int",
|
||||
help="Risk of tests to perform (0-3, "
|
||||
"default 1)")
|
||||
|
||||
detection.add_option("--string", dest="string",
|
||||
help="String to match in page when the "
|
||||
"query is valid")
|
||||
|
|
|
|||
70
lib/parse/payloads.py
Normal file
70
lib/parse/payloads.py
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#!/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):
|
||||
count = 0
|
||||
|
||||
for value in values:
|
||||
if value.isdigit():
|
||||
value = int(value)
|
||||
|
||||
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():
|
||||
values = cleanupVals(child.text.split(','), child.tag)
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue