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 details)
Built Distribution
File details
Details for the file libphpphar-0.0.2.tar.gz
.
File metadata
- Download URL: libphpphar-0.0.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d56a3dfbe76ef1174fe7020603e17d90ab3fcd2b525e42b628828273ea4004a0 |
|
MD5 | 54c41d48300a4ad98b7fa8ea8d05e4f9 |
|
BLAKE2b-256 | b81cfd49a9a8f66bb4928289d6e06b29d8a66fddb09a0e218a2efa515c114728 |
File details
Details for the file libphpphar-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: libphpphar-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1075c179231d2ad1dd28ff72b27a8056f4eb9483a5ac79538336fad9044e23b3 |
|
MD5 | 61ae2b6c595c8138e53be68c4d117f32 |
|
BLAKE2b-256 | a222b8199a4ebea6143c56779b646c5506c076c491bdbd0129c2c2286c582617 |