Search code examples
hexhexdumpkaitai-struct

Parsing Hex dump


I recently came across a kaitai struct to deal with arbitrary binary formats. Now the thing is I have a hex-dump what I mean by that is I have a file which i want to parse and its in hex format when i use the visualizer in the web ide of kaitai for the mapping of data, it's converting the hex data again into hex is there any way i can convert the data from hex and get the exact hex data when i use the visualizer.

for example consider this 3335363330 and then again its mapping it to 33 33 33 35 33 36 33 33 33 30

thanks in advance


Solution

  • Currently the Kaitai WebIDE & the console visualizer (ksv) does not support reading hex-encoded files, only raw binary files.

    The solution is to convert the hex-encoded (text) file to a binary one first and then load the binary file into Kaitai.

    You can do this by calling xxd -r -p <input_file >output_file on Linux or eg. calling this small Python script: python -c "open('output_file','wb').write(open('input_file','r').read().strip().decode('hex'))". The latter works on any machine where Python 2 is installed.