mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-02 20:54:13 +03:00
Minor update for Issue #832
This commit is contained in:
parent
7278af01ee
commit
5b0732e9f9
|
@ -1058,7 +1058,9 @@ def setPaths():
|
||||||
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
|
paths.SQLMAP_FILES_PATH = os.path.join(paths.SQLMAP_OUTPUT_PATH, "%s", "files")
|
||||||
|
|
||||||
# sqlmap 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.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_COLUMNS = os.path.join(paths.SQLMAP_TXT_PATH, "common-columns.txt")
|
||||||
paths.COMMON_TABLES = os.path.join(paths.SQLMAP_TXT_PATH, "common-tables.txt")
|
paths.COMMON_TABLES = os.path.join(paths.SQLMAP_TXT_PATH, "common-tables.txt")
|
||||||
|
|
|
@ -31,24 +31,38 @@ def clearHistory():
|
||||||
|
|
||||||
readline.clear_history()
|
readline.clear_history()
|
||||||
|
|
||||||
def saveHistory():
|
def saveHistory(completion=None):
|
||||||
if not readlineAvailable():
|
if not readlineAvailable():
|
||||||
return
|
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:
|
try:
|
||||||
os.remove(historyPath)
|
with open(historyPath, "rw+") as f:
|
||||||
|
f.truncate()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
readline.set_history_length(MAX_HISTORY_LENGTH)
|
readline.set_history_length(MAX_HISTORY_LENGTH)
|
||||||
readline.write_history_file(historyPath)
|
readline.write_history_file(historyPath)
|
||||||
|
|
||||||
def loadHistory():
|
def loadHistory(completion=None):
|
||||||
if not readlineAvailable():
|
if not readlineAvailable():
|
||||||
return
|
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):
|
if os.path.exists(historyPath):
|
||||||
try:
|
try:
|
||||||
|
@ -107,5 +121,5 @@ def autoCompletion(completion=None, os=None, commands=None):
|
||||||
readline.set_completer(completer.complete)
|
readline.set_completer(completer.complete)
|
||||||
readline.parse_and_bind("tab: complete")
|
readline.parse_and_bind("tab: complete")
|
||||||
|
|
||||||
loadHistory()
|
loadHistory(completion)
|
||||||
atexit.register(saveHistory)
|
atexit.register(saveHistory, completion)
|
||||||
|
|
|
@ -832,15 +832,15 @@ def cmdLineParser():
|
||||||
elif command.lower() == "clear":
|
elif command.lower() == "clear":
|
||||||
clearHistory()
|
clearHistory()
|
||||||
print "[i] history cleared"
|
print "[i] history cleared"
|
||||||
saveHistory()
|
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
|
||||||
elif command.lower() in ("x", "q", "exit", "quit"):
|
elif command.lower() in ("x", "q", "exit", "quit"):
|
||||||
raise SqlmapShellQuitException
|
raise SqlmapShellQuitException
|
||||||
elif command[0] != '-':
|
elif command[0] != '-':
|
||||||
print "[!] invalid option(s) provided"
|
print "[!] invalid option(s) provided"
|
||||||
print "[i] proper example: '-u http://www.site.com/vuln.php?id=1 --banner'"
|
print "[i] proper example: '-u http://www.site.com/vuln.php?id=1 --banner'"
|
||||||
else:
|
else:
|
||||||
saveHistory()
|
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
|
||||||
loadHistory()
|
loadHistory(AUTOCOMPLETE_TYPE.SQLMAP)
|
||||||
break
|
break
|
||||||
|
|
||||||
for arg in shlex.split(command):
|
for arg in shlex.split(command):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user