MCPcopy
hub / github.com/knownsec/pocsuite3 / Utf

Class Utf

pocsuite3/lib/helper/java/serialization.py:758–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756
757
758class Utf(Element):
759 def __init__(self, stream='', contents=''):
760 Element.__init__(self, stream)
761 self.contents = contents
762 self.length = len(contents)
763
764 def decode(self, io):
765 raw_length = io.read(2)
766 if not raw_length or len(raw_length) != 2:
767 raise Exception('Failed to unserialize Utf')
768 self.length = struct.unpack('>H', raw_length)[0]
769 if self.length == 0:
770 self.contents = ""
771 else:
772 self.contents = io.read(self.length)
773 if not self.contents or len(self.contents) != self.length:
774 raise Exception('Failed to unserialize Utf')
775 return self
776
777 def encode(self):
778 encoded = struct.pack('>H', self.length)
779 encoded += self.contents
780 return encoded
781
782 def __str__(self):
783 return self.contents
784
785
786class LongUtf(Utf):

Callers 4

decodeMethod · 0.85
decodeMethod · 0.85
decodeMethod · 0.85
decode_contentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected