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

Method decode_value

pocsuite3/lib/helper/java/serialization.py:307–350  ·  view source on GitHub ↗
(self, io)

Source from the content-addressed store, hash-verified

305 raise Exception('Unsupported NewArray Type')
306
307 def decode_value(self, io):
308 if self.type == 'byte':
309 value = io.read(1)
310 if not value:
311 raise Exception('Failed to deserialize NewArray value')
312 value = struct.unpack('>B', value)[0]
313 elif self.type == 'char':
314 value = io.read(2)
315 if not value or len(value) != 2:
316 raise Exception('Failed to deserialize NewArray value')
317 value = struct.unpack('>ss', value)[0]
318 elif self.type == 'boolean':
319 value = io.read(1)
320 if not value:
321 raise Exception('Failed to deserialize NewArray value')
322 value = struct.unpack('>B', value)[0]
323 elif self.type == 'short':
324 value = io.read(2)
325 if not value or len(value) != 2:
326 raise Exception('Failed to deserialize NewArray value')
327 value = struct.unpack('>H', value)[0]
328 elif self.type == 'int':
329 value = io.read(4)
330 if not value or len(value) != 4:
331 raise Exception('Failed to deserialize NewArray value')
332 value = struct.unpack('>I', value)[0]
333 elif self.type == 'long':
334 value = io.read(8)
335 if not value or len(value) != 8:
336 raise Exception('Failed to deserialize NewArray value')
337 value = struct.unpack('>Q', value)[0]
338 elif self.type == 'float':
339 value = io.read(4)
340 if not value or len(value) != 4:
341 raise Exception('Failed to deserialize NewArray value')
342 value = struct.unpack('>F', value)[0]
343 elif self.type == 'double':
344 value = io.read(8)
345 if not value or len(value) != 8:
346 raise Exception('Failed to deserialize NewArray value')
347 value = struct.unpack('>D', value)[0]
348 else:
349 value = decode_content(io, self.stream)
350 return value
351
352 def encode_value(self, value):
353 if self.type == 'byte':

Callers 1

decodeMethod · 0.95

Calls 2

decode_contentFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected