GNU poke is already really promising. You can have a look at this presentation from Kernel Recipes 2019 to get a rough idea of what it looked like ~two years ago:
Think of it as the missing tool between an hex editor and a programming language. Hachoir, Kaitai, linker scripts or most reverse engineering toolkits (radare, etc.) all try to address a similar problem, but from a different angle.
Is this named after the old BASIC command "poke" on micros of the 80s?
This program looks pretty awesome and seems to fit into a use-case that I frequently want. I've usually just consigned myself to using standard hex editors, sometimes little bits of Python to wrangle whatever data I'm trying to manage.
Sounds like a better version of the old MS-DOS DEBUG.EXE to me, which for some reason I saw fit to use on explorer.exe on my dad's old WinBook XP running Windows 95 back in the day...
One thing I haven't had much success with when trying editors like this is dealing with variable data, like Pascal-style strings or varints. Another one is a length field that is either one byte, or a NUL byte followed by two bytes, or three NUL bytes followed by four bytes.
I'll have to give this one a try. It would be nice to be able to sift through binary data like bytecode or some non-standard serialization format without writing a one-off utility for it.
I recently tried Kaitai for something like this. It worked for some nontrivial cases, but I felt like I kept getting bitten by syntax limitations. All the way through, I kept wondering if writing a one off utility might be faster. But it was possible to express variable structures, sizes and counts. I was using the syntax and the cmd line visualizer, but might have been more productive with their html/gui tooling.
It lets you write "templates" in a weird hybrid syntax that looks a lot like a C header file but also allows control statements that can decode complicated data structures in a few lines of script. It looks to have very similar capabilities to GNU Poke, but with a GUI.
I skimmed through the manual and from what i can tell this seems to be more of a language (with a REPL) with support for handling data streams (they call them I/O Spaces for some reason) than an editor. There does seem to be support for declaring types of variable length and it is one of the first examples:
(this is an alternative to another way it provides by using unions which work similar to C unions but each alternative also has conditions for when it is valid).
So at least from the above i think it should be possible to declare types that work with variable length and prefixes like that.
It reminds me of 010 Editor. A programming language to describe structures is exactly what 010 Editor had (they were called “Binary Templates”). It allowed awesome things like: this next sequence of bytes is interpreted differently depending on the previously encountered bytes. For example, here’s the EXE file format: https://www.sweetscape.com/010editor/repository/files/EXE.bt
Me neither. I think the trick is to make it really, really dry and deadpan, then the humourless don't even notice and others have can have a little chuckle.
As I have said before in response to similar comments: HN has no problem with humour. Where it differs from, say, typical reddits is that in order to get upvoted rather than dowvoted, humorous comments have to actually be funny.
> Or sprinkle some AI on it and decide based on the destination.
Or avoid that overcomplication and specify what you want. As the one writing the command, you should know if the output is big and what the ideal is for the destination you want.
You don't have to make it for me haha. This is not a product specification and I am not a demanding customer. It's a hypothetical command that popped into my head while browsing a site with hacker in the name.
It's also a command I could throw together in about an hour with a bit of bash if I really wanted it. Mix in a bit of curl, bit of whatever the sendmail command is these days, bit of Twilio. Job's a good'un.
For the record "sprinkle some AI on it" is if statements, it was a yoke.
https://www.youtube.com/watch?v=92Sykut06N8
Think of it as the missing tool between an hex editor and a programming language. Hachoir, Kaitai, linker scripts or most reverse engineering toolkits (radare, etc.) all try to address a similar problem, but from a different angle.