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

Skip to content

Commit 075fa1d

Browse files
committed
Minor improvement (bz2 slow, zlib fast)
1 parent 5be407e commit 075fa1d

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

lib/core/bigarray.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
except:
1111
import pickle
1212

13-
import bz2
1413
import itertools
1514
import os
1615
import sys
1716
import tempfile
17+
import zlib
1818

1919
from lib.core.compat import xrange
2020
from lib.core.enums import MKSTEMP_PREFIX
@@ -24,17 +24,17 @@
2424

2525
DEFAULT_SIZE_OF = sys.getsizeof(object())
2626

27-
def _size_of(object_):
27+
def _size_of(instance):
2828
"""
29-
Returns total size of a given object_ (in bytes)
29+
Returns total size of a given instance / object (in bytes)
3030
"""
3131

32-
retval = sys.getsizeof(object_, DEFAULT_SIZE_OF)
32+
retval = sys.getsizeof(instance, DEFAULT_SIZE_OF)
3333

34-
if isinstance(object_, dict):
35-
retval += sum(_size_of(_) for _ in itertools.chain.from_iterable(object_.items()))
36-
elif hasattr(object_, "__iter__"):
37-
retval += sum(_size_of(_) for _ in object_ if _ != object_)
34+
if isinstance(instance, dict):
35+
retval += sum(_size_of(_) for _ in itertools.chain.from_iterable(instance.items()))
36+
elif hasattr(instance, "__iter__"):
37+
retval += sum(_size_of(_) for _ in instance if _ != instance)
3838

3939
return retval
4040

@@ -54,8 +54,8 @@ class BigArray(list):
5454
5555
>>> _ = BigArray(xrange(100000))
5656
>>> _[20] = 0
57-
>>> _[100]
58-
100
57+
>>> _[99999]
58+
99999
5959
"""
6060

6161
def __init__(self, items=None):
@@ -92,7 +92,7 @@ def pop(self):
9292
self.chunks.pop()
9393
try:
9494
with open(self.chunks[-1], "rb") as f:
95-
self.chunks[-1] = pickle.loads(bz2.decompress(f.read()))
95+
self.chunks[-1] = pickle.loads(zlib.decompress(f.read()))
9696
except IOError as ex:
9797
errMsg = "exception occurred while retrieving data "
9898
errMsg += "from a temporary file ('%s')" % ex
@@ -113,7 +113,7 @@ def _dump(self, chunk):
113113
self.filenames.add(filename)
114114
os.close(handle)
115115
with open(filename, "w+b") as f:
116-
f.write(bz2.compress(pickle.dumps(chunk, pickle.HIGHEST_PROTOCOL), BIGARRAY_COMPRESS_LEVEL))
116+
f.write(zlib.compress(pickle.dumps(chunk, pickle.HIGHEST_PROTOCOL), BIGARRAY_COMPRESS_LEVEL))
117117
return filename
118118
except (OSError, IOError) as ex:
119119
errMsg = "exception occurred while storing data "
@@ -131,7 +131,7 @@ def _checkcache(self, index):
131131
if not (self.cache and self.cache.index == index):
132132
try:
133133
with open(self.chunks[index], "rb") as f:
134-
self.cache = Cache(index, pickle.loads(bz2.decompress(f.read())), False)
134+
self.cache = Cache(index, pickle.loads(zlib.decompress(f.read())), False)
135135
except Exception as ex:
136136
errMsg = "exception occurred while retrieving data "
137137
errMsg += "from a temporary file ('%s')" % ex

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

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

lib/core/testing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ def smokeTest():
327327
count, length = 0, 0
328328

329329
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
330-
if any(_ in root for _ in ("thirdparty", "extra")):
330+
if any(_ in root for _ in ("thirdparty", "extra", "interbase")):
331331
continue
332332

333333
for filename in files:
334334
if os.path.splitext(filename)[1].lower() == ".py" and filename != "__init__.py":
335335
length += 1
336336

337337
for root, _, files in os.walk(paths.SQLMAP_ROOT_PATH):
338-
if any(_ in root for _ in ("thirdparty", "extra")):
338+
if any(_ in root for _ in ("thirdparty", "extra", "interbase")):
339339
continue
340340

341341
for filename in files:

0 commit comments

Comments
 (0)