Skip to main content

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


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.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

libphpphar-0.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file libphpphar-0.0.1.tar.gz.

File metadata

  • Download URL: libphpphar-0.0.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for libphpphar-0.0.1.tar.gz
Algorithm Hash digest
SHA256 90a3f6bf7cbbff7c9b1e9d2122347f744f2eb76b7679397879814f2989c7c995
MD5 86089ab10a9e33aa022bed355ed22600
BLAKE2b-256 9a5f703949f04888e9c8a1bc6ce766703ab35f5c0b5fb142b59f6af1376abbb0

See more details on using hashes here.

File details

Details for the file libphpphar-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: libphpphar-0.0.1-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

Hashes for libphpphar-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab5a421e630e110f9041230173f06985422713c15b8583dc15bad51ec7b9aa94
MD5 510a452078860bc50f60bdcf6fbe3d5c
BLAKE2b-256 febf16f381f3c03369d08afc8a43b74b7c8a4f71fec2a81c1b3ec560007a0e30

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page