adding option '--purge'

This commit is contained in:
Miroslav Stampar 2012-04-23 14:24:23 +00:00
parent 3532d23933
commit 095b25e1d1
2 changed files with 17 additions and 0 deletions

View File

@ -77,6 +77,7 @@ from lib.core.exception import sqlmapSyntaxException
from lib.core.exception import sqlmapUnsupportedDBMSException
from lib.core.exception import sqlmapUserQuitException
from lib.core.optiondict import optDict
from lib.core.purge import purge
from lib.core.settings import CODECS_LIST_PAGE
from lib.core.settings import CRAWL_EXCLUDE_EXTENSIONS
from lib.core.settings import DEFAULT_GET_POST_DELIMITER
@ -1372,6 +1373,17 @@ def __cleanupOptions():
threadData = getCurrentThreadData()
threadData.reset()
def __purgeOutput():
"""
Safely removes (purges) output directory.
"""
if conf.purgeOutput and os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
infoMsg = "purging content of output directory ('%s')" % paths.SQLMAP_OUTPUT_PATH
logger.info(infoMsg)
purge(paths.SQLMAP_OUTPUT_PATH)
def __setConfAttributes():
"""
This function set some needed attributes into the configuration
@ -1945,6 +1957,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
__saveCmdline()
__setRequestFromFile()
__cleanupOptions()
__purgeOutput()
__checkDependencies()
__basicOptionValidation()
__setTorProxySettings()

View File

@ -596,6 +596,10 @@ def cmdLineParser():
action="store_true",
help="Display page rank (PR) for Google dork results")
miscellaneous.add_option("--purge-output", dest="purgeOutput",
action="store_true",
help="Safely remove all content from output directory")
miscellaneous.add_option("--smart", dest="smart",
action="store_true",
help="Conduct through tests only if positive heuristic(s)")