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

Skip to content

Commit 7d9cd0c

Browse files
committed
Stabilizing first drei compatible prototype
1 parent 6dbf245 commit 7d9cd0c

7 files changed

Lines changed: 23 additions & 13 deletions

File tree

lib/controller/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _saveToHashDB():
220220
_[key] = injection
221221
else:
222222
_[key].data.update(injection.data)
223-
hashDBWrite(HASHDB_KEYS.KB_INJECTIONS, _.values(), True)
223+
hashDBWrite(HASHDB_KEYS.KB_INJECTIONS, list(_.values()), True)
224224

225225
_ = hashDBRetrieve(HASHDB_KEYS.KB_ABS_FILE_PATHS, True)
226226
hashDBWrite(HASHDB_KEYS.KB_ABS_FILE_PATHS, kb.absFilePaths | (_ if isinstance(_, set) else set()), True)

lib/core/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3290,7 +3290,9 @@ def arrayizeValue(value):
32903290
['1']
32913291
"""
32923292

3293-
if not isListLike(value):
3293+
if isinstance(value, collections.KeysView):
3294+
value = [_ for _ in value]
3295+
elif not isListLike(value):
32943296
value = [value]
32953297

32963298
return value
@@ -3393,7 +3395,7 @@ def showHttpErrorCodes():
33933395
warnMsg = "HTTP error codes detected during run:\n"
33943396
warnMsg += ", ".join("%d (%s) - %d times" % (code, _http_client.responses[code] if code in _http_client.responses else '?', count) for code, count in kb.httpErrorCodes.items())
33953397
logger.warn(warnMsg)
3396-
if any((str(_).startswith('4') or str(_).startswith('5')) and _ != _http_client.INTERNAL_SERVER_ERROR and _ != kb.originalCode for _ in kb.httpErrorCodes.keys()):
3398+
if any((str(_).startswith('4') or str(_).startswith('5')) and _ != _http_client.INTERNAL_SERVER_ERROR and _ != kb.originalCode for _ in kb.httpErrorCodes):
33973399
msg = "too many 4xx and/or 5xx HTTP error codes "
33983400
msg += "could mean that some kind of protection is involved (e.g. WAF)"
33993401
logger.debug(msg)

lib/core/convert.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import sys
1717

1818
from lib.core.settings import IS_WIN
19+
from lib.core.settings import PICKLE_PROTOCOL
1920
from lib.core.settings import UNICODE_ENCODING
2021
from thirdparty import six
2122

@@ -50,7 +51,7 @@ def base64pickle(value):
5051
retVal = None
5152

5253
try:
53-
retVal = base64encode(pickle.dumps(value, pickle.HIGHEST_PROTOCOL))
54+
retVal = base64encode(pickle.dumps(value, PICKLE_PROTOCOL))
5455
except:
5556
warnMsg = "problem occurred while serializing "
5657
warnMsg += "instance of a type '%s'" % type(value)
@@ -59,7 +60,7 @@ def base64pickle(value):
5960
try:
6061
retVal = base64encode(pickle.dumps(value))
6162
except:
62-
retVal = base64encode(pickle.dumps(str(value), pickle.HIGHEST_PROTOCOL))
63+
retVal = base64encode(pickle.dumps(str(value), PICKLE_PROTOCOL))
6364

6465
return retVal
6566

lib/core/dump.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def userSettings(self, header, userSettings, subHeader, content_type=None):
194194
self._areAdmins = userSettings[1]
195195
userSettings = userSettings[0]
196196

197-
users = userSettings.keys()
197+
users = list(userSettings.keys())
198198
users.sort(key=lambda _: _.lower() if hasattr(_, "lower") else _)
199199

200200
if conf.api:
@@ -288,7 +288,7 @@ def dbTableColumns(self, tableColumns, content_type=None):
288288

289289
colType = None
290290

291-
colList = columns.keys()
291+
colList = list(columns.keys())
292292
colList.sort(key=lambda _: _.lower() if hasattr(_, "lower") else _)
293293

294294
for column in colList:
@@ -372,7 +372,7 @@ def dbTablesCount(self, dbTables):
372372
self._write("| Table%s | Entries%s |" % (blank1, blank2))
373373
self._write("+%s+%s+" % (lines1, lines2))
374374

375-
sortedCounts = counts.keys()
375+
sortedCounts = list(counts.keys())
376376
sortedCounts.sort(reverse=True)
377377

378378
for count in sortedCounts:
@@ -484,7 +484,7 @@ def dbTableValues(self, tableValues):
484484
field = 1
485485
fields = len(tableValues) - 1
486486

487-
columns = prioritySortColumns(tableValues.keys())
487+
columns = prioritySortColumns(list(tableValues.keys()))
488488

489489
if conf.col:
490490
cols = conf.col.split(',')

lib/core/settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lib.core.enums import OS
1818

1919
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
20-
VERSION = "1.3.5.1"
20+
VERSION = "1.3.5.2"
2121
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2222
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2323
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
@@ -618,7 +618,10 @@
618618
HASHDB_END_TRANSACTION_RETRIES = 3
619619

620620
# Unique milestone value used for forced deprecation of old HashDB values (e.g. when changing hash/pickle mechanism)
621-
HASHDB_MILESTONE_VALUE = "BZzRotigLX" # python -c 'import random, string; print "".join(random.sample(string.ascii_letters, 10))'
621+
HASHDB_MILESTONE_VALUE = "OdqjeUpBLc" # python -c 'import random, string; print "".join(random.sample(string.ascii_letters, 10))'
622+
623+
# Pickle protocl used for storage of serialized data inside HashDB (https://docs.python.org/3/library/pickle.html#data-stream-format)
624+
PICKLE_PROTOCOL = 2
622625

623626
# Warn user of possible delay due to large page dump in full UNION query injections
624627
LARGE_OUTPUT_THRESHOLD = 1024 ** 2

lib/core/testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def smokeTest():
143143
return retVal
144144

145145
def adjustValueType(tagName, value):
146-
for family in optDict.keys():
146+
for family in optDict:
147147
for name, type_ in optDict[family].items():
148148
if type(type_) == tuple:
149149
type_ = type_[0]

sqlmap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,12 @@ def main():
375375
os.remove(filepath)
376376
except OSError:
377377
pass
378+
378379
if not filterNone(filepath for filepath in glob.glob(os.path.join(kb.tempDir, '*')) if not any(filepath.endswith(_) for _ in ('.lock', '.exe', '_'))):
379-
shutil.rmtree(kb.tempDir, ignore_errors=True)
380+
try:
381+
shutil.rmtree(kb.tempDir, ignore_errors=True)
382+
except OSError:
383+
pass
380384

381385
if conf.get("hashDB"):
382386
conf.hashDB.flush(True)

0 commit comments

Comments
 (0)