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

Skip to content

Commit 34281af

Browse files
committed
Minor cleaning
1 parent 7dbbf3e commit 34281af

3 files changed

Lines changed: 15 additions & 36 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

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

lib/utils/api.py

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -232,34 +232,26 @@ def write(self, value, status=CONTENT_STATUS.IN_PROGRESS, content_type=None):
232232
# Ignore all non-relevant messages
233233
return
234234

235-
output = conf.databaseCursor.execute(
236-
"SELECT id, status, value FROM data WHERE taskid = ? AND content_type = ?",
237-
(self.taskid, content_type))
235+
output = conf.databaseCursor.execute("SELECT id, status, value FROM data WHERE taskid = ? AND content_type = ?", (self.taskid, content_type))
238236

239237
# Delete partial output from IPC database if we have got a complete output
240238
if status == CONTENT_STATUS.COMPLETE:
241239
if len(output) > 0:
242240
for index in xrange(len(output)):
243-
conf.databaseCursor.execute("DELETE FROM data WHERE id = ?",
244-
(output[index][0],))
241+
conf.databaseCursor.execute("DELETE FROM data WHERE id = ?", (output[index][0],))
245242

246-
conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)",
247-
(self.taskid, status, content_type, jsonize(value)))
243+
conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)", (self.taskid, status, content_type, jsonize(value)))
248244
if kb.partRun:
249245
kb.partRun = None
250246

251247
elif status == CONTENT_STATUS.IN_PROGRESS:
252248
if len(output) == 0:
253-
conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)",
254-
(self.taskid, status, content_type,
255-
jsonize(value)))
249+
conf.databaseCursor.execute("INSERT INTO data VALUES(NULL, ?, ?, ?, ?)", (self.taskid, status, content_type, jsonize(value)))
256250
else:
257251
new_value = "%s%s" % (dejsonize(output[0][2]), value)
258-
conf.databaseCursor.execute("UPDATE data SET value = ? WHERE id = ?",
259-
(jsonize(new_value), output[0][0]))
252+
conf.databaseCursor.execute("UPDATE data SET value = ? WHERE id = ?", (jsonize(new_value), output[0][0]))
260253
else:
261-
conf.databaseCursor.execute("INSERT INTO errors VALUES(NULL, ?, ?)",
262-
(self.taskid, str(value) if value else ""))
254+
conf.databaseCursor.execute("INSERT INTO errors VALUES(NULL, ?, ?)", (self.taskid, str(value) if value else ""))
263255

264256
def flush(self):
265257
pass
@@ -270,17 +262,13 @@ def close(self):
270262
def seek(self):
271263
pass
272264

273-
274265
class LogRecorder(logging.StreamHandler):
275266
def emit(self, record):
276267
"""
277268
Record emitted events to IPC database for asynchronous I/O
278269
communication with the parent process
279270
"""
280-
conf.databaseCursor.execute("INSERT INTO logs VALUES(NULL, ?, ?, ?, ?)",
281-
(conf.taskid, time.strftime("%X"), record.levelname,
282-
record.msg % record.args if record.args else record.msg))
283-
271+
conf.databaseCursor.execute("INSERT INTO logs VALUES(NULL, ?, ?, ?, ?)", (conf.taskid, time.strftime("%X"), record.levelname, record.msg % record.args if record.args else record.msg))
284272

285273
def setRestAPILog():
286274
if conf.api:
@@ -555,16 +543,11 @@ def scan_data(taskid):
555543
return jsonize({"success": False, "message": "Invalid task ID"})
556544

557545
# Read all data from the IPC database for the taskid
558-
for status, content_type, value in DataStore.current_db.execute(
559-
"SELECT status, content_type, value FROM data WHERE taskid = ? ORDER BY id ASC",
560-
(taskid,)):
561-
json_data_message.append(
562-
{"status": status, "type": content_type, "value": dejsonize(value)})
546+
for status, content_type, value in DataStore.current_db.execute("SELECT status, content_type, value FROM data WHERE taskid = ? ORDER BY id ASC", (taskid,)):
547+
json_data_message.append({"status": status, "type": content_type, "value": dejsonize(value)})
563548

564549
# Read all error messages from the IPC database
565-
for error in DataStore.current_db.execute(
566-
"SELECT error FROM errors WHERE taskid = ? ORDER BY id ASC",
567-
(taskid,)):
550+
for error in DataStore.current_db.execute("SELECT error FROM errors WHERE taskid = ? ORDER BY id ASC", (taskid,)):
568551
json_errors_message.append(error)
569552

570553
logger.debug("[%s] Retrieved scan data and error messages" % taskid)
@@ -591,10 +574,7 @@ def scan_log_limited(taskid, start, end):
591574
end = max(1, int(end))
592575

593576
# Read a subset of log messages from the IPC database
594-
for time_, level, message in DataStore.current_db.execute(
595-
("SELECT time, level, message FROM logs WHERE "
596-
"taskid = ? AND id >= ? AND id <= ? ORDER BY id ASC"),
597-
(taskid, start, end)):
577+
for time_, level, message in DataStore.current_db.execute("SELECT time, level, message FROM logs WHERE taskid = ? AND id >= ? AND id <= ? ORDER BY id ASC", (taskid, start, end)):
598578
json_log_messages.append({"time": time_, "level": level, "message": message})
599579

600580
logger.debug("[%s] Retrieved scan log messages subset" % taskid)
@@ -613,8 +593,7 @@ def scan_log(taskid):
613593
return jsonize({"success": False, "message": "Invalid task ID"})
614594

615595
# Read all log messages from the IPC database
616-
for time_, level, message in DataStore.current_db.execute(
617-
"SELECT time, level, message FROM logs WHERE taskid = ? ORDER BY id ASC", (taskid,)):
596+
for time_, level, message in DataStore.current_db.execute("SELECT time, level, message FROM logs WHERE taskid = ? ORDER BY id ASC", (taskid,)):
618597
json_log_messages.append({"time": time_, "level": level, "message": message})
619598

620599
logger.debug("[%s] Retrieved scan log messages" % taskid)

txt/checksum.md5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ f1531be15ed98555a9010e2db3c9da75 lib/core/optiondict.py
4646
d8e9250f3775119df07e9070eddccd16 lib/core/replication.py
4747
785f86e3f963fa3798f84286a4e83ff2 lib/core/revision.py
4848
40c80b28b3a5819b737a5a17d4565ae9 lib/core/session.py
49-
cbbdac42ff202cffc475492e6652fce5 lib/core/settings.py
49+
58c602f0b15b945250f7dadbe3702c98 lib/core/settings.py
5050
d91291997d2bd2f6028aaf371bf1d3b6 lib/core/shell.py
5151
2ad85c130cc5f2b3701ea85c2f6bbf20 lib/core/subprocessng.py
5252
04cca8a05faef752c98d1a775d98a0e6 lib/core/target.py
@@ -98,7 +98,7 @@ d3da4c7ceaf57c4687a052d58722f6bb lib/techniques/dns/use.py
9898
310efc965c862cfbd7b0da5150a5ad36 lib/techniques/union/__init__.py
9999
d71e48e6fd08f75cc612bf8b260994ce lib/techniques/union/test.py
100100
db3090ff9a740ba096ba676fcf44ebfc lib/techniques/union/use.py
101-
67f0ad96ec2207d7e59c788b858afd6d lib/utils/api.py
101+
1f4c7000cc2a4e75a53c5f39c1a5f8b5 lib/utils/api.py
102102
7d10ba0851da8ee9cd3c140dcd18798e lib/utils/brute.py
103103
ed70f1ca9113664043ec9e6778e48078 lib/utils/crawler.py
104104
ba12c69a90061aa14d848b8396e79191 lib/utils/deps.py

0 commit comments

Comments
 (0)