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

Skip to content

Commit 6095451

Browse files
committed
Minor refactoring
1 parent 8de4820 commit 6095451

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

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.4.8.17"
21+
VERSION = "1.4.8.18"
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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ def _format_action_invocation(self, action):
863863
_ = []
864864
advancedHelp = True
865865
extraHeaders = []
866-
tamperIndex = None
866+
auxIndexes = {}
867867

868868
# Reference: https://stackoverflow.com/a/4012683 (Note: previously used "...sys.getfilesystemencoding() or UNICODE_ENCODING")
869869
for arg in argv:
@@ -952,11 +952,15 @@ def _format_action_invocation(self, action):
952952
argv[i] = ""
953953
elif argv[i] in DEPRECATED_OPTIONS:
954954
argv[i] = ""
955-
elif argv[i].startswith("--tamper"):
956-
if tamperIndex is None:
957-
tamperIndex = i if '=' in argv[i] else (i + 1 if i + 1 < len(argv) and not argv[i + 1].startswith('-') else None)
955+
elif any(argv[i].startswith(_) for _ in ("--tamper",)):
956+
key = re.search(r"\-\-(\w+)", argv[i]).group(1)
957+
index = auxIndexes.get(key, None)
958+
if index is None:
959+
index = i if '=' in argv[i] else (i + 1 if i + 1 < len(argv) and not argv[i + 1].startswith('-') else None)
960+
auxIndexes[key] = index
958961
else:
959-
argv[tamperIndex] = "%s,%s" % (argv[tamperIndex], argv[i].split('=')[1] if '=' in argv[i] else (argv[i + 1] if i + 1 < len(argv) and not argv[i + 1].startswith('-') else ""))
962+
delimiter = ','
963+
argv[index] = "%s%s%s" % (argv[index], delimiter, argv[i].split('=')[1] if '=' in argv[i] else (argv[i + 1] if i + 1 < len(argv) and not argv[i + 1].startswith('-') else ""))
960964
argv[i] = ""
961965
elif argv[i] in ("-H", "--header") or any(argv[i].startswith("%s=" % _) for _ in ("-H", "--header")):
962966
if '=' in argv[i]:

0 commit comments

Comments
 (0)