minor refactoring

This commit is contained in:
Miroslav Stampar 2011-04-07 10:27:22 +00:00
parent 1880f18367
commit 845533e92f
2 changed files with 18 additions and 14 deletions

View File

@ -125,7 +125,6 @@ class PAYLOAD:
UNION = "union"
class TECHNIQUE:
HEURISTIC = 0
BOOLEAN = 1
ERROR = 2
UNION = 3

View File

@ -606,26 +606,31 @@ def __setOS():
raise sqlmapUnsupportedDBMSException, errMsg
def __setTechnique():
validTechniques = getPublicTypeMembers(PAYLOAD.TECHNIQUE)
validTechniques = sorted(getPublicTypeMembers(PAYLOAD.TECHNIQUE), key=lambda x: x[1])
validLetters = map(lambda x: x[0][0].upper(), validTechniques)
if conf.tech and isinstance(conf.tech, basestring):
selTechniques = []
for t in conf.tech:
if t.upper() not in ("B", "E", "U", "S", "T"):
# e.g.: BEUST
if not conf.tech.isdigit():
for letter in conf.tech:
if letter.upper() not in validLetters:
errMsg = "value for --technique must be a string composed "
errMsg += "by the letters B, E, U, S and T. Refer to the "
errMsg += "by the letters %s. Refer to the " % ",".join(validLetters)
errMsg += "user's manual for details"
raise sqlmapSyntaxException, errMsg
for validTech, validInt in validTechniques:
if t.upper() == validTech[0]:
if letter.upper() == validTech[0]:
selTechniques.append(validInt)
break
conf.tech = selTechniques
# e.g.: 12345
else:
conf.tech = filter(lambda x: x in PAYLOAD.SQLINJECTION, [int(c) for c in str(conf.tech)])
selTechniques = filter(lambda x: x in PAYLOAD.SQLINJECTION, [int(c) for c in str(conf.tech)])
conf.tech = selTechniques
if len(conf.tech) > 0:
# TODO: consider MySQL/PHP/ASP/web backdoor case where stacked