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

Skip to content

Commit 095b25e

Browse files
committed
adding option '--purge'
1 parent 3532d23 commit 095b25e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

lib/core/option.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
from lib.core.exception import sqlmapUnsupportedDBMSException
7878
from lib.core.exception import sqlmapUserQuitException
7979
from lib.core.optiondict import optDict
80+
from lib.core.purge import purge
8081
from lib.core.settings import CODECS_LIST_PAGE
8182
from lib.core.settings import CRAWL_EXCLUDE_EXTENSIONS
8283
from lib.core.settings import DEFAULT_GET_POST_DELIMITER
@@ -1372,6 +1373,17 @@ class _(unicode): pass
13721373
threadData = getCurrentThreadData()
13731374
threadData.reset()
13741375

1376+
def __purgeOutput():
1377+
"""
1378+
Safely removes (purges) output directory.
1379+
"""
1380+
1381+
if conf.purgeOutput and os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
1382+
infoMsg = "purging content of output directory ('%s')" % paths.SQLMAP_OUTPUT_PATH
1383+
logger.info(infoMsg)
1384+
1385+
purge(paths.SQLMAP_OUTPUT_PATH)
1386+
13751387
def __setConfAttributes():
13761388
"""
13771389
This function set some needed attributes into the configuration
@@ -1945,6 +1957,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
19451957
__saveCmdline()
19461958
__setRequestFromFile()
19471959
__cleanupOptions()
1960+
__purgeOutput()
19481961
__checkDependencies()
19491962
__basicOptionValidation()
19501963
__setTorProxySettings()

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@ def cmdLineParser():
596596
action="store_true",
597597
help="Display page rank (PR) for Google dork results")
598598

599+
miscellaneous.add_option("--purge-output", dest="purgeOutput",
600+
action="store_true",
601+
help="Safely remove all content from output directory")
602+
599603
miscellaneous.add_option("--smart", dest="smart",
600604
action="store_true",
601605
help="Conduct through tests only if positive heuristic(s)")

0 commit comments

Comments
 (0)