Skip to main content

a naive implementation to parse raw vmess package

Project description

Pyvmess

PyPI - Version PyPI - Python Version code style - black imports - isort License - MIT

Pyvmess is a naive implementation to parse raw vmess package in Python. Note: As vmess is such a complicated protocol, it's quite hard to implement full feature decoder. There are quite a lot of cases which are covered by Pyvmess.

As this package is likely to be outdated, you can refer to vmess source code server code and client code if needed.

Table of Contents

Installation

pip install pyvmess

Usage

Let's take one challenge dieyingchongchong from qwb2022 as an example. Pyvmess can parse meta data from header and decode data from body. The following example can be found in test cases.

from uuid import UUID

import pyvmess


client_uuid = UUID("b831381d-6324-4d53-ad4f-8cda48b30811")
with open("data/client.bin", "rb") as f:
    client_data = f.read()

client_package = pyvmess.ClientVmessPackage(client_uuid, client_data)

timestamp = client_package.auth(1615528982 + 100)

client_package.decode_header()

client_package.decode_body()

print(b"".join(client_package.body_data).decode())

with open("tests/data/server.bin", "rb") as f:
    server_data = f.read()

server_package = pyvmess.ServerVmessPackage(
    client_package.response_header,
    client_package.body_iv,
    client_package.body_key,
    client_package.option,
    client_package.security,
    server_data,
)

server_package.decode_header()

server_package.decode_body()

print(b"".join(server_package.body_data).decode())

Build

Pyvmess uses hatch as the project manager. You can use hatch or any other build tools compliant with PEP517 such as build.

# hatch
hatch build
# build
python -m build

Tests

Pyvmess uses pytest for testing. You can run tests as follows.

hatch run test

License

pyvmess is distributed under the terms of the MIT license.

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

pyvmess-0.0.1.tar.gz (1.7 MB view hashes)

Uploaded Source

Built Distribution

pyvmess-0.0.1-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

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