DEB extractor

This commit is contained in:
n1073645 2020-03-05 15:01:07 +00:00
parent d78730edc0
commit 14190fc533

View file

@ -1716,13 +1716,27 @@ export const FILE_SIGNATURES = {
extension: "jar",
mime: "application/java-archive",
description: "",
signature: {
0: 0x5f,
1: 0x27,
2: 0xa8,
3: 0x89
},
extractor: null
signature: [
{
0: 0x5f,
1: 0x27,
2: 0xa8,
3: 0x89
},
{
0: 0x50,
1: 0x4B,
2: 0x03,
3: 0x04,
4: 0x14,
5: 0x00,
6: 0x08,
7: 0x00,
8: 0x08,
9: 0x00
}
],
extractor: extractZIP
},
{
name: "lzop compressed",
@ -1755,7 +1769,7 @@ export const FILE_SIGNATURES = {
5: 0x68,
6: 0x3e
},
extractor: null
extractor: extractDEB
},
{
name: "Apple Disk Image",
@ -3448,6 +3462,37 @@ export function extractXZ(bytes, offset) {
}
/**
* DEB extractor.
*
* @param {Uint8Array} bytes
* @param {Number} offset
*/
export function extractDEB(bytes, offset) {
const stream = new Stream(bytes.slice(offset));
// Move past !<arch>
stream.moveForwardsBy(8);
while (stream.hasMore()) {
// Move to size field.
stream.moveForwardsBy(48);
let fsize= "";
// Convert size to a usable number.
for (const elem of stream.getBytes(10)) {
fsize += String.fromCharCode(elem);
}
fsize = parseInt(fsize.trim(), 10);
// Move past `\n
stream.moveForwardsBy(2);
stream.moveForwardsBy(fsize);
}
return stream.carve();
}
/**
* ELF extractor.
*