kifurushi


Namekifurushi JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://kifurushi.readthedocs.io/en/stable
SummaryA simple library to forge network packets
upload_time2023-11-27 19:39:52
maintainer
docs_urlNone
authorlewoudar
requires_python>=3.8,<4.0
licenseApache-2.0
keywords kifurushi networking protocol sans-io packet
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Kifurushi

[![Pypi version](https://img.shields.io/pypi/v/kifurushi.svg)](https://pypi.org/project/kifurushi/)
[![](https://github.com/lewoudar/kifurushi/workflows/CI/badge.svg)](https://github.com/lewoudar/kifurushi/actions)
[![Coverage Status](https://codecov.io/gh/lewoudar/kifurushi/branch/main/graphs/badge.svg?branch=main)](https://codecov.io/gh/lewoudar/kifurushi)
[![Documentation Status](https://readthedocs.org/projects/kifurushi/badge/?version=latest)](https://kifurushi.readthedocs.io/en/latest/?badge=latest)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/lewoudar/ws)
[![License Apache 2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://github.com/lewoudar/kifurushi)

A simple library to forge network packets.

## Why?

I was playing with the DNS protocol using the excellent [scapy](https://scapy.readthedocs.io/) library.
It is very simple to forge network data with this library. I have always wondered why protocol libraries like
[h2](https://hyper-h2.readthedocs.io/en/stable/) or [aioquic](https://aioquic.readthedocs.io/en/latest/) don't use it
to forge packets instead of doing it all by hands and then I thought maybe it is because it will be overkill to import
the whole library containing many protocol implementations just for one thing you want to use (or maybe library authors
don't know the scapy library...). It would be glad to just use the scapy ability to forge packets without importing the
**huge** protocol library. This is where the idea of *kifurushi* comes from.

It is a simple library that will help you forge network data quickly. It is less capable than scapy because its specific
goal is to implement a concrete protocol as opposed to scapy which makes it possible to give free rein to its imagination.
So if you find that your needs cannot be simply express with kifurushi, you probably need to use scapy.

## Installation

with pip:

```bash
pip install kifurushi
```

With [poetry](https://python-poetry.org/docs/) an alternative package manager:

```bash
poetry add kifurushi
```

kifurushi starts working from **python3.7** and also supports **pypy3**. It has one dependency:
* [attrs](https://www.attrs.org/en/stable/): A library helping to write classes without pain.

## Documentation

The documentation is available at https://kifurushi.readthedocs.io

## Usage

```python
import socket
import enum
from kifurushi import Packet, ShortField, ByteField, IntEnumField

HOST = 'disney-stuff.com'
PORT = 14006


class Mood(enum.Enum):
  happy = 1
  cool = 2
  angry = 4


class Disney(Packet):
  __fields__ = [
    ShortField('mickey', 2),
    ByteField('minnie', 3, hex=True),
    IntEnumField('donald', 1, Mood)
  ]


with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  disney = Disney()
  s.connect((HOST, PORT))
  disney.donald = Mood.cool.value
  # we send the packet data
  s.sendall(disney.raw)
  # we create another packet object from raw bytes
  received_packet = Disney.from_bytes(s.recv(1024))
  print(received_packet)
```

To see more protocol implementations check the folder [examples](examples) of the project.

## Warnings

* If you use the excellent [Pycharm](https://www.jetbrains.com/pycharm/) editor, you may notice weird warnings when
  instantiating kifurushi fields. At the moment I'm writing this documentation, I'm using Pycharm 2020.3 and there is
  an [issue](https://youtrack.jetbrains.com/issue/PY-46298) when subclassing **attrs** classes. So just ignore the
  warning saying to fill the *format* parameter if you don't need it.
* kifurushi is a young project, so it is expected to have breaking changes in the api without respecting the
  [semver](https://semver.org/) principle. It is recommended to pin the version you are using for now.

            

Raw data

            {
    "_id": null,
    "home_page": "https://kifurushi.readthedocs.io/en/stable",
    "name": "kifurushi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "kifurushi,networking,protocol,sans-io,packet",
    "author": "lewoudar",
    "author_email": "lewoudar@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a1/bf/755f646b598f453d0b57bdf8adc1af91547705b5c53114c0135803e40a57/kifurushi-0.6.0.tar.gz",
    "platform": null,
    "description": "# Kifurushi\n\n[![Pypi version](https://img.shields.io/pypi/v/kifurushi.svg)](https://pypi.org/project/kifurushi/)\n[![](https://github.com/lewoudar/kifurushi/workflows/CI/badge.svg)](https://github.com/lewoudar/kifurushi/actions)\n[![Coverage Status](https://codecov.io/gh/lewoudar/kifurushi/branch/main/graphs/badge.svg?branch=main)](https://codecov.io/gh/lewoudar/kifurushi)\n[![Documentation Status](https://readthedocs.org/projects/kifurushi/badge/?version=latest)](https://kifurushi.readthedocs.io/en/latest/?badge=latest)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/lewoudar/ws)\n[![License Apache 2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://github.com/lewoudar/kifurushi)\n\nA simple library to forge network packets.\n\n## Why?\n\nI was playing with the DNS protocol using the excellent [scapy](https://scapy.readthedocs.io/) library.\nIt is very simple to forge network data with this library. I have always wondered why protocol libraries like\n[h2](https://hyper-h2.readthedocs.io/en/stable/) or [aioquic](https://aioquic.readthedocs.io/en/latest/) don't use it\nto forge packets instead of doing it all by hands and then I thought maybe it is because it will be overkill to import\nthe whole library containing many protocol implementations just for one thing you want to use (or maybe library authors\ndon't know the scapy library...). It would be glad to just use the scapy ability to forge packets without importing the\n**huge** protocol library. This is where the idea of *kifurushi* comes from.\n\nIt is a simple library that will help you forge network data quickly. It is less capable than scapy because its specific\ngoal is to implement a concrete protocol as opposed to scapy which makes it possible to give free rein to its imagination.\nSo if you find that your needs cannot be simply express with kifurushi, you probably need to use scapy.\n\n## Installation\n\nwith pip:\n\n```bash\npip install kifurushi\n```\n\nWith [poetry](https://python-poetry.org/docs/) an alternative package manager:\n\n```bash\npoetry add kifurushi\n```\n\nkifurushi starts working from **python3.7** and also supports **pypy3**. It has one dependency:\n* [attrs](https://www.attrs.org/en/stable/): A library helping to write classes without pain.\n\n## Documentation\n\nThe documentation is available at https://kifurushi.readthedocs.io\n\n## Usage\n\n```python\nimport socket\nimport enum\nfrom kifurushi import Packet, ShortField, ByteField, IntEnumField\n\nHOST = 'disney-stuff.com'\nPORT = 14006\n\n\nclass Mood(enum.Enum):\n  happy = 1\n  cool = 2\n  angry = 4\n\n\nclass Disney(Packet):\n  __fields__ = [\n    ShortField('mickey', 2),\n    ByteField('minnie', 3, hex=True),\n    IntEnumField('donald', 1, Mood)\n  ]\n\n\nwith socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:\n  disney = Disney()\n  s.connect((HOST, PORT))\n  disney.donald = Mood.cool.value\n  # we send the packet data\n  s.sendall(disney.raw)\n  # we create another packet object from raw bytes\n  received_packet = Disney.from_bytes(s.recv(1024))\n  print(received_packet)\n```\n\nTo see more protocol implementations check the folder [examples](examples) of the project.\n\n## Warnings\n\n* If you use the excellent [Pycharm](https://www.jetbrains.com/pycharm/) editor, you may notice weird warnings when\n  instantiating kifurushi fields. At the moment I'm writing this documentation, I'm using Pycharm 2020.3 and there is\n  an [issue](https://youtrack.jetbrains.com/issue/PY-46298) when subclassing **attrs** classes. So just ignore the\n  warning saying to fill the *format* parameter if you don't need it.\n* kifurushi is a young project, so it is expected to have breaking changes in the api without respecting the\n  [semver](https://semver.org/) principle. It is recommended to pin the version you are using for now.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A simple library to forge network packets",
    "version": "0.6.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/lewoudar/kifurushi/issues",
        "Documentation": "https://kifurushi.readthedocs.io/en/stable",
        "Homepage": "https://kifurushi.readthedocs.io/en/stable",
        "Repository": "https://github.com/lewoudar/kifurushi"
    },
    "split_keywords": [
        "kifurushi",
        "networking",
        "protocol",
        "sans-io",
        "packet"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73aff71d80190b92542c9d09895254880950683b35711930e92b75237fd719c9",
                "md5": "1e639843443d5fcd83db3d42aaadae08",
                "sha256": "007834f11913ff61937db4ea357e46575d13487ef7e2b9027684eff22aeba091"
            },
            "downloads": -1,
            "filename": "kifurushi-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1e639843443d5fcd83db3d42aaadae08",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 23284,
            "upload_time": "2023-11-27T19:39:51",
            "upload_time_iso_8601": "2023-11-27T19:39:51.169224Z",
            "url": "https://files.pythonhosted.org/packages/73/af/f71d80190b92542c9d09895254880950683b35711930e92b75237fd719c9/kifurushi-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1bf755f646b598f453d0b57bdf8adc1af91547705b5c53114c0135803e40a57",
                "md5": "d8aab7558bc779748d5ecdcba7d728e2",
                "sha256": "cc2b004210dc3901d3ae6d912bbd5672b986e50a5a38df95e6d4b255e67d9601"
            },
            "downloads": -1,
            "filename": "kifurushi-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d8aab7558bc779748d5ecdcba7d728e2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 19711,
            "upload_time": "2023-11-27T19:39:52",
            "upload_time_iso_8601": "2023-11-27T19:39:52.973353Z",
            "url": "https://files.pythonhosted.org/packages/a1/bf/755f646b598f453d0b57bdf8adc1af91547705b5c53114c0135803e40a57/kifurushi-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-27 19:39:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lewoudar",
    "github_project": "kifurushi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kifurushi"
}
        
Elapsed time: 0.15136s