From 095b25e1d101dd6112b4d97cf57ffc96b887b040 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 23 Apr 2012 14:24:23 +0000 Subject: [PATCH] adding option '--purge' --- lib/core/option.py | 13 +++++++++++++ lib/parse/cmdline.py | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/lib/core/option.py b/lib/core/option.py index d85a336f1..8e154e697 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -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() diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index e4c198926..76207a374 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -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)")