generate PHP phar archives on the fly
Project description
libphpphar
A port of PHP's Phar class, in pure python
Installation
pip install libphpphar
(not available yet)
Features
- Phar generation with python, no more annoying
phar.readonly = Off
- uses libphpserialize for metadata serialization
Example
from datetime import datetime
from io import BytesIO
from phpphar import Phar, PharIOPhar
from phpserialize import PHP_Class
# for (un)serializing the metadatas
class VulnerableObject(PHP_Class):
pass
with open("app.phar", "rb") as f:
original = f.read()
archive: Phar = Phar.from_bytes(original)
# simply `archive = Phar()` if you want to start from scratch
print(archive.metadata)
for entry in archive.entries:
print(f'{entry.permissions}\t{entry.size}\t{datetime.fromtimestamp(entry.timestamp)}\t{entry.name}')
output = bytes(archive)
assert original == output
Important
- the code is written and tested under python 3.9+
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
libphpphar-0.0.2.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for libphpphar-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1075c179231d2ad1dd28ff72b27a8056f4eb9483a5ac79538336fad9044e23b3 |
|
MD5 | 61ae2b6c595c8138e53be68c4d117f32 |
|
BLAKE2b-256 | a222b8199a4ebea6143c56779b646c5506c076c491bdbd0129c2c2286c582617 |