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" UNION = "union"
class TECHNIQUE: class TECHNIQUE:
HEURISTIC = 0
BOOLEAN = 1 BOOLEAN = 1
ERROR = 2 ERROR = 2
UNION = 3 UNION = 3

View File

@ -606,26 +606,31 @@ def __setOS():
raise sqlmapUnsupportedDBMSException, errMsg raise sqlmapUnsupportedDBMSException, errMsg
def __setTechnique(): 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): if conf.tech and isinstance(conf.tech, basestring):
selTechniques = [] selTechniques = []
for t in conf.tech: # e.g.: BEUST
if t.upper() not in ("B", "E", "U", "S", "T"): 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 = "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" errMsg += "user's manual for details"
raise sqlmapSyntaxException, errMsg raise sqlmapSyntaxException, errMsg
for validTech, validInt in validTechniques: for validTech, validInt in validTechniques:
if t.upper() == validTech[0]: if letter.upper() == validTech[0]:
selTechniques.append(validInt) selTechniques.append(validInt)
break break
conf.tech = selTechniques # e.g.: 12345
else: 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: if len(conf.tech) > 0:
# TODO: consider MySQL/PHP/ASP/web backdoor case where stacked # TODO: consider MySQL/PHP/ASP/web backdoor case where stacked