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

Skip to content

Commit 5b0732e

Browse files
committed
Minor update for Issue #832
1 parent 7278af0 commit 5b0732e

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

lib/core/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@ def setPaths():
10581058
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
10591059

10601060
# sqlmap files
1061-
paths.SQLMAP_SHELL_HISTORY = os.path.join(_, "shell.hst")
1061+
paths.SQL_SHELL_HISTORY = os.path.join(_, "sql.hst")
1062+
paths.OS_SHELL_HISTORY = os.path.join(_, "os.hst")
1063+
paths.SQLMAP_SHELL_HISTORY = os.path.join(_, "sqlmap.hst")
10621064
paths.SQLMAP_CONFIG = os.path.join(paths.SQLMAP_ROOT_PATH, "sqlmap-%s.conf" % randomStr())
10631065
paths.COMMON_COLUMNS = os.path.join(paths.SQLMAP_TXT_PATH, "common-columns.txt")
10641066
paths.COMMON_TABLES = os.path.join(paths.SQLMAP_TXT_PATH, "common-tables.txt")

lib/core/shell.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,38 @@ def clearHistory():
3131

3232
readline.clear_history()
3333

34-
def saveHistory():
34+
def saveHistory(completion=None):
3535
if not readlineAvailable():
3636
return
3737

38-
historyPath = os.path.expanduser(paths.SQLMAP_SHELL_HISTORY)
38+
if completion == AUTOCOMPLETE_TYPE.SQL:
39+
historyPath = paths.SQL_SHELL_HISTORY
40+
elif completion == AUTOCOMPLETE_TYPE.OS:
41+
historyPath = paths.OS_SHELL_HISTORY
42+
else:
43+
historyPath = paths.SQLMAP_SHELL_HISTORY
44+
3945
try:
40-
os.remove(historyPath)
46+
with open(historyPath, "rw+") as f:
47+
f.truncate()
4148
except:
4249
pass
4350

4451
readline.set_history_length(MAX_HISTORY_LENGTH)
4552
readline.write_history_file(historyPath)
4653

47-
def loadHistory():
54+
def loadHistory(completion=None):
4855
if not readlineAvailable():
4956
return
5057

51-
historyPath = os.path.expanduser(paths.SQLMAP_SHELL_HISTORY)
58+
clearHistory()
59+
60+
if completion == AUTOCOMPLETE_TYPE.SQL:
61+
historyPath = paths.SQL_SHELL_HISTORY
62+
elif completion == AUTOCOMPLETE_TYPE.OS:
63+
historyPath = paths.OS_SHELL_HISTORY
64+
else:
65+
historyPath = paths.SQLMAP_SHELL_HISTORY
5266

5367
if os.path.exists(historyPath):
5468
try:
@@ -107,5 +121,5 @@ def autoCompletion(completion=None, os=None, commands=None):
107121
readline.set_completer(completer.complete)
108122
readline.parse_and_bind("tab: complete")
109123

110-
loadHistory()
111-
atexit.register(saveHistory)
124+
loadHistory(completion)
125+
atexit.register(saveHistory, completion)

lib/parse/cmdline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,15 @@ def _(self, *args):
832832
elif command.lower() == "clear":
833833
clearHistory()
834834
print "[i] history cleared"
835-
saveHistory()
835+
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
836836
elif command.lower() in ("x", "q", "exit", "quit"):
837837
raise SqlmapShellQuitException
838838
elif command[0] != '-':
839839
print "[!] invalid option(s) provided"
840840
print "[i] proper example: '-u http://www.site.com/vuln.php?id=1 --banner'"
841841
else:
842-
saveHistory()
843-
loadHistory()
842+
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
843+
loadHistory(AUTOCOMPLETE_TYPE.SQLMAP)
844844
break
845845

846846
for arg in shlex.split(command):

0 commit comments

Comments
 (0)