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

Skip to content

Commit 4b00924

Browse files
committed
Couple of updates regarding readline capabilities
1 parent f9ee0f4 commit 4b00924

6 files changed

Lines changed: 55 additions & 43 deletions

File tree

lib/core/common.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,14 +1268,22 @@ def setPaths(rootPath):
12681268
paths.SQLMAP_XML_BANNER_PATH = os.path.join(paths.SQLMAP_XML_PATH, "banner")
12691269
paths.SQLMAP_XML_PAYLOADS_PATH = os.path.join(paths.SQLMAP_XML_PATH, "payloads")
12701270

1271-
_ = os.path.join(os.path.expandvars(os.path.expanduser("~")), ".sqlmap")
1272-
paths.SQLMAP_HOME_PATH = _
1273-
paths.SQLMAP_OUTPUT_PATH = getUnicode(paths.get("SQLMAP_OUTPUT_PATH", os.path.join(_, "output")), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
1271+
if IS_WIN:
1272+
if os.getenv("LOCALAPPDATA"):
1273+
paths.SQLMAP_HOME_PATH = os.path.expandvars("%LOCALAPPDATA%\\sqlmap")
1274+
elif os.getenv("USERPROFILE"):
1275+
paths.SQLMAP_HOME_PATH = os.path.expandvars("%USERPROFILE%\\Local Settings\\sqlmap")
1276+
else:
1277+
paths.SQLMAP_HOME_PATH = os.path.join(os.path.expandvars(os.path.expanduser("~")), "sqlmap")
1278+
else:
1279+
paths.SQLMAP_HOME_PATH = os.path.join(os.path.expandvars(os.path.expanduser("~")), ".sqlmap")
1280+
1281+
paths.SQLMAP_OUTPUT_PATH = getUnicode(paths.get("SQLMAP_OUTPUT_PATH", os.path.join(paths.SQLMAP_HOME_PATH, "output")), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
12741282
paths.SQLMAP_DUMP_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "dump")
12751283
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
12761284

12771285
# history files
1278-
paths.SQLMAP_HISTORY_PATH = getUnicode(os.path.join(_, "history"), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
1286+
paths.SQLMAP_HISTORY_PATH = getUnicode(os.path.join(paths.SQLMAP_HOME_PATH, "history"), encoding=sys.getfilesystemencoding() or UNICODE_ENCODING)
12791287
paths.API_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "api.hst")
12801288
paths.OS_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "os.hst")
12811289
paths.SQL_SHELL_HISTORY = os.path.join(paths.SQLMAP_HISTORY_PATH, "sql.hst")

lib/core/option.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,41 @@ def _checkDependencies():
14131413
if conf.dependencies:
14141414
checkDependencies()
14151415

1416+
def _createHomeDirectories():
1417+
"""
1418+
Creates directories inside sqlmap's home directory
1419+
"""
1420+
1421+
for context in "output", "history":
1422+
directory = paths["SQLMAP_%s_PATH" % context.upper()]
1423+
try:
1424+
if not os.path.isdir(directory):
1425+
os.makedirs(directory)
1426+
1427+
_ = os.path.join(directory, randomStr())
1428+
open(_, "w+b").close()
1429+
os.remove(_)
1430+
1431+
if conf.outputDir and context == "output":
1432+
warnMsg = "using '%s' as the %s directory" % (directory, context)
1433+
logger.warn(warnMsg)
1434+
except (OSError, IOError) as ex:
1435+
try:
1436+
tempDir = tempfile.mkdtemp(prefix="sqlmap%s" % context)
1437+
except Exception as _:
1438+
errMsg = "unable to write to the temporary directory ('%s'). " % _
1439+
errMsg += "Please make sure that your disk is not full and "
1440+
errMsg += "that you have sufficient write permissions to "
1441+
errMsg += "create temporary files and/or directories"
1442+
raise SqlmapSystemException(errMsg)
1443+
1444+
warnMsg = "unable to %s %s directory " % ("create" if not os.path.isdir(directory) else "write to the", context)
1445+
warnMsg += "'%s' (%s). " % (directory, getUnicode(ex))
1446+
warnMsg += "Using temporary directory '%s' instead" % getUnicode(tempDir)
1447+
logger.warn(warnMsg)
1448+
1449+
paths["SQLMAP_%s_PATH" % context.upper()] = tempDir
1450+
14161451
def _createTemporaryDirectory():
14171452
"""
14181453
Creates temporary directory for this run.
@@ -2500,6 +2535,7 @@ def init():
25002535
_cleanupEnvironment()
25012536
_purge()
25022537
_checkDependencies()
2538+
_createHomeDirectories()
25032539
_createTemporaryDirectory()
25042540
_basicOptionValidation()
25052541
_setProxyList()

lib/core/readlineng.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656
# http://mail.python.org/pipermail/python-dev/2003-August/037845.html
5757
# has the original discussion.
5858
if _readline:
59-
try:
60-
_readline.clear_history()
61-
except AttributeError:
59+
if not hasattr(_readline, "clear_history"):
6260
def clear_history():
6361
pass
6462

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.3.2.4"
22+
VERSION = "1.3.2.5"
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: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -630,36 +630,6 @@ def _createTargetDirs():
630630
Create the output directory.
631631
"""
632632

633-
for context in "output", "history":
634-
directory = paths["SQLMAP_%s_PATH" % context.upper()]
635-
try:
636-
if not os.path.isdir(directory):
637-
os.makedirs(directory)
638-
639-
_ = os.path.join(directory, randomStr())
640-
open(_, "w+b").close()
641-
os.remove(_)
642-
643-
if conf.outputDir and context == "output":
644-
warnMsg = "using '%s' as the %s directory" % (directory, context)
645-
logger.warn(warnMsg)
646-
except (OSError, IOError) as ex:
647-
try:
648-
tempDir = tempfile.mkdtemp(prefix="sqlmap%s" % context)
649-
except Exception as _:
650-
errMsg = "unable to write to the temporary directory ('%s'). " % _
651-
errMsg += "Please make sure that your disk is not full and "
652-
errMsg += "that you have sufficient write permissions to "
653-
errMsg += "create temporary files and/or directories"
654-
raise SqlmapSystemException(errMsg)
655-
656-
warnMsg = "unable to %s %s directory " % ("create" if not os.path.isdir(directory) else "write to the", context)
657-
warnMsg += "'%s' (%s). " % (directory, getUnicode(ex))
658-
warnMsg += "Using temporary directory '%s' instead" % getUnicode(tempDir)
659-
logger.warn(warnMsg)
660-
661-
paths["SQLMAP_%s_PATH" % context.upper()] = tempDir
662-
663633
conf.outputPath = os.path.join(getUnicode(paths.SQLMAP_OUTPUT_PATH), normalizeUnicode(getUnicode(conf.hostname)))
664634

665635
try:

txt/checksum.md5

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ c1da277517c7ec4c23e953a51b51e203 lib/controller/handler.py
3030
fb6be55d21a70765e35549af2484f762 lib/controller/__init__.py
3131
ed7874be0d2d3802f3d20184f2b280d5 lib/core/agent.py
3232
a932126e7d80e545c5d44af178d0bc0c lib/core/bigarray.py
33-
abbe98412255c4856ef30a15da8136a2 lib/core/common.py
33+
e253cc58cb0d2bc01a68cfbe58266435 lib/core/common.py
3434
de8d27ae6241163ff9e97aa9e7c51a18 lib/core/convert.py
3535
abcb1121eb56d3401839d14e8ed06b6e lib/core/data.py
3636
e1f7758f433202c50426efde5eb96768 lib/core/datatype.py
@@ -43,17 +43,17 @@ e1f7758f433202c50426efde5eb96768 lib/core/datatype.py
4343
fb6be55d21a70765e35549af2484f762 lib/core/__init__.py
4444
18c896b157b03af716542e5fe9233ef9 lib/core/log.py
4545
fa9f24e88c81a6cef52da3dd5e637010 lib/core/optiondict.py
46-
7099592edf923ff3b88ecc4a98b52762 lib/core/option.py
46+
f479c164e44c766316205aa16cf3947b lib/core/option.py
4747
fe370021c6bc99daf44b2bfc0d1effb3 lib/core/patch.py
4848
4b12aa67fbf6c973d12e54cf9cb54ea0 lib/core/profiling.py
49-
5e2c16a8e2daee22dd545df13386e7a3 lib/core/readlineng.py
49+
d5ef43fe3cdd6c2602d7db45651f9ceb lib/core/readlineng.py
5050
7d8a22c582ad201f65b73225e4456170 lib/core/replication.py
5151
3179d34f371e0295dd4604568fb30bcd lib/core/revision.py
5252
d6269c55789f78cf707e09a0f5b45443 lib/core/session.py
53-
eb57ce3f759d37233aba581cc8c88751 lib/core/settings.py
53+
91a39930f92053b07f6ba594b6691fb8 lib/core/settings.py
5454
4483b4a5b601d8f1c4281071dff21ecc lib/core/shell.py
5555
10fd19b0716ed261e6d04f311f6f527c lib/core/subprocessng.py
56-
9c7b5c6397fb3da33e7a4d7876d159c6 lib/core/target.py
56+
43772ea73e9e3d446f782af591cb4eda lib/core/target.py
5757
7857b24b7865ccb4a05283faa596974d lib/core/testing.py
5858
e9788d2992f842cf91ab67389bf4372a lib/core/threads.py
5959
2c263c8610667fdc593c50a35ab20f57 lib/core/unescaper.py

0 commit comments

Comments
 (0)