marshal – Python marshal loader

This module contains functions to load and unserialize data (including .pyc files) serialized using the marshal module on most version of python.

pwnypack.marshal.marshal_load(fp, origin=None)[source]

Unserialize data serialized with marshal.dump(). This function works across python versions. Marshalled code objects are returned as instances of CodeObject.

Parameters:
  • fp (file) – A file or file-like object that contains the serialized data.
  • origin (dict) – The opcode specification of the python version that generated the data. If you provide None, the specs for the currently running python version will be used.
Returns:

The unserialized data.

pwnypack.marshal.marshal_loads(data, origin=None)[source]

Load data serialized with marshal.dump() from a bytestring.

Parameters:
  • data (bytes) – The marshalled data.
  • origin (dict) – The opcode specification of the python version that generated the data. If you provide None, the specs for the currently running python version will be used.
Returns:

The unserialized data.

pwnypack.marshal.pyc_load(fp)[source]

Load a .pyc file from a file-like object.

Parameters:fp (file) – The file-like object to read.
Returns:The parsed representation of the .pyc file.
Return type:PycFile
pwnypack.marshal.pyc_loads(data)[source]

Load a .pyc file from a bytestring.

Parameters:data (bytes) – The content of the .pyc file.
Returns:The parsed representation of the .pyc file.
Return type:PycFile