Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c87147

Browse files
committed
Some more refactoring
1 parent 86c27cc commit 8c87147

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

lib/core/option.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -609,20 +609,16 @@ def __setMetasploit():
609609
raise sqlmapMissingPrivileges, errMsg
610610

611611
if conf.msfPath:
612-
found = False
613-
614612
for path in (conf.msfPath, os.path.join(conf.msfPath, 'bin')):
615613
if all(os.path.exists(normalizePath(os.path.join(path, _))) for _ in ("", "msfcli", "msfconsole", "msfencode", "msfpayload")):
616-
found = True
614+
msfEnvPathExists = True
617615
conf.msfPath = path
618616
break
619617

620-
if found:
618+
if msfEnvPathExists:
621619
debugMsg = "provided Metasploit Framework path "
622620
debugMsg += "'%s' is valid" % conf.msfPath
623621
logger.debug(debugMsg)
624-
625-
msfEnvPathExists = True
626622
else:
627623
warnMsg = "the provided Metasploit Framework path "
628624
warnMsg += "'%s' is not valid. The cause could " % conf.msfPath
@@ -1071,10 +1067,7 @@ def __setHTTPMethod():
10711067
Check and set the HTTP method to perform HTTP requests through.
10721068
"""
10731069

1074-
if conf.data:
1075-
conf.method = HTTPMETHOD.POST
1076-
else:
1077-
conf.method = HTTPMETHOD.GET
1070+
conf.method = HTTPMETHOD.POST if conf.data else HTTPMETHOD.GET
10781071

10791072
debugMsg = "setting the HTTP method to %s" % conf.method
10801073
logger.debug(debugMsg)
@@ -1434,6 +1427,12 @@ def __setKnowledgeBaseAttributes(flushAll=True):
14341427
kb.cache.regex = {}
14351428
kb.cache.stdev = {}
14361429

1430+
kb.chars = AttribDict()
1431+
kb.chars.delimiter = randomStr(length=6, lowercase=True)
1432+
kb.chars.start = ":%s:" % randomStr(length=3, lowercase=True)
1433+
kb.chars.stop = ":%s:" % randomStr(length=3, lowercase=True)
1434+
kb.chars.at, kb.chars.space, kb.chars.dollar, kb.chars.hash_ = (":%s:" % _ for _ in randomStr(length=4, lowercase=True))
1435+
14371436
kb.commonOutputs = None
14381437
kb.counters = {}
14391438
kb.data = AttribDict()
@@ -1466,7 +1465,6 @@ def __setKnowledgeBaseAttributes(flushAll=True):
14661465
kb.ignoreTimeout = False
14671466
kb.injection = InjectionDict()
14681467
kb.injections = []
1469-
14701468
kb.lastParserStatus = None
14711469

14721470
kb.locks = AttribDict()
@@ -1522,13 +1520,6 @@ def __setKnowledgeBaseAttributes(flushAll=True):
15221520
kb.unionDuplicates = False
15231521
kb.xpCmdshellAvailable = False
15241522

1525-
kb.chars = AttribDict()
1526-
kb.chars.delimiter = randomStr(length=6, lowercase=True)
1527-
kb.chars.start = ":%s:" % randomStr(length=3, lowercase=True)
1528-
kb.chars.stop = ":%s:" % randomStr(length=3, lowercase=True)
1529-
1530-
kb.chars.at, kb.chars.space, kb.chars.dollar, kb.chars.hash_ = (":%s:" % _ for _ in randomStr(length=4, lowercase=True))
1531-
15321523
if flushAll:
15331524
kb.headerPaths = {}
15341525
kb.keywords = set(getFileItems(paths.SQL_KEYWORDS))

0 commit comments

Comments
 (0)