mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-28 18:50:42 +00:00
revert some minor changes
This commit is contained in:
parent
38cca379df
commit
82b5d61456
@ -54,6 +54,7 @@ BACK_WALL = b"3847asd"
|
||||
PAYLOAD = b"""s'd"ao<ac>so[sb]po(pc)se;sl/bsl\\eq="""
|
||||
FULL_PAYLOAD = FRONT_WALL + PAYLOAD + BACK_WALL
|
||||
|
||||
|
||||
# A XSSData is a named tuple with the following fields:
|
||||
# - url -> str
|
||||
# - injection_point -> str
|
||||
@ -65,6 +66,7 @@ class XSSData(NamedTuple):
|
||||
exploit: str
|
||||
line: str
|
||||
|
||||
|
||||
# A SQLiData is named tuple with the following fields:
|
||||
# - url -> str
|
||||
# - injection_point -> str
|
||||
|
@ -30,7 +30,7 @@ class Gif(KaitaiStruct):
|
||||
self.hdr = self._root.Header(self._io, self, self._root)
|
||||
self.logical_screen_descriptor = self._root.LogicalScreenDescriptorStruct(self._io, self, self._root)
|
||||
if self.logical_screen_descriptor.has_color_table:
|
||||
self._raw_global_color_table = self._io.read_bytes(self.logical_screen_descriptor.color_table_size * 3)
|
||||
self._raw_global_color_table = self._io.read_bytes((self.logical_screen_descriptor.color_table_size * 3))
|
||||
io = KaitaiStream(BytesIO(self._raw_global_color_table))
|
||||
self.global_color_table = self._root.ColorTable(io, self, self._root)
|
||||
|
||||
@ -99,7 +99,7 @@ class Gif(KaitaiStruct):
|
||||
self.height = self._io.read_u2le()
|
||||
self.flags = self._io.read_u1()
|
||||
if self.has_color_table:
|
||||
self._raw_local_color_table = self._io.read_bytes(self.color_table_size * 3)
|
||||
self._raw_local_color_table = self._io.read_bytes((self.color_table_size * 3))
|
||||
io = KaitaiStream(BytesIO(self._raw_local_color_table))
|
||||
self.local_color_table = self._root.ColorTable(io, self, self._root)
|
||||
|
||||
@ -168,7 +168,7 @@ class Gif(KaitaiStruct):
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.magic = self._io.ensure_fixed_contents(struct.pack('3b', 71, 73, 70))
|
||||
self.version = (self._io.read_bytes(3)).decode("ASCII")
|
||||
self.version = (self._io.read_bytes(3)).decode(u"ASCII")
|
||||
|
||||
|
||||
class ExtGraphicControl(KaitaiStruct):
|
||||
|
@ -94,7 +94,7 @@ class GoogleProtobuf(KaitaiStruct):
|
||||
if hasattr(self, '_m_wire_type'):
|
||||
return self._m_wire_type if hasattr(self, '_m_wire_type') else None
|
||||
|
||||
self._m_wire_type = self._root.Pair.WireTypes(self.key.value & 7)
|
||||
self._m_wire_type = self._root.Pair.WireTypes((self.key.value & 7))
|
||||
return self._m_wire_type if hasattr(self, '_m_wire_type') else None
|
||||
|
||||
@property
|
||||
|
@ -79,23 +79,23 @@ class Jpeg(KaitaiStruct):
|
||||
if ((self.marker != self._root.Segment.MarkerEnum.soi) and (self.marker != self._root.Segment.MarkerEnum.eoi)) :
|
||||
_on = self.marker
|
||||
if _on == self._root.Segment.MarkerEnum.sos:
|
||||
self._raw_data = self._io.read_bytes(self.length - 2)
|
||||
self._raw_data = self._io.read_bytes((self.length - 2))
|
||||
io = KaitaiStream(BytesIO(self._raw_data))
|
||||
self.data = self._root.SegmentSos(io, self, self._root)
|
||||
elif _on == self._root.Segment.MarkerEnum.app1:
|
||||
self._raw_data = self._io.read_bytes(self.length - 2)
|
||||
self._raw_data = self._io.read_bytes((self.length - 2))
|
||||
io = KaitaiStream(BytesIO(self._raw_data))
|
||||
self.data = self._root.SegmentApp1(io, self, self._root)
|
||||
elif _on == self._root.Segment.MarkerEnum.sof0:
|
||||
self._raw_data = self._io.read_bytes(self.length - 2)
|
||||
self._raw_data = self._io.read_bytes((self.length - 2))
|
||||
io = KaitaiStream(BytesIO(self._raw_data))
|
||||
self.data = self._root.SegmentSof0(io, self, self._root)
|
||||
elif _on == self._root.Segment.MarkerEnum.app0:
|
||||
self._raw_data = self._io.read_bytes(self.length - 2)
|
||||
self._raw_data = self._io.read_bytes((self.length - 2))
|
||||
io = KaitaiStream(BytesIO(self._raw_data))
|
||||
self.data = self._root.SegmentApp0(io, self, self._root)
|
||||
else:
|
||||
self.data = self._io.read_bytes(self.length - 2)
|
||||
self.data = self._io.read_bytes((self.length - 2))
|
||||
|
||||
if self.marker == self._root.Segment.MarkerEnum.sos:
|
||||
self.image_data = self._io.read_bytes_full()
|
||||
@ -131,9 +131,9 @@ class Jpeg(KaitaiStruct):
|
||||
self._io = _io
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.magic = (self._io.read_bytes_term(0, False, True, True)).decode("ASCII")
|
||||
self.magic = (self._io.read_bytes_term(0, False, True, True)).decode(u"ASCII")
|
||||
_on = self.magic
|
||||
if _on == "Exif":
|
||||
if _on == u"Exif":
|
||||
self.body = self._root.ExifInJpeg(self._io, self, self._root)
|
||||
|
||||
|
||||
@ -199,7 +199,7 @@ class Jpeg(KaitaiStruct):
|
||||
self._io = _io
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.magic = (self._io.read_bytes(5)).decode("ASCII")
|
||||
self.magic = (self._io.read_bytes(5)).decode(u"ASCII")
|
||||
self.version_major = self._io.read_u1()
|
||||
self.version_minor = self._io.read_u1()
|
||||
self.density_units = self._root.SegmentApp0.DensityUnit(self._io.read_u1())
|
||||
@ -207,4 +207,4 @@ class Jpeg(KaitaiStruct):
|
||||
self.density_y = self._io.read_u2be()
|
||||
self.thumbnail_x = self._io.read_u1()
|
||||
self.thumbnail_y = self._io.read_u1()
|
||||
self.thumbnail = self._io.read_bytes((self.thumbnail_x * self.thumbnail_y) * 3)
|
||||
self.thumbnail = self._io.read_bytes(((self.thumbnail_x * self.thumbnail_y) * 3))
|
||||
|
@ -37,7 +37,7 @@ class Png(KaitaiStruct):
|
||||
while True:
|
||||
_ = self._root.Chunk(self._io, self, self._root)
|
||||
self.chunks.append(_)
|
||||
if ((_.type == "IEND") or (self._io.is_eof())) :
|
||||
if ((_.type == u"IEND") or (self._io.is_eof())) :
|
||||
break
|
||||
|
||||
class Rgb(KaitaiStruct):
|
||||
@ -56,45 +56,45 @@ class Png(KaitaiStruct):
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.len = self._io.read_u4be()
|
||||
self.type = (self._io.read_bytes(4)).decode("UTF-8")
|
||||
self.type = (self._io.read_bytes(4)).decode(u"UTF-8")
|
||||
_on = self.type
|
||||
if _on == "iTXt":
|
||||
if _on == u"iTXt":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.InternationalTextChunk(io, self, self._root)
|
||||
elif _on == "gAMA":
|
||||
elif _on == u"gAMA":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.GamaChunk(io, self, self._root)
|
||||
elif _on == "tIME":
|
||||
elif _on == u"tIME":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.TimeChunk(io, self, self._root)
|
||||
elif _on == "PLTE":
|
||||
elif _on == u"PLTE":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.PlteChunk(io, self, self._root)
|
||||
elif _on == "bKGD":
|
||||
elif _on == u"bKGD":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.BkgdChunk(io, self, self._root)
|
||||
elif _on == "pHYs":
|
||||
elif _on == u"pHYs":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.PhysChunk(io, self, self._root)
|
||||
elif _on == "tEXt":
|
||||
elif _on == u"tEXt":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.TextChunk(io, self, self._root)
|
||||
elif _on == "cHRM":
|
||||
elif _on == u"cHRM":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.ChrmChunk(io, self, self._root)
|
||||
elif _on == "sRGB":
|
||||
elif _on == u"sRGB":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.SrgbChunk(io, self, self._root)
|
||||
elif _on == "zTXt":
|
||||
elif _on == u"zTXt":
|
||||
self._raw_body = self._io.read_bytes(self.len)
|
||||
io = KaitaiStream(BytesIO(self._raw_body))
|
||||
self.body = self._root.CompressedTextChunk(io, self, self._root)
|
||||
@ -199,7 +199,7 @@ class Png(KaitaiStruct):
|
||||
self._io = _io
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode("UTF-8")
|
||||
self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
|
||||
self.compression_method = self._io.read_u1()
|
||||
self._raw_text_datastream = self._io.read_bytes_full()
|
||||
self.text_datastream = zlib.decompress(self._raw_text_datastream)
|
||||
@ -264,12 +264,12 @@ class Png(KaitaiStruct):
|
||||
self._io = _io
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode("UTF-8")
|
||||
self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
|
||||
self.compression_flag = self._io.read_u1()
|
||||
self.compression_method = self._io.read_u1()
|
||||
self.language_tag = (self._io.read_bytes_term(0, False, True, True)).decode("ASCII")
|
||||
self.translated_keyword = (self._io.read_bytes_term(0, False, True, True)).decode("UTF-8")
|
||||
self.text = (self._io.read_bytes_full()).decode("UTF-8")
|
||||
self.language_tag = (self._io.read_bytes_term(0, False, True, True)).decode(u"ASCII")
|
||||
self.translated_keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"UTF-8")
|
||||
self.text = (self._io.read_bytes_full()).decode(u"UTF-8")
|
||||
|
||||
|
||||
class TextChunk(KaitaiStruct):
|
||||
@ -277,8 +277,8 @@ class Png(KaitaiStruct):
|
||||
self._io = _io
|
||||
self._parent = _parent
|
||||
self._root = _root if _root else self
|
||||
self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode("iso8859-1")
|
||||
self.text = (self._io.read_bytes_full()).decode("iso8859-1")
|
||||
self.keyword = (self._io.read_bytes_term(0, False, True, True)).decode(u"iso8859-1")
|
||||
self.text = (self._io.read_bytes_full()).decode(u"iso8859-1")
|
||||
|
||||
|
||||
class TimeChunk(KaitaiStruct):
|
||||
|
@ -41,7 +41,7 @@ class ASCommandResponse:
|
||||
raise ValueError("Empty WBXML body passed")
|
||||
except Exception as e:
|
||||
self.xmlString = None
|
||||
raise ValueError(f"Error: {e}")
|
||||
raise ValueError("Error: {0}".format(e))
|
||||
|
||||
def getWBXMLBytes(self):
|
||||
return self.wbxmlBytes
|
||||
|
@ -861,7 +861,7 @@ class ASWBXML:
|
||||
if (newCodePage >= 0 and newCodePage < 25):
|
||||
self.currentCodePage = newCodePage
|
||||
else:
|
||||
raise InvalidDataException(f"Unknown code page ID 0x{currentByte:X} encountered in WBXML")
|
||||
raise InvalidDataException("Unknown code page ID 0x{0:X} encountered in WBXML".format(currentByte))
|
||||
elif ( currentByte == GlobalTokens.END ):
|
||||
if (currentNode != None and currentNode.parentNode != None):
|
||||
currentNode = currentNode.parentNode
|
||||
@ -878,14 +878,14 @@ class ASWBXML:
|
||||
currentNode.appendChild(newTextNode)
|
||||
|
||||
elif ( currentByte in unusedArray):
|
||||
raise InvalidDataException(f"Encountered unknown global token 0x{currentByte:X}.")
|
||||
raise InvalidDataException("Encountered unknown global token 0x{0:X}.".format(currentByte))
|
||||
else:
|
||||
hasAttributes = (currentByte & 0x80) > 0
|
||||
hasContent = (currentByte & 0x40) > 0
|
||||
|
||||
token = currentByte & 0x3F
|
||||
if (hasAttributes):
|
||||
raise InvalidDataException(f"Token 0x{token:X} has attributes.")
|
||||
raise InvalidDataException("Token 0x{0:X} has attributes.".format(token))
|
||||
|
||||
strTag = self.codePages[self.currentCodePage].getTag(token)
|
||||
if (strTag == None):
|
||||
|
@ -52,7 +52,7 @@ class ASWBXMLByteQueue(Queue):
|
||||
def dequeueAndLog(self):
|
||||
singleByte = self.get()
|
||||
self.bytesDequeued += 1
|
||||
logging.debug(f"Dequeued byte 0x{singleByte:X} ({self.bytesDequeued} total)")
|
||||
logging.debug("Dequeued byte 0x{0:X} ({1} total)".format(singleByte, self.bytesDequeued))
|
||||
return singleByte
|
||||
|
||||
"""
|
||||
|
@ -288,7 +288,7 @@ class Redirect(threading.Thread):
|
||||
while True:
|
||||
try:
|
||||
packet = self.windivert.recv()
|
||||
except OSError as e:
|
||||
except WindowsError as e:
|
||||
if e.winerror == 995:
|
||||
return
|
||||
else:
|
||||
@ -306,7 +306,7 @@ class Redirect(threading.Thread):
|
||||
"""
|
||||
try:
|
||||
return self.windivert.recv()
|
||||
except OSError as e:
|
||||
except WindowsError as e:
|
||||
if e.winerror == 995:
|
||||
return None
|
||||
else:
|
||||
|
@ -1,5 +1,4 @@
|
||||
import queue
|
||||
import socket
|
||||
from OpenSSL import SSL
|
||||
|
||||
import wsproto
|
||||
|
@ -3,6 +3,7 @@ This file must be kept in a python2.7 and python3.5 compatible syntax!
|
||||
DO NOT use type annotations or other python3.6-only features that makes this file unparsable by older interpreters!
|
||||
"""
|
||||
|
||||
from __future__ import print_function # this is here for the version check to work on Python 2.
|
||||
|
||||
import sys
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user