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.1a0.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for libphpphar-0.0.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b8dc18f3c98ab3d9e07eeab701ac3d2ec8a2b66cfc5c23f5c484a758cafe2d3 |
|
MD5 | 109f998ab3078cc4b3b30de4855cd045 |
|
BLAKE2b-256 | 1caef1eb479d0d70d69b2616405fb27f23894c2a56a8a91ba883761432c1d91f |