MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / StdDbOut

Class StdDbOut

lib/utils/api.py:222–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220
221# Wrapper functions for sqlmap engine
222class StdDbOut(object):
223 def __init__(self, taskid, messagetype="stdout"):
224 # Overwrite system standard output and standard error to write
225 # to an IPC database
226 self.messagetype = messagetype
227 self.taskid = taskid
228
229 if self.messagetype == "stdout":
230 sys.stdout = self
231 else:
232 sys.stderr = self
233
234 def write(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None):
235 if self.messagetype == "stdout":
236 if content_type is None:
237 if kb.partRun is not None:
238 content_type = PART_RUN_CONTENT_TYPES.get(kb.partRun)
239 else:
240 # Ignore all non-relevant messages
241 return
242
243 output = conf.databaseCursor.execute("SELECT id, status, value FROM data WHERE taskid = ? AND content_type = ?", (self.taskid, content_type))
244
245 # Delete partial output from IPC database if we have got a complete output
246 if status == CONTENT_STATUS.COMPLETE:
247 if len(output) > 0:
248 for index in xrange(len(output)):
249 conf.databaseCursor.execute("DELETE FROM data WHERE id = ?", (output[index][0],))
250
251 conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)", (self.taskid, status, content_type, jsonize(value)))
252 if kb.partRun:
253 kb.partRun = None
254
255 elif status == CONTENT_STATUS.IN_PROGRESS:
256 if len(output) == 0:
257 conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)", (self.taskid, status, content_type, jsonize(value)))
258 else:
259 new_value = "%s%s" % (dejsonize(output[0][2]), value)
260 conf.databaseCursor.execute("UPDATE data SET value = ? WHERE id = ?", (jsonize(new_value), output[0][0]))
261 else:
262 conf.databaseCursor.execute("INSERT INTO errors VALUES(NULL, ?, ?)", (self.taskid, str(value) if value else ""))
263
264 def flush(self):
265 pass
266
267 def close(self):
268 pass
269
270 def seek(self):
271 pass
272
273class LogRecorder(logging.StreamHandler):
274 def emit(self, record):

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…