Skip to content

Commit f6c7b39

Browse files
committed
Update for an Issue sqlmapproject#405 (fix for persistent options problem)
1 parent aad1023 commit f6c7b39

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/utils/api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,18 @@ class Task(object):
9898
def __init__(self, taskid):
9999
self.process = None
100100
self.output_directory = None
101+
self.options = None
102+
self._original_options = None
101103
self.initialize_options(taskid)
102104

103105
def initialize_options(self, taskid):
104-
dataype = {"boolean": False, "string": None, "integer": None, "float": None}
106+
datatype = {"boolean": False, "string": None, "integer": None, "float": None}
105107
self.options = AttribDict()
106108

107109
for _ in optDict:
108110
for name, type_ in optDict[_].items():
109111
type_ = unArrayizeValue(type_)
110-
self.options[name] = _defaults.get(name, dataype[type_])
112+
self.options[name] = _defaults.get(name, datatype[type_])
111113

112114
# Let sqlmap engine knows it is getting called by the API, the task ID and the file path of the IPC database
113115
self.options.api = True
@@ -119,6 +121,8 @@ def initialize_options(self, taskid):
119121
self.options.disableColoring = True
120122
self.options.eta = False
121123

124+
self._original_options = AttribDict(self.options)
125+
122126
def set_option(self, option, value):
123127
self.options[option] = value
124128

@@ -128,6 +132,9 @@ def get_option(self, option):
128132
def get_options(self):
129133
return self.options
130134

135+
def reset_options(self):
136+
self.options = AttribDict(self._original_options)
137+
131138
def set_output_directory(self):
132139
if not self.output_directory or not os.path.isdir(self.output_directory):
133140
self.output_directory = tempfile.mkdtemp(prefix="sqlmapoutput-")
@@ -419,6 +426,8 @@ def scan_start(taskid):
419426
if taskid not in tasks:
420427
abort(500, "Invalid task ID")
421428

429+
tasks[taskid].reset_options()
430+
422431
# Initialize sqlmap engine's options with user's provided options, if any
423432
for option, value in request.json.items():
424433
tasks[taskid].set_option(option, value)

sqlmapapi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@
4242
server(args.host, args.port)
4343
elif args.client is True:
4444
client(args.host, args.port)
45+
else:
46+
apiparser.print_help()

0 commit comments

Comments
 (0)