diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-10-17 16:20:35 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-10-17 16:22:44 +1300 |
commit | 839813a84c3d63ca44d2721f6cb39b79c489195a (patch) | |
tree | d4cc5f86191dfef1c454ae51d2fa639b91e79cf3 /mitmproxy/contrib | |
parent | d60ef617e33211cee3808c8b145d576f34ff437a (diff) | |
download | mitmproxy-839813a84c3d63ca44d2721f6cb39b79c489195a.tar.gz mitmproxy-839813a84c3d63ca44d2721f6cb39b79c489195a.tar.bz2 mitmproxy-839813a84c3d63ca44d2721f6cb39b79c489195a.zip |
mitmproxy: zap six
Diffstat (limited to 'mitmproxy/contrib')
-rw-r--r-- | mitmproxy/contrib/tls/utils.py | 11 | ||||
-rw-r--r-- | mitmproxy/contrib/tnetstring.py | 7 | ||||
-rw-r--r-- | mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py | 21 |
3 files changed, 15 insertions, 24 deletions
diff --git a/mitmproxy/contrib/tls/utils.py b/mitmproxy/contrib/tls/utils.py index 4c917303..87afbacb 100644 --- a/mitmproxy/contrib/tls/utils.py +++ b/mitmproxy/contrib/tls/utils.py @@ -6,15 +6,12 @@ from __future__ import absolute_import, division, print_function import construct -import six - - class _UBInt24(construct.Adapter): def _encode(self, obj, context): - return ( - six.int2byte((obj & 0xFF0000) >> 16) + - six.int2byte((obj & 0x00FF00) >> 8) + - six.int2byte(obj & 0x0000FF) + return bytes( + (obj & 0xFF0000) >> 16, + (obj & 0x00FF00) >> 8, + obj & 0x0000FF ) def _decode(self, obj, context): diff --git a/mitmproxy/contrib/tnetstring.py b/mitmproxy/contrib/tnetstring.py index f5e1d5c1..22ecab65 100644 --- a/mitmproxy/contrib/tnetstring.py +++ b/mitmproxy/contrib/tnetstring.py @@ -41,7 +41,6 @@ all other strings are returned as plain bytes. """ import collections -import six from typing import io, Union, Tuple # noqa TSerializable = Union[None, bool, int, float, bytes, list, tuple, dict] @@ -96,7 +95,7 @@ def _rdumpq(q, size, value): elif value is False: write(b'5:false!') return size + 8 - elif isinstance(value, six.integer_types): + elif isinstance(value, int): data = str(value).encode() ldata = len(data) span = str(ldata).encode() @@ -191,16 +190,12 @@ def load(file_handle): def parse(data_type, data): # type: (int, bytes) -> TSerializable - if six.PY2: - data_type = ord(data_type) if data_type == ord(b','): return data if data_type == ord(b';'): return data.decode("utf8") if data_type == ord(b'#'): try: - if six.PY2: - return long(data) return int(data) except ValueError: raise ValueError("not a tnetstring: invalid integer literal: {}".format(data)) diff --git a/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py b/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py index ecc76efb..b616028c 100644 --- a/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py +++ b/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py @@ -5,7 +5,7 @@ Inspired by EAS Inspector for Fiddler https://easinspectorforfiddler.codeplex.com ------ The MIT License (MIT) ----- +----- The MIT License (MIT) ----- Filename: ASWBXMLByteQueue.py Copyright (c) 2014, David P. Shaw @@ -27,25 +27,25 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' -from six.moves.queue import Queue +from queue import Queue import logging class ASWBXMLByteQueue(Queue): def __init__(self, wbxmlBytes): - + self.bytesDequeued = 0 self.bytesEnqueued = 0 - + Queue.__init__(self) for byte in wbxmlBytes: self.put(ord(byte)) self.bytesEnqueued += 1 - - + + logging.debug("Array byte count: %d, enqueued: %d" % (self.qsize(), self.bytesEnqueued)) - + """ Created to debug the dequeueing of bytes """ @@ -54,18 +54,18 @@ class ASWBXMLByteQueue(Queue): self.bytesDequeued += 1 logging.debug("Dequeued byte 0x{0:X} ({1} total)".format(singleByte, self.bytesDequeued)) return singleByte - + """ Return true if the continuation bit is set in the byte """ def checkContinuationBit(self, byteval): continuationBitmask = 0x80 return (continuationBitmask & byteval) != 0 - + def dequeueMultibyteInt(self): iReturn = 0 singleByte = 0xFF - + while True: iReturn <<= 7 if (self.qsize() == 0): @@ -100,4 +100,3 @@ class ASWBXMLByteQueue(Queue): break return strReturn - |