Questions tagged [kaitai-struct]

Kaitai Struct is a declarative language used to describe binary data structures.

Kaitai Struct is a DSL (domain-specific language), designed to describe binary data structures in human- and machine-readable way. Description of certain structure ("format") can be written once and then translated using a compiler into a source code for supported programming languages — and then used from any program in that language.

44 questions
10
votes
2 answers

Parsing files over 2.15 GB in Java using Kaitai Struct

I'm parsing large PCAP files in Java using Kaitai-Struct. Whenever the file size exceeds Integer.MAX_VALUE bytes I face an IllegalArgumentException caused by the size limit of the underlying ByteBuffer. I haven't found references to this issue…
Julian
  • 192
  • 1
  • 12
6
votes
1 answer

Kaitai Struct: calculated instances with a condition

I'm trying to get Kaitai Struct to reverse engineer a binary structure. seq fields work as intended, but instances don't seem to work as I want them to. My binary format includes a header with a list of constants that I parse as header field with…
4
votes
1 answer

Python: reading ID3v1 tag with Kaitai Struct

I'm trying to get Kaitai Struct to parse a ID3v1 tag format for MP3s. According to the standard, it is a fixed format structure located at the certain offset - but the trick is that this offset is calculated not from the beginning of the file, but…
dpm_min
  • 315
  • 3
  • 6
4
votes
1 answer

Kaitai Struct: pass some field to achieve fault tolerance

is there has any way to pass some field when parsing a truncated log in Kaitai Struct? Because if it read a field (type specify to a enum) but value not in there, it will raise a NullPointer Exception. So I want ask if any way to achieve that just…
Kaniel Venson
  • 181
  • 2
  • 12
3
votes
1 answer

Parsing binary messages with kaitai struct & python

I need to extract and process data (variably-sized binary messages) from a very large message log. Using the Gif example and the online documentation, I have defined and compiled the variably-sized message layout into msg_log.py. Calling…
3
votes
2 answers

"installing" Kaitai Struct Python

I need help with installing Kaitai Struct on my Laptop. I installed python-kaitaistruct and compiled the network files. But i get an import error: Traceback (most recent call last): File "test2.py", line 1, in from ethernet_frame…
3
votes
1 answer

Parsing opcodes with Kaitai Struct

Doing my first steps in Kaitai Struct, I've been trying to do BSON parser as an excercise. My .ksy code that parses BSON element now looks like that: element: seq: - id: el_type type: u1 enum: bson_type - id:…
2
votes
1 answer

Kaitai (KSY) - optional attribute

I'm trying to describe SSH protocol in Kaitai language (.ksy file). At the beginning, there is a protocol version exchange in the following format: SSH-protoversion-softwareversion SP comments CR LF where SP comments is optional. AFAIK, there is…
2
votes
1 answer

Kaitai Struct Parameter Type

I am trying to pass a parameter to ksy file. The parameter is of type another ksy file. The reason is that i need to access all the fields from the ksy file passed as parameter. Is that possible? If yes, would you please provide me with syntax code…
Ossama
  • 45
  • 3
2
votes
1 answer

Parse an item depending on previous elements

To give some context, I am parsing a DICOM file, and having difficulties using the Transfer Syntax entry to determine whether to use implicit or explicit parsing. But let me define a simplified syntax, so no dicom knowledge is required. We have a…
Tamas Hegedus
  • 28,755
  • 12
  • 63
  • 97
2
votes
1 answer

Windows registry database parsing

I'm trying to parse Windows registry database hives file format using Kaitai Web IDE using this question as a reference, but I ran into the problem. The hive I'm most interested in is c:\windows\system32\config\software, and it's more than 90…
1
vote
1 answer

Can Kaitai Struct be used to describe TLV data without creating new types for each field?

I'm reverse engineering a file format that stores each field as TLV blocks (type, length, value). The fields do not have to be in order, or even present at all. Their presence is denoted with a sentinel, which is a 16-bit type identifier and a…
w0f
  • 908
  • 9
  • 23
1
vote
1 answer

Kaitai Struct: Any way to make entire body type dependent on presence/type of first byte?

I'm trying to write a Katai definition for the Postgres Wire Protocol V3: The issue I've run into is that every message except for the StartupMessage follows the same format. The StartupMessage is shaped differently. So I need to somehow say "The…
Gavin Ray
  • 595
  • 1
  • 3
  • 10
1
vote
0 answers

How do I implement a spec for this format?

I am working on the VST3 preset format. This is what I managed till now: meta: id: vstpreset file-extension: vstpreset endian: le seq: - id: magic contents: 'VST3' - id: version type: u4 - id: class_id type: str size: 32 …
demberto
  • 489
  • 5
  • 15
1
vote
1 answer

Kaitai Struct dump to json

I need a command line like "ksc" which can take parameters "binary file" and "yaml file" and dump it in json format. WebIDE is doing the same through "ExportToJson", but i need the same functionality from command line. Thank You
Ossama
  • 45
  • 3
1
2 3