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

Skip to content

Commit 5e2d0bd

Browse files
committed
Minor patches (--purge instead of --purge-output)
1 parent 4badb54 commit 5e2d0bd

8 files changed

Lines changed: 51 additions & 45 deletions

File tree

lib/core/common.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,12 +1273,15 @@ def setPaths(rootPath):
12731273
paths.SQLMAP_DUMP_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "dump")
12741274
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
12751275

1276+
# history files
1277+
paths.SQLMAP_HISTORY_PATH = getUnicode(os.path.join(_, "history"), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
1278+
paths.API_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "api.hst")
1279+
paths.OS_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "os.hst")
1280+
paths.SQL_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "sql.hst")
1281+
paths.SQLMAP_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "sqlmap.hst")
1282+
paths.GITHUB_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "github.hst")
1283+
12761284
# sqlmap files
1277-
paths.API_SHELL_HISTORY = os.path.join(_, "api.hst")
1278-
paths.OS_SHELL_HISTORY = os.path.join(_, "os.hst")
1279-
paths.SQL_SHELL_HISTORY = os.path.join(_, "sql.hst")
1280-
paths.SQLMAP_SHELL_HISTORY = os.path.join(_, "sqlmap.hst")
1281-
paths.GITHUB_HISTORY = os.path.join(_, "github.hst")
12821285
paths.CHECKSUM_MD5 = os.path.join(paths.SQLMAP_TXT_PATH, "checksum.md5")
12831286
paths.COMMON_COLUMNS = os.path.join(paths.SQLMAP_TXT_PATH, "common-columns.txt")
12841287
paths.COMMON_TABLES = os.path.join(paths.SQLMAP_TXT_PATH, "common-tables.txt")

lib/core/dicts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
"--auth-private": "use '--auth-file' instead",
282282
"--ignore-401": "use '--ignore-code' instead",
283283
"--second-order": "use '--second-url' instead",
284+
"--purge-output": "use '--purge' instead",
284285
"--check-payload": None,
285286
"--check-waf": None,
286287
"--pickled-options": "use '--api -c ...' instead",

lib/core/option.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,13 +1638,13 @@ def _cleanupEnvironment():
16381638
if hasattr(socket, "_ready"):
16391639
socket._ready.clear()
16401640

1641-
def _purgeOutput():
1641+
def _purge():
16421642
"""
1643-
Safely removes (purges) output directory.
1643+
Safely removes (purges) sqlmap data directory.
16441644
"""
16451645

1646-
if conf.purgeOutput:
1647-
purge(paths.SQLMAP_OUTPUT_PATH)
1646+
if conf.purge:
1647+
purge(paths.SQLMAP_HOME_PATH)
16481648

16491649
def _setConfAttributes():
16501650
"""
@@ -2450,7 +2450,7 @@ def init():
24502450
_setRequestFromFile()
24512451
_cleanupOptions()
24522452
_cleanupEnvironment()
2453-
_purgeOutput()
2453+
_purge()
24542454
_checkDependencies()
24552455
_createTemporaryDirectory()
24562456
_basicOptionValidation()

lib/core/optiondict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"identifyWaf": "boolean",
230230
"mobile": "boolean",
231231
"offline": "boolean",
232-
"purgeOutput": "boolean",
232+
"purge": "boolean",
233233
"skipWaf": "boolean",
234234
"smart": "boolean",
235235
"tmpDir": "string",

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.2.6.35"
22+
VERSION = "1.2.6.36"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/core/target.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -619,33 +619,35 @@ def _createTargetDirs():
619619
Create the output directory.
620620
"""
621621

622-
try:
623-
if not os.path.isdir(paths.SQLMAP_OUTPUT_PATH):
624-
os.makedirs(paths.SQLMAP_OUTPUT_PATH)
622+
for context in "output", "history":
623+
directory = paths["SQLMAP_%s_PATH" % context.upper()]
624+
try:
625+
if not os.path.isdir(directory):
626+
os.makedirs(directory)
625627

626-
_ = os.path.join(paths.SQLMAP_OUTPUT_PATH, randomStr())
627-
open(_, "w+b").close()
628-
os.remove(_)
628+
_ = os.path.join(directory, randomStr())
629+
open(_, "w+b").close()
630+
os.remove(_)
629631

630-
if conf.outputDir:
631-
warnMsg = "using '%s' as the output directory" % paths.SQLMAP_OUTPUT_PATH
632-
logger.warn(warnMsg)
633-
except (OSError, IOError), ex:
634-
try:
635-
tempDir = tempfile.mkdtemp(prefix="sqlmapoutput")
636-
except Exception, _:
637-
errMsg = "unable to write to the temporary directory ('%s'). " % _
638-
errMsg += "Please make sure that your disk is not full and "
639-
errMsg += "that you have sufficient write permissions to "
640-
errMsg += "create temporary files and/or directories"
641-
raise SqlmapSystemException(errMsg)
632+
if conf.outputDir and context == "output":
633+
warnMsg = "using '%s' as the %s directory" % (directory, context)
634+
logger.warn(warnMsg)
635+
except (OSError, IOError), ex:
636+
try:
637+
tempDir = tempfile.mkdtemp(prefix="sqlmap%s" % context)
638+
except Exception, _:
639+
errMsg = "unable to write to the temporary directory ('%s'). " % _
640+
errMsg += "Please make sure that your disk is not full and "
641+
errMsg += "that you have sufficient write permissions to "
642+
errMsg += "create temporary files and/or directories"
643+
raise SqlmapSystemException(errMsg)
642644

643-
warnMsg = "unable to %s output directory " % ("create" if not os.path.isdir(paths.SQLMAP_OUTPUT_PATH) else "write to the")
644-
warnMsg += "'%s' (%s). " % (paths.SQLMAP_OUTPUT_PATH, getUnicode(ex))
645-
warnMsg += "Using temporary directory '%s' instead" % getUnicode(tempDir)
646-
logger.warn(warnMsg)
645+
warnMsg = "unable to %s %s directory " % ("create" if not os.path.isdir(directory) else "write to the", context)
646+
warnMsg += "'%s' (%s). " % (directory, getUnicode(ex))
647+
warnMsg += "Using temporary directory '%s' instead" % getUnicode(tempDir)
648+
logger.warn(warnMsg)
647649

648-
paths.SQLMAP_OUTPUT_PATH = tempDir
650+
paths["SQLMAP_%s_PATH" % context.upper()] = tempDir
649651

650652
conf.outputPath = os.path.join(getUnicode(paths.SQLMAP_OUTPUT_PATH), normalizeUnicode(getUnicode(conf.hostname)))
651653

lib/parse/cmdline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,8 @@ def cmdLineParser(argv=None):
643643
miscellaneous.add_option("--offline", dest="offline", action="store_true",
644644
help="Work in offline mode (only use session data)")
645645

646-
miscellaneous.add_option("--purge-output", dest="purgeOutput", action="store_true",
647-
help="Safely remove all content from output directory")
646+
miscellaneous.add_option("--purge", dest="purge", action="store_true",
647+
help="Safely remove all content from sqlmap data directory")
648648

649649
miscellaneous.add_option("--skip-waf", dest="skipWaf", action="store_true",
650650
help="Skip heuristic detection of WAF/IPS/IDS protection")
@@ -874,7 +874,7 @@ def _(self, *args):
874874
if args.dummy:
875875
args.url = args.url or DUMMY_URL
876876

877-
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, args.purgeOutput, args.sitemapUrl)):
877+
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.wizard, args.dependencies, args.purge, args.sitemapUrl)):
878878
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, -x, --wizard, --update, --purge-output or --dependencies), "
879879
errMsg += "use -h for basic or -hh for advanced help\n"
880880
parser.error(errMsg)

txt/checksum.md5

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,38 @@ c7443613a0a2505b1faec931cee2a6ef lib/controller/handler.py
2828
1e5532ede194ac9c083891c2f02bca93 lib/controller/__init__.py
2929
0adf547455a76dc71e6a599e52da1ed9 lib/core/agent.py
3030
fd8f239e259afaf5f24bcf34a0ad187f lib/core/bigarray.py
31-
6165b8a826803b29c479d47a60e8dbf6 lib/core/common.py
31+
acec51826b280ad96dedbb56515e3988 lib/core/common.py
3232
0d082da16c388b3445e656e0760fb582 lib/core/convert.py
3333
9f87391b6a3395f7f50830b391264f27 lib/core/data.py
3434
72016ea5c994a711a262fd64572a0fcd lib/core/datatype.py
3535
4086fb55f42e27de5330505605baad0f lib/core/decorators.py
3636
fbb55cc6100318ff922957b6577dc58f lib/core/defaults.py
37-
98b730cef6a59ab044a108276aef6f42 lib/core/dicts.py
37+
db165596ef0a3e19ec59c24192bb318d lib/core/dicts.py
3838
9ea8a043030796e6faef7f7e957729d5 lib/core/dump.py
3939
ab3f4f3e3019add5f4a2e28f7e8748a4 lib/core/enums.py
4040
cada93357a7321655927fc9625b3bfec lib/core/exception.py
4141
1e5532ede194ac9c083891c2f02bca93 lib/core/__init__.py
4242
458a194764805cd8312c14ecd4be4d1e lib/core/log.py
43-
e9e32e5afe49ecd644b3a0ca9c9a36fc lib/core/optiondict.py
44-
5d25911fbd379c32d5bf918c79febc0b lib/core/option.py
43+
13c0a490b5a928b64236b4a15e578267 lib/core/optiondict.py
44+
4ef6c718b5069f7468c647b5e29fd3db lib/core/option.py
4545
c8c386d644d57c659d74542f5f57f632 lib/core/patch.py
4646
6783160150b4711d02c56ee2beadffdb lib/core/profiling.py
4747
6f654e1715571eff68a0f8af3d62dcf8 lib/core/readlineng.py
4848
0c3eef46bdbf87e29a3f95f90240d192 lib/core/replication.py
4949
a7db43859b61569b601b97f187dd31c5 lib/core/revision.py
5050
fcb74fcc9577523524659ec49e2e964b lib/core/session.py
51-
4742105fe7dd3964e11961c44cf9e851 lib/core/settings.py
51+
770a509eb586d686c1ca318171d17a33 lib/core/settings.py
5252
dd68a9d02fccb4fa1428b20e15b0db5d lib/core/shell.py
5353
a7edc9250d13af36ac0108f259859c19 lib/core/subprocessng.py
54-
36bd2dc292c0e10e39bd9c43b77fe1bc lib/core/target.py
54+
95f04c1c1d8c3998d86e1bdf0e12771c lib/core/target.py
5555
72d499ca8d792e90a1ebfb2ad2341a51 lib/core/testing.py
5656
de9922a29c71a235cb95a916ff925db2 lib/core/threads.py
5757
c40758411bb0bd68764d78e0bb72bd0f lib/core/unescaper.py
5858
9d395b143be295a143eb5c9b926f3569 lib/core/update.py
5959
e772deb63270375e685fa5a7b775c382 lib/core/wordlist.py
6060
1e5532ede194ac9c083891c2f02bca93 lib/__init__.py
6161
7620f1f4b8791e13c7184c06b5421754 lib/parse/banner.py
62-
2b3b021a8e7e119d0553c02b110d07d9 lib/parse/cmdline.py
62+
3dd11b8be62e15a9d54cf5f08c603ffc lib/parse/cmdline.py
6363
fb2e2f05dde98caeac6ccf3e67192177 lib/parse/configfile.py
6464
3794ff139869f5ae8e81cfdbe5714f56 lib/parse/handler.py
6565
6bab53ea9d75bc9bb8169d3e8f3f149f lib/parse/headers.py

0 commit comments

Comments
 (0)