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.1a1.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for libphpphar-0.0.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9676a91d05e2f07cc53cd44dd735ca2022ddef4fd3969795e5728728e67be6e |
|
MD5 | 2d1dce750f635a2b64c158f4487243ce |
|
BLAKE2b-256 | e9311ce36b7cb7c636fe705f9f21c2804050eaff99dd2733364319e5a1b82a38 |