{"id":13541137,"url":"https://github.com/WindSoilder/nu_plugin_bin_reader","last_synced_at":"2025-04-02T08:30:57.324Z","repository":{"id":54352674,"uuid":"521980572","full_name":"WindSoilder/nu_plugin_bin_reader","owner":"WindSoilder","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-11T10:23:51.000Z","size":1478,"stargazers_count":11,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T13:51:20.459Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WindSoilder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-06T15:16:25.000Z","updated_at":"2024-10-14T07:02:57.000Z","dependencies_parsed_at":"2024-01-16T15:45:01.238Z","dependency_job_id":"0a67b941-893d-437c-9231-2499974375bc","html_url":"https://github.com/WindSoilder/nu_plugin_bin_reader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fnu_plugin_bin_reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fnu_plugin_bin_reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fnu_plugin_bin_reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WindSoilder%2Fnu_plugin_bin_reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WindSoilder","download_url":"https://codeload.github.com/WindSoilder/nu_plugin_bin_reader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246781920,"owners_count":20832934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T10:00:39.407Z","updated_at":"2025-04-02T08:30:56.896Z","avatar_url":"https://github.com/WindSoilder.png","language":"Python","readme":"# Nu plugin binary reader\nA [nushell](https://www.nushell.sh/) plugin to read binary data\n\n```\n     ┌───────┐\n     │  png  ├────────────────────┐\n     └───────┘                    │\n                                  │\n      ┌─────┐             ┌───────▼─────────────┐\n      │ ttf ├────────────►│                     │\n      └─────┘             │      Nushell        ├─────►Structured data\n                          │                     │\n     ┌───────┐            │                     │\n     │  bmp  ├───────────►└─────────────────────┘\n     └───────┘                   ▲\n                                 │\n    ┌─────────┐                  │\n    │   gif   ├──────────────────┘\n    └─────────┘\n        ...\n```\n\n\n# Screenshots\n## Parsing png and ttf\n![parse png and ttf](examples/demo.gif)\n\n## Download lib and parse binary\n![parse gif](examples/demo3.gif)\n\n## Prerequisite\n1. `nushell`, It's a nushell plugin, so you need it.\n2. `python3.6+`\n\n## Usage\n1. register the plugin to nushell\n```\nregister nu_plugin_bin_reader.py\n```\n\nIt will introduce a new command: `from-binary`.  So you can play with it\nYou can just do it once.\n\n2. fetch libs\n\nThere is `fetcher.nu` to help you download binary reader.  You can do something like this:\n\n```\n\u003e use fetcher.nu\n\u003e fetcher fetch-lib png\n```\n\nIt will download \"png\" binary parser for you.\n\n3. parse relative binary file\nTake `png` file as example, you can do the following to get `capture.png` information.\n\n```\nopen capture.png | from-binary png\n```\n\nThen it will output the following:\n```\n╭───────────┬───────────────────────────────────╮\n│ magic     │ [137, 80, 78, 71, 13, 10, 26, 10] │\n│ ihdr_len  │ 13                                │\n│ ihdr_type │ [73, 72, 68, 82]                  │\n│ ihdr      │ {record 7 fields}                 │\n│ ihdr_crc  │ [179, 17, 228, 177]               │\n│ chunks    │ [table 9 rows]                    │\n╰───────────┴───────────────────────────────────╯\n```\n\nOk, what if you want to get the size of png file, you need to know it's stored inside ihdr, so you just need to get `ihdr`.\n\n```\nopen capture.png | from-binary png | get ihdr\n```\n\nSo it will output the following:\n```\n╭────────────────────┬───────────────────╮\n│ width              │ 1470              │\n│ height             │ 728               │\n│ bit_depth          │ 8                 │\n│ color_type         │ {record 0 fields} │\n│ compression_method │ 0                 │\n│ filter_method      │ 0                 │\n│ interlace_method   │ 0                 │\n╰────────────────────┴───────────────────╯\n```\n\n## Note\nThe `kaitaistruct.py` is just a copy of [kaitai struct python runtime](https://github.com/kaitai-io/kaitai_struct_python_runtime), put it directly here, so we don't need extra requirements.  DON'T CHANGE IT.\n\n`reader/*.py` are just a copy of auto-generated parser, DON'T CHANGE IT.\n\nTo keep the repo as small as possible, it doesn't provide all parsing libs by default, and just provide `png`, `ttf` for showcase.\n\nIf you need all parsing lib, just do the following:\n```\nuse fetcher.nu\nfetcher fetch-all-libs\n```\n\nIt'll take several minutes to download all binary parsing libs which exists in kaitai gallery.\n\n## For more references\n- [Nushell plugin system](https://www.nushell.sh/book/plugins.html)\n- [kaitai struct](https://kaitai.io/)\n","funding_links":[],"categories":["Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWindSoilder%2Fnu_plugin_bin_reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWindSoilder%2Fnu_plugin_bin_reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWindSoilder%2Fnu_plugin_bin_reader/lists"}