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

Skip to content

Commit 04396c9

Browse files
committed
Minor refactoring
1 parent b1cdbda commit 04396c9

5 files changed

Lines changed: 68 additions & 8 deletions

File tree

lib/core/dicts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
"--ignore-401": "use '--ignore-code' instead",
364364
"--second-order": "use '--second-url' instead",
365365
"--purge-output": "use '--purge' instead",
366+
"--sqlmap-shell": "use '--shell' instead",
366367
"--check-payload": None,
367368
"--check-waf": None,
368369
"--pickled-options": "use '--api -c ...' instead",

lib/core/enums.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,58 @@ class FUZZ_UNION_COLUMN:
437437
STRING = "<string>"
438438
INTEGER = "<integer>"
439439
NULL = "NULL"
440+
441+
class COLOR:
442+
BLUE = "\033[34m"
443+
BOLD_MAGENTA = "\033[35;1m"
444+
BOLD_GREEN = "\033[32;1m"
445+
BOLD_LIGHT_MAGENTA = "\033[95;1m"
446+
LIGHT_GRAY = "\033[37m"
447+
BOLD_RED = "\033[31;1m"
448+
BOLD_LIGHT_GRAY = "\033[37;1m"
449+
YELLOW = "\033[33m"
450+
DARK_GRAY = "\033[90m"
451+
BOLD_CYAN = "\033[36;1m"
452+
LIGHT_RED = "\033[91m"
453+
CYAN = "\033[36m"
454+
MAGENTA = "\033[35m"
455+
LIGHT_MAGENTA = "\033[95m"
456+
LIGHT_GREEN = "\033[92m"
457+
RESET = "\033[0m"
458+
BOLD_DARK_GRAY = "\033[90;1m"
459+
BOLD_LIGHT_YELLOW = "\033[93;1m"
460+
BOLD_LIGHT_RED = "\033[91;1m"
461+
BOLD_LIGHT_GREEN = "\033[92;1m"
462+
LIGHT_YELLOW = "\033[93m"
463+
BOLD_LIGHT_BLUE = "\033[94;1m"
464+
BOLD_LIGHT_CYAN = "\033[96;1m"
465+
LIGHT_BLUE = "\033[94m"
466+
BOLD_WHITE = "\033[97;1m"
467+
LIGHT_CYAN = "\033[96m"
468+
BLACK = "\033[30m"
469+
BOLD_YELLOW = "\033[33;1m"
470+
BOLD_BLUE = "\033[34;1m"
471+
GREEN = "\033[32m"
472+
WHITE = "\033[97m"
473+
BOLD_BLACK = "\033[30;1m"
474+
RED = "\033[31m"
475+
UNDERLINE = "\033[4m"
476+
477+
class BACKGROUND:
478+
BLUE = "\033[44m"
479+
LIGHT_GRAY = "\033[47m"
480+
YELLOW = "\033[43m"
481+
DARK_GRAY = "\033[100m"
482+
LIGHT_RED = "\033[101m"
483+
CYAN = "\033[46m"
484+
MAGENTA = "\033[45m"
485+
LIGHT_MAGENTA = "\033[105m"
486+
LIGHT_GREEN = "\033[102m"
487+
RESET = "\033[0m"
488+
LIGHT_YELLOW = "\033[103m"
489+
LIGHT_BLUE = "\033[104m"
490+
LIGHT_CYAN = "\033[106m"
491+
BLACK = "\033[40m"
492+
GREEN = "\033[42m"
493+
WHITE = "\033[107m"
494+
RED = "\033[41m"

lib/core/option.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1916,7 +1916,7 @@ class _(six.text_type):
19161916

19171917
def _cleanupEnvironment():
19181918
"""
1919-
Cleanup environment (e.g. from leftovers after --sqlmap-shell).
1919+
Cleanup environment (e.g. from leftovers after --shell).
19201920
"""
19211921

19221922
if issubclass(_http_client.socket.socket, socks.socksocket):

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

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

lib/parse/cmdline.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def cmdLineParser(argv=None):
751751
miscellaneous.add_argument("--results-file", dest="resultsFile",
752752
help="Location of CSV results file in multiple targets mode")
753753

754-
miscellaneous.add_argument("--sqlmap-shell", dest="sqlmapShell", action="store_true",
754+
miscellaneous.add_argument("--shell", dest="shell", action="store_true",
755755
help="Prompt for an interactive sqlmap shell")
756756

757757
miscellaneous.add_argument("--tmp-dir", dest="tmpDir",
@@ -894,7 +894,7 @@ def _format_action_invocation(self, action):
894894

895895
raise SqlmapSilentQuitException
896896

897-
elif "--sqlmap-shell" in argv:
897+
elif "--shell" in argv:
898898
_createHomeDirectories()
899899

900900
parser.usage = ""
@@ -907,14 +907,17 @@ def _format_action_invocation(self, action):
907907

908908
while True:
909909
command = None
910+
prompt = "sqlmap > "
910911

911912
try:
912913
# Note: in Python2 command should not be converted to Unicode before passing to shlex (Reference: https://bugs.python.org/issue1170)
913-
command = _input("sqlmap-shell> ").strip()
914+
command = _input(prompt).strip()
914915
except (KeyboardInterrupt, EOFError):
915916
print()
916917
raise SqlmapShellQuitException
917918

919+
command = re.sub(r"(?i)\Anew\s+", "", command or "")
920+
918921
if not command:
919922
continue
920923
elif command.lower() == "clear":
@@ -924,8 +927,9 @@ def _format_action_invocation(self, action):
924927
elif command.lower() in ("x", "q", "exit", "quit"):
925928
raise SqlmapShellQuitException
926929
elif command[0] != '-':
927-
dataToStdout("[!] invalid option(s) provided\n")
928-
dataToStdout("[i] proper example: '-u http://www.site.com/vuln.php?id=1 --banner'\n")
930+
if not re.search(r"(?i)\A(\?|help)\Z", command):
931+
dataToStdout("[!] invalid option(s) provided\n")
932+
dataToStdout("[i] valid example: '-u http://www.site.com/vuln.php?id=1 --banner'\n")
929933
else:
930934
saveHistory(AUTOCOMPLETE_TYPE.SQLMAP)
931935
loadHistory(AUTOCOMPLETE_TYPE.SQLMAP)
@@ -1057,7 +1061,7 @@ def _format_action_invocation(self, action):
10571061
args.stdinPipe = None
10581062

10591063
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, args.requestFile, args.updateAll, args.smokeTest, args.vulnTest, args.bedTest, args.fuzzTest, args.wizard, args.dependencies, args.purge, args.listTampers, args.hashFile, args.stdinPipe)):
1060-
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --list-tampers, --wizard, --update, --purge or --dependencies). "
1064+
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --wizard, --shell, --update, --purge, --list-tampers or --dependencies). "
10611065
errMsg += "Use -h for basic and -hh for advanced help\n"
10621066
parser.error(errMsg)
10631067

0 commit comments

Comments
 (0)