Javascript must be enabled for this page to work!

About

Why?

I wanted to test the limits of what was possible in the browser from a static site. Because all the files are static (no database, and no server-side functionality) IceBuddha is hosted on github pages.

Ridiculous things IceBuddha does

"Submitted" files are not uploaded anywhere. Everything happens in your browser locally.
If you're concerned, you can clone and host this project locally by running it in a simple web server,
such as using "python -m SimpleHTTPServer" in the folder you clone the repo to.

Files are parsed via >Python scripts that define the structure of the files.
The python is converted to Javascript in your browser via the skulpt library.
By clicking on the "Parse as" tab when you drop a file, you can see this Python code.
You can then edit it, and your file will parsed again immediately using your new code.
Again, this is all happening entirely in your browser without hitting the server.

You can take your python parse scripts, and run them directly on files to generate JSON data, without using your browser, as explained here

Similar projects/products

010 editor: Windows & Mac (commercial), odd format for binary templates to parse files, but looks similar to C structs and is often referenced.
Synalize It!: Mac only (commercial); XML based grammar format which means limited capability for more advanced binary file formats.

File parsing

IceBuddha can parse a few of the main structures in the following file types:

PE files (.exe, .dll, .sys)

GIF image files

Mach-O (Mac OS X files)

Expanding and adding your own file parsing

File types are automatically identified in drop.js via the function "ChooseParseScript". Look at pe.py to see an example of how files are parsed.

Change the PE in the line ib = icebuddha.IceBuddha(filedata, "PE") to be name of your file type.

The line imageDosHeader = ib.parse(0, "IMAGE_DOS_HEADER", """ creates a structure at offset 0 with name IMAGE_DOS_HEADER.
Then the next lines in that file describe what is in that structure.

Known variable types are:

BYTE, CHAR, and anything unknown: 1 byte

WORD: 2 bytes

DWORD: 4 bytes

ULONGLONG: 8 bytes

You can also create arrays such as WORD e_res2[10];

ib is the root object, so we then append imageDosHeader to that. Later we append objects to imageDosHeader

The line e_lfanew = imageDosHeader.getInt("e_lfanew") gets the value of PE.IMAGE_DOS_HEADER.e_lfanew in the file it parses, and sets the variable e_lfanew which is then used as the offset in the next line.

Usually you can specify an offset simply by using something like imageNtHeader.end() to specify the end of the previous object.

To describe a bit field, you can look at what I did for dllCharacteristics.

Finally, you just need to return everything with the lines return ib.getParseTree() and parser = Parse()

You can have loops, other functions, and other logic in your code, as shown in gif.py.

You can also describe what a value means as shown with the function setMeaningFromConstants in the file mach_o.py

You can set the endianness as shown with setBigEndian in the file mach_o.py

Project status

IceBuddha is mostly abandoned (last update on 2014-11-13). It does a lot of stuff, but a lot of things are impossible for a webapp based on static files (ex. saving files).