GTAR
application/x-gtar
Magic Bytes
Offset: 257
75 73 74 61 72 20 20 00
GNU Tar (GTAR) is an archival file format developed by the GNU Project to extend the capabilities of the standard POSIX tar specification. It is primarily used to aggregate multiple files into a single container for system backups, software distribution, and data portability across Unix-like environments. Although the format does not inherently employ compression, it preserves critical file system metadata such as permissions and directory structures, necessitating standard verification when extracting archives from untrusted sources.
Validation Code
How to validate .gtar files in Python
Python
def is_gtar(file_path: str) -> bool:
"""
Check if file is a valid GTAR by magic bytes.
Signature offset: 257 bytes
"""
signature = bytes([0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00])
with open(file_path, "rb") as f:
f.seek(257)
return f.read(8) == signature
How to validate .gtar files in Node.js
Node.js
function isGTAR(buffer: Buffer): boolean {
// Signature offset: 257 bytes
const signature = Buffer.from([0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00]);
if (buffer.length < 265) return false;
return buffer.subarray(257, 265).equals(signature);
}
Go
func IsGTAR(data []byte) bool {
// Signature offset: 257 bytes
signature := []byte{0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00}
if len(data) < 265 {
return false
}
return bytes.Equal(data[257:265], signature)
}
API Endpoint
GET
/api/v1/gtar
curl https://filesignature.org/api/v1/gtar