The Electron ASAR archive format is clownshoes. The basic idea is simple: File c...
Oriel Jutty :hhHHHAAAH: @barubary@infosec.exchange
The Electron ASAR archive format is clownshoes.
The basic idea is simple: File contents are packed in one contiguous blob of bytes, and an index gives the directory/file structure (each file index entry contains an (offset, length) pair specifying where in the blob to grab the file contents from).
The index is in JSON format.
The file format has no magic number or other unambiguous identifying marks. However, due to how the implementation works, the following properties emerge: Every ASAR file starts with 04 00 00 00 (4 as a little-endian 32-bit integer) at offset zero. It is followed by three more closely related little-endian 32-bit integers:
- The third one gives the size (in bytes) of the immediately following JSON index.
- The second one is equal to the third one, rounded up to the nearest multiple of 4, plus 4.
- The first one is equal to the second one plus four.
For example, if the JSON index were the string {"files" : {}}, the numbers in the file header would be 4, 24, 20, 14:
- Index 0: Always 4.
- Index 1: 20 + 4 =24.
- Index 2:
next_multiple_of_4(14)+ 4 = 16 + 4 = 20. - Index 3:
length('{"files" : {}}')= 14.