diff --git a/data/txt/sha256sums.txt b/data/txt/sha256sums.txt index e7e2aba3de..31cdb6e8d9 100644 --- a/data/txt/sha256sums.txt +++ b/data/txt/sha256sums.txt @@ -167,12 +167,12 @@ e376093d4f6e42ee38b050af329179df9c1c136b7667b2f1cb559f5d4b69ebd9 lib/controller 56e03690c1b783699c9f30cb2f8cc743d3716aba8137e6b253b21d1dd31a4314 lib/controller/handler.py 1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/controller/__init__.py 2a96190ced25d8929861b13866101812fcadf5cac23dd1dd4b29b1a915918769 lib/core/agent.py -1da4ec9cd9b67c8b54e4a3d314f8237d58778d8f3a00bc26a1e0540294dca30f lib/core/bigarray.py +3f13b3856fb5c51a392bfe90e8380b44ec74e7df82d50940e28536a1a5e513a6 lib/core/bigarray.py af24159b8ca5b8fe5e13cdfdedc2a758a2f4883361a601e0a550127cff368b3a lib/core/common.py a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py -e396b7971d38896e0e20b973a3a6a3fbc3171d080a21bc6e66a65bee452fd69c lib/core/datatype.py +ca06a0e9d66a58e74ef994d53f9b3cd2ebaed98735bbab99854054235a8083d6 lib/core/datatype.py e18c0c2c5a57924a623792a48bfd36e98d9bc085f6db61a95fc0dc8a3bcedc0c lib/core/decorators.py 147823c37596bd6a56d677697781f34b8d1d1671d5a2518fbc9468d623c6d07d lib/core/defaults.py 6b366f897e66b9df39df2ee45fef77d46efb7a2d4e294440d3aa7dc1b2f4cedf lib/core/dicts.py @@ -187,9 +187,9 @@ a033f92d136c707a25927c2383125ddb004d4283db62c004dcd67c3fc242bb1c lib/core/dump. 49c0fa7e3814dfda610d665ee02b12df299b28bc0b6773815b4395514ddf8dec lib/core/profiling.py 03db48f02c3d07a047ddb8fe33a757b6238867352d8ddda2a83e4fec09a98d04 lib/core/readlineng.py 48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py -3574639db4942d16a2dc0a2f04bb7c0913c40c3862b54d34c44075a760e0c194 lib/core/revision.py +0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py 888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py -7e7d27e3e472e55c3938d7041bab589b29f425548f11f93c939b249da36bce98 lib/core/settings.py +d6577e20ed58d058dcde4341010e3ea26240cc959185ce9471eda0fab17a21cf lib/core/settings.py cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py diff --git a/lib/core/bigarray.py b/lib/core/bigarray.py index 14c8ad3f02..b9f78c07a5 100644 --- a/lib/core/bigarray.py +++ b/lib/core/bigarray.py @@ -305,11 +305,29 @@ def __repr__(self): return "%s%s" % ("..." if len(self.chunks) > 1 else "", self.chunks[-1].__repr__()) def __iter__(self): - for i in xrange(len(self)): - try: - yield self[i] - except IndexError: - break + with self._lock: + chunks = list(self.chunks) + cache_index = self.cache.index if isinstance(self.cache, Cache) else None + cache_data = self.cache.data if isinstance(self.cache, Cache) else None + + for idx, chunk in enumerate(chunks): + if isinstance(chunk, list): + for item in chunk: + yield item + else: + try: + if cache_index == idx and cache_data is not None: + data = cache_data + else: + with open(chunk, "rb") as f: + data = pickle.loads(zlib.decompress(f.read())) + except Exception as ex: + errMsg = "exception occurred while retrieving data " + errMsg += "from a temporary file ('%s')" % ex + raise SqlmapSystemException(errMsg) + + for item in data: + yield item def __len__(self): return len(self.chunks[-1]) if len(self.chunks) == 1 else (len(self.chunks) - 1) * self.chunk_length + len(self.chunks[-1]) diff --git a/lib/core/datatype.py b/lib/core/datatype.py index 2e31542c26..b0b1809f8a 100644 --- a/lib/core/datatype.py +++ b/lib/core/datatype.py @@ -20,21 +20,18 @@ class AttribDict(dict): >>> foo.bar = 1 >>> foo.bar 1 + >>> import copy; copy.deepcopy(foo).bar + 1 """ def __init__(self, indict=None, attribute=None, keycheck=True): if indict is None: indict = {} - # Set any attributes here - before initialisation - # these remain as normal attributes - self.attribute = attribute - self.keycheck = keycheck dict.__init__(self, indict) - self.__initialised = True - - # After initialisation, setting attributes - # is the same as setting an item + self.__dict__["_attribute"] = attribute + self.__dict__["_keycheck"] = keycheck + self.__dict__["_initialized"] = True def __getattr__(self, item): """ @@ -45,7 +42,7 @@ def __getattr__(self, item): try: return self.__getitem__(item) except KeyError: - if self.keycheck: + if self.__dict__.get("_keycheck"): raise AttributeError("unable to access item '%s'" % item) else: return None @@ -58,7 +55,7 @@ def __delattr__(self, item): try: return self.pop(item) except KeyError: - if self.keycheck: + if self.__dict__.get("_keycheck"): raise AttributeError("unable to access item '%s'" % item) else: return None @@ -69,14 +66,8 @@ def __setattr__(self, item, value): Only if we are initialised """ - # This test allows attributes to be set in the __init__ method - if "_AttribDict__initialised" not in self.__dict__: - return dict.__setattr__(self, item, value) - - # Any normal attributes are handled normally - elif item in self.__dict__: - dict.__setattr__(self, item, value) - + if "_initialized" not in self.__dict__ or item in self.__dict__: + self.__dict__[item] = value else: self.__setitem__(item, value) @@ -87,14 +78,12 @@ def __setstate__(self, dict): self.__dict__ = dict def __deepcopy__(self, memo): - retVal = self.__class__(keycheck=self.keycheck) + retVal = self.__class__(keycheck=self.__dict__.get("_keycheck")) memo[id(self)] = retVal - for attr in dir(self): - if not attr.startswith('_'): - value = getattr(self, attr) - if not isinstance(value, (types.BuiltinFunctionType, types.FunctionType, types.MethodType)): - setattr(retVal, attr, copy.deepcopy(value, memo)) + for attr, value in self.__dict__.items(): + if attr not in ('_attribute', '_keycheck', '_initialized'): + setattr(retVal, attr, copy.deepcopy(value, memo)) for key, value in self.items(): retVal.__setitem__(key, copy.deepcopy(value, memo)) diff --git a/lib/core/revision.py b/lib/core/revision.py index e7413937bb..e5e1a1e76f 100644 --- a/lib/core/revision.py +++ b/lib/core/revision.py @@ -22,43 +22,39 @@ def getRevisionNumber(): retVal = None filePath = None - _ = os.path.dirname(__file__) + directory = os.path.dirname(__file__) while True: - filePath = os.path.join(_, ".git", "HEAD") - if os.path.exists(filePath): + candidate = os.path.join(directory, ".git", "HEAD") + if os.path.exists(candidate): + filePath = candidate break - else: - filePath = None - if _ == os.path.dirname(_): - break - else: - _ = os.path.dirname(_) - while True: - if filePath and os.path.isfile(filePath): - with openFile(filePath, "r") as f: - content = getText(f.read()) - filePath = None + parent = os.path.dirname(directory) + if parent == directory: + break + directory = parent - if content.startswith("ref: "): - try: - filePath = os.path.join(_, ".git", content.replace("ref: ", "")).strip() - except UnicodeError: - pass + if filePath: + with openFile(filePath, "r") as f: + content = getText(f.read()).strip() - if filePath is None: - match = re.match(r"(?i)[0-9a-f]{32}", content) - retVal = match.group(0) if match else None - break - else: - break + if content.startswith("ref: "): + ref_path = content.replace("ref: ", "").strip() + filePath = os.path.join(directory, ".git", ref_path) + + if os.path.exists(filePath): + with openFile(filePath, "r") as f_ref: + content = getText(f_ref.read()).strip() + + match = re.match(r"(?i)[0-9a-f]{40}", content) + retVal = match.group(0) if match else None if not retVal: try: - process = subprocess.Popen("git rev-parse --verify HEAD", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + process = subprocess.Popen(["git", "rev-parse", "--verify", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, _ = process.communicate() - match = re.search(r"(?i)[0-9a-f]{32}", getText(stdout or "")) + match = re.search(r"(?i)[0-9a-f]{40}", getText(stdout or "")) retVal = match.group(0) if match else None except: pass diff --git a/lib/core/settings.py b/lib/core/settings.py index 36c33893ac..6927ca3425 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from thirdparty import six # sqlmap version (...) -VERSION = "1.10.1.57" +VERSION = "1.10.1.60" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)