Skip to content

0x00-pl/flatbuffers_modifier

Repository files navigation

flatbuffers modifier

CI status

download flatc using poetry

poetry run install-flatc

download flatc using python

from scripts.install_flatc import download_and_extract_flatc

download_and_extract_flatc()

generate flatbuffers python code

flatc --python -o <output_path> <fbs_file>

usage

reference from tests/test_flatbuffers_modifier.py

from flatbuffers_modifier import FlatbuffersModifier

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

# add compiled flatbuffers schema to sys.path
modifier = FlatbuffersModifier(data, "MyGame.Sample", "Monster")
modifications = {
    "hp": 500,
    "weapon.damage": 10,
    "weapon.type": "Bow"
}
updated_data = modifier.modify_fields(modifications)

with open("tests/data/output/updated_monster.bin", "wb") as f:
    f.write(updated_data)

About

modify flatbuffers data file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages