Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I made a library called Restruct. https://github.com/go-restruct/restruct

It is useful for parsing and emitting binary structures. It uses Go struct tags to allow you to define fairly advanced arbitrary structures. Unlike some similar libraries, it supports both reading and writing data. I used it to write a quick program that manipulates FL Studio project files, and another that extracts PNGs out of a blob (like binwalk but more accurate for this specific task.)

https://github.com/jchv/pngextract

https://github.com/jchv/flsplit

If you’ve never seen Kaitai, it might take a while for it to click what you can do with it. I was actually inspired by 010 Editor’s binary templates, but found out about Kaitai Struct after creating Restruct. I stole their idea of having arbitrary expressions and wrote my own expression engine for Restruct, and also ended up contributing improvements to Kaitai’s Go compiler too, for good measure. The bottom line is, these tools make it extremely easy to work with complex binary files. I can incrementally sketch out an unknown file format, like FL Studio FLP, and quickly test my assumptions about structure shape. Kaitai also has their IDE tool, which lets you use Kaitai interactively:

https://ide.kaitai.io/

I actually hope to do the same for Restruct, but want to re-engineer some aspects of it to make it work better in an interactive context.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: