Minor update for Issue #832

This commit is contained in:
Miroslav Stampar 2014-09-16 15:17:50 +02:00
parent 7278af01ee
commit 5b0732e9f9
3 changed files with 27 additions and 11 deletions

View File

@ -1058,7 +1058,9 @@ def setPaths():
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
# sqlmap files
paths.SQLMAP_SHELL_HISTORY = os.path.join(_, "shell.hst")
paths.SQL_SHELL_HISTORY = os.path.join(_, "sql.hst")
paths.OS_SHELL_HISTORY = os.path.join(_, "os.hst")
paths.SQLMAP_SHELL_HISTORY = os.path.join(_, "sqlmap.hst")
paths.SQLMAP_CONFIG = os.path.join(paths.SQLMAP_ROOT_PATH, "sqlmap-%s.conf" % randomStr())
paths.COMMON_COLUMNS = os.path.join(paths.SQLMAP_TXT_PATH, "common-columns.txt")
paths.COMMON_TABLES = os.path.join(paths.SQLMAP_TXT_PATH, "common-tables.txt")

View File

@ -31,24 +31,38 @@ def clearHistory():
readline.clear_history()
def saveHistory():
def saveHistory(completion=None):
if not readlineAvailable():
return
historyPath = os.path.expanduser(paths.SQLMAP_SHELL_HISTORY)
if completion == AUTOCOMPLETE_TYPE.SQL:
historyPath = paths.SQL_SHELL_HISTORY
elif completion == AUTOCOMPLETE_TYPE.OS:
historyPath = paths.OS_SHELL_HISTORY
else:
historyPath = paths.SQLMAP_SHELL_HISTORY
try:
os.remove(historyPath)
with open(historyPath, "rw+") as f:
f.truncate()
except:
pass
readline.set_history_length(MAX_HISTORY_LENGTH)
readline.write_history_file(historyPath)
def loadHistory():
def loadHistory(completion=None):
if not readlineAvailable():
return
historyPath = os.path.expanduser(paths.SQLMAP_SHELL_HISTORY)
clearHistory()
if completion == AUTOCOMPLETE_TYPE.SQL:
historyPath = paths.SQL_SHELL_HISTORY
elif completion == AUTOCOMPLETE_TYPE.OS:
historyPath = paths.OS_SHELL_HISTORY
else:
historyPath = paths.SQLMAP_SHELL_HISTORY
if os.path.exists(historyPath):
try:
@ -107,5 +121,5 @@ def autoCompletion(completion=None, os=None, commands=None):
readline.set_completer(completer.complete)
readline.parse_and_bind("tab: complete")
loadHistory()
atexit.register(saveHistory)
loadHistory(completion)
atexit.register(saveHistory, completion)

View File

@ -832,15 +832,15 @@ def cmdLineParser():
elif command.lower() == "clear":
clearHistory()
print "[i] history cleared"
saveHistory()
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
elif command.lower() in ("x", "q", "exit", "quit"):
raise SqlmapShellQuitException
elif command[0] != '-':
print "[!] invalid option(s) provided"
print "[i] proper example: '-u http://www.site.com/vuln.php?id=1 --banner'"
else:
saveHistory()
loadHistory()
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
loadHistory(AUTOCOMPLETE_TYPE.SQLMAP)
break
for arg in shlex.split(command):