Skip to content

Instantly share code, notes, and snippets.

@tomberek

tomberek/catar.ksy

Last active Aug 21, 2019
Embed
What would you like to do?
meta:
id: catar
file-extension: catar
endian: le
license: CC0-1.0
seq:
- id: top
type: ca_format
instances:
marker:
pos: _io.size-4
type: u4
enum: ca_type
tail:
pos: marker == ca_type::ca_format_goodbye_tail1 ? _io.size-24 : _io.size-40
type:
switch-on: marker
cases:
'ca_type::ca_format_goodbye_tail1': ca_format_goodbye_tail
'ca_type::ca_format_table_tail1': ca_format_table_tail
_: dummy
types:
dummy: {}
ca_format:
seq:
- id: header
type: ca_format_header
size: 16
- id: body
size: header.size - 16
type:
switch-on: header.type1
cases:
'ca_type::ca_format_entry1': ca_format_entry
'ca_type::ca_format_user1': ca_format_user
'ca_type::ca_format_group1': ca_format_group
'ca_type::ca_format_filename1': ca_format_filename
'ca_type::ca_format_payload1': ca_format_payload
'ca_type::ca_format_goodbye1': ca_format_goodbye
'ca_type::ca_format_index1': ca_format_index
#'ca_type::ca_format_table1': ca_format_table
ca_format_table:
params:
- id: num
type: u4
seq:
- id: header
size: 16
type: ca_format_header
- id: items
type: ca_format_table_item
size: 40
repeat: expr
# Subtract header, count items, subtract tail
repeat-expr: (num - 16) / 40 - 1
- id: tail
type: ca_format_table_tail
ca_format_table_item:
seq:
- id: offset
type: u8
- id: hash
size: 32
ca_format_table_tail:
seq:
- id: zeros
size: 16
- id: index_offset
type: u8
- id: size
type: u8
- id: marker2
type: u4
enum: ca_type
- id: marker1
type: u4
enum: ca_type
instances:
index:
pos: index_offset
type: ca_format_table(size)
ca_format_index:
seq:
- id: feature_flags
type: u8
- id: chunk_size_min
type: u8
- id: chunk_size_avg
type: u8
- id: chunk_size_max
type: u8
ca_format_goodbye:
seq:
- id: items
size: 24
type: ca_format_goodbye_item
repeat: expr
repeat-expr: _parent.header.size / 24 -1
- id: tail
type: ca_format_goodbye_tail
ca_format_goodbye_tail:
seq:
- id: entry_offset
type: u8
- id: size
type: u8
- id: marker1
contents: [0x43,0x29,0x70,0x33,0xa5,0x6f,0x44,0x57]
instances:
goodbye:
io: _root._io
pos: entry_offset
type: ca_format
ca_format_goodbye_item:
seq:
- id: offset
type: u8
- id: size
type: u8
- id: hash
type: u8
instances:
reference:
io: _root._io
pos: _root._io.size - _parent._io.size - offset -16
size: size
type: ca_filename_payload
ca_filename_payload:
seq:
- id: ca
type: ca_format
repeat: eos
ca_format_payload:
instances:
data:
size: _parent.header.size - 16
ca_format_user:
seq:
- id: name
encoding: UTF-8
type: strz
ca_format_group:
seq:
- id: name
encoding: UTF-8
type: strz
ca_format_filename:
seq:
- id: name
encoding: UTF-8
type: strz
ca_format_entry:
seq:
- id: feature_flags
type: u8
- id: mode
type: u8
- id: flags
type: u8
- id: uid
type: u8
- id: gid
type: u8
- id: mtime
type: u8
ca_format_header:
seq:
- id: size
type: u8
- id: type2
type: u4
enum: ca_type
- id: type1
type: u4
enum: ca_type
enums:
big_type:
0x57446fa5_33702943: ca_format_goodybe_tail_marker
ca_type:
0x96824d9c: ca_format_index1
0x7b129ff9: ca_format_index2
0xe75b9e11: ca_format_table1
0x2f17417d: ca_format_table2
0x4b4f050e: ca_format_table_tail1
0x5549ecd1: ca_format_table_tail2
0x1396fabc: ca_format_entry1
0xea5bbb51: ca_format_entry2
0xf453131a: ca_format_user1
0xaeeaccb3: ca_format_user2
0x25eb6ac9: ca_format_group1
0x69396a52: ca_format_group2
0x6dbb6ebc: ca_format_filename1
0xb3161f0b: ca_format_filename2
0x8b9e1d93: ca_format_payload1
0xd6dcffc9: ca_format_payload2
0xdfd35c5e: ca_format_goodbye1
0x8327c403: ca_format_goodbye2
0x57446fa5: ca_format_goodbye_tail1
0x33702943: ca_format_goodybe_tail2
@tomberek

This comment has been minimized.

Copy link
Owner Author

@tomberek tomberek commented Aug 11, 2019

Use the .ksy at https://ide.kaitai.io/# to see a visualization of the file format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment