From 8c871476ee38dc15cfe3db0e1585b284b5b71b6f Mon Sep 17 00:00:00 2001
From: Miroslav Stampar <miroslav.stampar@gmail.com>
Date: Fri, 6 Jul 2012 17:34:40 +0200
Subject: [PATCH] Some more refactoring

---
 lib/core/option.py | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/lib/core/option.py b/lib/core/option.py
index 27b02a4eb..8db29af99 100644
--- a/lib/core/option.py
+++ b/lib/core/option.py
@@ -609,20 +609,16 @@ def __setMetasploit():
             raise sqlmapMissingPrivileges, errMsg
 
     if conf.msfPath:
-        found = False
-
         for path in (conf.msfPath, os.path.join(conf.msfPath, 'bin')):
             if all(os.path.exists(normalizePath(os.path.join(path, _))) for _ in ("", "msfcli", "msfconsole", "msfencode", "msfpayload")):
-                found = True
+                msfEnvPathExists = True
                 conf.msfPath = path
                 break
 
-        if found:
+        if msfEnvPathExists:
             debugMsg = "provided Metasploit Framework path "
             debugMsg += "'%s' is valid" % conf.msfPath
             logger.debug(debugMsg)
-
-            msfEnvPathExists = True
         else:
             warnMsg = "the provided Metasploit Framework path "
             warnMsg += "'%s' is not valid. The cause could " % conf.msfPath
@@ -1071,10 +1067,7 @@ def __setHTTPMethod():
     Check and set the HTTP method to perform HTTP requests through.
     """
 
-    if conf.data:
-        conf.method = HTTPMETHOD.POST
-    else:
-        conf.method = HTTPMETHOD.GET
+    conf.method = HTTPMETHOD.POST if conf.data else HTTPMETHOD.GET
 
     debugMsg = "setting the HTTP method to %s" % conf.method
     logger.debug(debugMsg)
@@ -1434,6 +1427,12 @@ def __setKnowledgeBaseAttributes(flushAll=True):
     kb.cache.regex = {}
     kb.cache.stdev = {}
 
+    kb.chars = AttribDict()
+    kb.chars.delimiter = randomStr(length=6, lowercase=True)
+    kb.chars.start = ":%s:" % randomStr(length=3, lowercase=True)
+    kb.chars.stop = ":%s:" % randomStr(length=3, lowercase=True)
+    kb.chars.at, kb.chars.space, kb.chars.dollar, kb.chars.hash_ = (":%s:" % _ for _ in randomStr(length=4, lowercase=True))
+
     kb.commonOutputs = None
     kb.counters = {}
     kb.data = AttribDict()
@@ -1466,7 +1465,6 @@ def __setKnowledgeBaseAttributes(flushAll=True):
     kb.ignoreTimeout = False
     kb.injection = InjectionDict()
     kb.injections = []
-
     kb.lastParserStatus = None
 
     kb.locks = AttribDict()
@@ -1522,13 +1520,6 @@ def __setKnowledgeBaseAttributes(flushAll=True):
     kb.unionDuplicates = False
     kb.xpCmdshellAvailable = False
 
-    kb.chars = AttribDict()
-    kb.chars.delimiter = randomStr(length=6, lowercase=True)
-    kb.chars.start = ":%s:" % randomStr(length=3, lowercase=True)
-    kb.chars.stop = ":%s:" % randomStr(length=3, lowercase=True)
-
-    kb.chars.at, kb.chars.space, kb.chars.dollar, kb.chars.hash_ = (":%s:" % _ for _ in randomStr(length=4, lowercase=True))
-
     if flushAll:
         kb.headerPaths = {}
         kb.keywords = set(getFileItems(paths.SQL_KEYWORDS))