Metadata-Version: 2.1
Name: libphpphar
Version: 0.0.1a0
Summary: generate PHP phar archives on the fly
Home-page: https://github.com/frankli0324/libphpphar
Author: Frank
Author-email: frankli0324@hotmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# 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](https://github.com/frankli0324/libphpserialize) for metadata serialization

## Example

```python
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+
