| 127 | self.execute("CREATE TABLE IF NOT EXISTS errors(id INTEGER PRIMARY KEY AUTOINCREMENT, taskid INTEGER, error TEXT)") |
| 128 | |
| 129 | class Task(object): |
| 130 | def __init__(self, taskid, remote_addr): |
| 131 | self.remote_addr = remote_addr |
| 132 | self.process = None |
| 133 | self.output_directory = None |
| 134 | self.options = None |
| 135 | self._original_options = None |
| 136 | self.initialize_options(taskid) |
| 137 | |
| 138 | def initialize_options(self, taskid): |
| 139 | datatype = {"boolean": False, "string": None, "integer": None, "float": None} |
| 140 | self.options = AttribDict() |
| 141 | |
| 142 | for _ in optDict: |
| 143 | for name, type_ in optDict[_].items(): |
| 144 | type_ = unArrayizeValue(type_) |
| 145 | self.options[name] = _defaults.get(name, datatype[type_]) |
| 146 | |
| 147 | # Let sqlmap engine knows it is getting called by the API, |
| 148 | # the task ID and the file path of the IPC database |
| 149 | self.options.api = True |
| 150 | self.options.taskid = taskid |
| 151 | self.options.database = Database.filepath |
| 152 | |
| 153 | # Enforce batch mode and disable coloring and ETA |
| 154 | self.options.batch = True |
| 155 | self.options.disableColoring = True |
| 156 | self.options.eta = False |
| 157 | |
| 158 | self._original_options = AttribDict(self.options) |
| 159 | |
| 160 | def set_option(self, option, value): |
| 161 | self.options[option] = value |
| 162 | |
| 163 | def get_option(self, option): |
| 164 | return self.options[option] |
| 165 | |
| 166 | def get_options(self): |
| 167 | return self.options |
| 168 | |
| 169 | def reset_options(self): |
| 170 | self.options = AttribDict(self._original_options) |
| 171 | |
| 172 | def engine_start(self): |
| 173 | handle, configFile = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.CONFIG, text=True) |
| 174 | os.close(handle) |
| 175 | saveConfig(self.options, configFile) |
| 176 | |
| 177 | if os.path.exists("sqlmap.py"): |
| 178 | self.process = Popen([sys.executable or "python", "sqlmap.py", "--api", "-c", configFile], shell=False, close_fds=not IS_WIN) |
| 179 | elif os.path.exists(os.path.join(os.getcwd(), "sqlmap.py")): |
| 180 | self.process = Popen([sys.executable or "python", "sqlmap.py", "--api", "-c", configFile], shell=False, cwd=os.getcwd(), close_fds=not IS_WIN) |
| 181 | elif os.path.exists(os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "sqlmap.py")): |
| 182 | self.process = Popen([sys.executable or "python", "sqlmap.py", "--api", "-c", configFile], shell=False, cwd=os.path.join(os.path.abspath(os.path.dirname(sys.argv[0]))), close_fds=not IS_WIN) |
| 183 | else: |
| 184 | self.process = Popen(["sqlmap", "--api", "-c", configFile], shell=False, close_fds=not IS_WIN) |
| 185 | |
| 186 | def engine_stop(self): |
no outgoing calls
no test coverage detected
searching dependent graphs…