Skip to content

Commit 2784ec6

Browse files
authored
Merge pull request #3446 from trailofbits/update-magic-defs
Update libmagic pattern defs
2 parents 871e3a6 + 6c963eb commit 2784ec6

130 files changed

Lines changed: 7225 additions & 1988 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

file

Submodule file updated 197 files

polyfile/magic.py

Lines changed: 150 additions & 38 deletions
Large diffs are not rendered by default.

polyfile/magic_defs/acorn

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#------------------------------------------------------------------------------
3-
# $File: acorn,v 1.8 2021/04/26 15:56:00 christos Exp $
3+
# $File: acorn,v 1.9 2024/08/30 17:29:28 christos Exp $
44
# acorn: file(1) magic for files found on Acorn systems
55
#
66

@@ -67,36 +67,3 @@
6767
>>8 byte x version %d,
6868
>>10 leshort =1 1 pattern
6969
>>10 leshort !1 %d patterns
70-
71-
# From: Joerg Jenderek
72-
# URL: https://www.kyzer.me.uk/pack/xad/#PackDir
73-
# reference: https://www.kyzer.me.uk/pack/xad/xad_PackDir.lha/PackDir.c
74-
# GRR: line below is too general as it matches also "Git pack" in ./revision
75-
0 string PACK\0
76-
# check for valid compression method 0-4
77-
>5 ulelong <5
78-
# https://www.riscosopen.org/wiki/documentation/show/Introduction%20To%20Filing%20Systems
79-
# To skip "Git pack" version 0 test for root directory object like
80-
# ADFS::RPC.$.websitezip.FONTFIX
81-
>>9 string >ADFS\ PackDir archive (RISC OS)
82-
# TrID labels above as "Acorn PackDir compressed Archive"
83-
# compression mode y (0 - 4) for GIF LZW with a maximum n bits
84-
# (y~n,0~12,1~13,2~14,3~15,4~16)
85-
>>>5 ulelong+12 x \b, LZW %u-bits compression
86-
# https://www.filebase.org.uk/filetypes
87-
# !Packdir compressed archive has three hexadecimal digits code 68E
88-
!:mime application/x-acorn-68E
89-
!:ext pkd/bin
90-
# null terminated root directory object like IDEFS::IDE-4.$.Apps.GRAPHICS.!XFMPdemo
91-
>>>9 string x \b, root "%s"
92-
# load address 0xFFFtttdd, ttt is the object filetype and dddddddddd is time
93-
>>>>&1 ulelong x \b, load address %#x
94-
# execution address 0xdddddddd dddddddddd is 40 bit unsigned centiseconds since 1.1.1900 UTC
95-
>>>>&5 ulelong x \b, exec address %#x
96-
# attributes (bits: 0~owner read,1~owner write,3~no delete,4~public read,5~public write)
97-
>>>>&9 ulelong x \b, attributes %#x
98-
# number of entries in this directory. for root dir 0
99-
#>>>&13 ulelong x \b, entries %#x
100-
# the entries start here with object name
101-
>>>>&17 string x \b, 1st object "%s"
102-

polyfile/magic_defs/adventure

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#------------------------------------------------------------------------------
3-
# $File: adventure,v 1.18 2019/04/19 00:42:27 christos Exp $
3+
# $File: adventure,v 1.19 2023/12/02 13:48:56 christos Exp $
44
# adventure: file(1) magic for Adventure game files
55
#
66
# from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
@@ -10,6 +10,8 @@
1010
# ALAN
1111
# I assume there are other, lower versions, but these are the only ones I
1212
# saw in the archive.
13+
#
14+
# FIXME: Conflicts with Microsoft x.out big-endian and PDP-11 binaries (./xenix)
1315
0 beshort 0x0206 ALAN game data
1416
>2 byte <10 version 2.6%d
1517

polyfile/magic_defs/algol68

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#------------------------------------------------------------------------------
3-
# $File: algol68,v 1.6 2022/11/06 18:36:55 christos Exp $
3+
# $File: algol68,v 1.7 2024/08/27 18:50:56 christos Exp $
44
# algol68: file(1) magic for Algol 68 source
55
#
66
# URL: https://en.wikipedia.org/wiki/ALGOL_68
@@ -13,8 +13,6 @@
1313
>0 use algol_68
1414
0 regex/1024 \bMODE[\t\ ]
1515
>0 use algol_68
16-
0 regex/1024 \bMODE[\t\ ]
17-
>0 use algol_68
1816
0 regex/1024 \bREF[\t\ ]
1917
>0 use algol_68
2018
0 regex/1024 \bFLEX[\t\ ]\*\\[

polyfile/magic_defs/amigaos

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#------------------------------------------------------------------------------
3-
# $File: amigaos,v 1.20 2021/09/20 00:42:19 christos Exp $
3+
# $File: amigaos,v 1.23 2026/02/05 18:49:06 christos Exp $
44
# amigaos: file(1) magic for AmigaOS binary formats:
55

66
#
@@ -36,7 +36,6 @@
3636
0 string COSO\0 Hippel-COSO Module sound file
3737
# Too simple (short, pure ASCII, deep), MPi
3838
#26 string V.3 Brian Postma's Soundmon Module sound file v3
39-
#26 string BPSM Brian Postma's Soundmon Module sound file v3
4039
#26 string V.2 Brian Postma's Soundmon Module sound file v2
4140

4241
# The following are from: "Stefan A. Haubenthal" <polluks@web.de>
@@ -195,8 +194,7 @@
195194
0 string LZX LZX compressed archive (Amiga)
196195

197196
# From: Przemek Kramarczyk <pkramarczyk@gmail.com>
198-
0 string .KEY AmigaDOS script
199-
0 string .key AmigaDOS script
197+
0 string/c .key AmigaDOS script
200198

201199
# AMOS Basic file formats
202200
# https://www.exotica.org.uk/wiki/AMOS_file_formats
@@ -216,3 +214,7 @@
216214
>12 regex .{8} \b, type %s
217215
0 string AmBs AMOS Basic memory banks
218216
>4 beshort x \b, %d banks
217+
218+
219+
# https://github.com/alb42/Leu/blob/master/TCDReaderUnit.pas
220+
3 string TURBOCALC TurboCalc spreadsheet

polyfile/magic_defs/android

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#------------------------------------------------------------
3-
# $File: android,v 1.24 2023/02/20 16:51:59 christos Exp $
3+
# $File: android,v 1.26 2024/09/04 19:06:11 christos Exp $
44
# Various android related magic entries
55
#------------------------------------------------------------
66

@@ -9,11 +9,11 @@
99
# Fixed to avoid regexec 17 errors on some dex files
1010
# From <diff@lookout.com> "Tim Strazzere"
1111
0 string dex\n
12-
>0 regex dex\n[0-9]{2}\0 Dalvik dex file
13-
>4 string >000 version %s
12+
>0 regex dex\n[0-9]{2} Dalvik dex file
13+
>>4 string >000 version %s
1414
0 string dey\n
15-
>0 regex dey\n[0-9]{2}\0 Dalvik dex file (optimized for host)
16-
>4 string >000 version %s
15+
>0 regex dey\n[0-9]{2} Dalvik dex file (optimized for host)
16+
>>4 string >000 version %s
1717

1818
# Android bootimg format
1919
# From https://android.googlesource.com/\
@@ -223,15 +223,15 @@
223223
# +/refs/heads/androidx-main/profileinstaller/profileinstaller/\
224224
# src/main/java/androidx/profileinstaller/ProfileVersion.java
225225
0 string pro\x00
226-
>0 regex pro\x000[0-9][0-9]\x00 Android ART profile
226+
>4 regex 0[0-9][0-9] Android ART profile
227227
!:ext prof
228228
>>4 string 001\x00 \b, version 001 N
229229
>>4 string 005\x00 \b, version 005 O
230230
>>4 string 009\x00 \b, version 009 O MR1
231231
>>4 string 010\x00 \b, version 010 P
232232
>>4 string 015\x00 \b, version 015 S
233233
0 string prm\x00
234-
>0 regex prm\x000[0-9][0-9]\x00 Android ART profile metadata
234+
>0 regex 0[0-9][0-9] Android ART profile metadata
235235
!:ext profm
236236
>>4 string 001\x00 \b, version 001 N
237237
>>4 string 002\x00 \b, version 002

polyfile/magic_defs/animation

Lines changed: 97 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
#------------------------------------------------------------------------------
3-
# $File: animation,v 1.93 2023/05/21 17:13:19 christos Exp $
3+
# $File: animation,v 1.101 2025/05/28 19:54:08 christos Exp $
44
# animation: file(1) magic for animation/movie formats
55
#
66
# animation formats
@@ -542,36 +542,39 @@
542542
>>2 byte&0xF0 !0xF0 MPEG ADTS, layer III, v1
543543
!:strength +20
544544
!:mime audio/mpeg
545-
>2 byte&0xF0 0x10 \b, 32 kbps
546-
>2 byte&0xF0 0x20 \b, 40 kbps
547-
>2 byte&0xF0 0x30 \b, 48 kbps
548-
>2 byte&0xF0 0x40 \b, 56 kbps
549-
>2 byte&0xF0 0x50 \b, 64 kbps
550-
>2 byte&0xF0 0x60 \b, 80 kbps
551-
>2 byte&0xF0 0x70 \b, 96 kbps
552-
>2 byte&0xF0 0x80 \b, 112 kbps
553-
>2 byte&0xF0 0x90 \b, 128 kbps
554-
>2 byte&0xF0 0xA0 \b, 160 kbps
555-
>2 byte&0xF0 0xB0 \b, 192 kbps
556-
>2 byte&0xF0 0xC0 \b, 224 kbps
557-
>2 byte&0xF0 0xD0 \b, 256 kbps
558-
>2 byte&0xF0 0xE0 \b, 320 kbps
545+
>>>2 search/100 Xing \b, variable bitrate
546+
>>>2 search/100 VBRI \b, variable bitrate
547+
>>>2 default x
548+
>>>>2 byte&0xF0 0x10 \b, 32 kbps
549+
>>>>2 byte&0xF0 0x20 \b, 40 kbps
550+
>>>>2 byte&0xF0 0x30 \b, 48 kbps
551+
>>>>2 byte&0xF0 0x40 \b, 56 kbps
552+
>>>>2 byte&0xF0 0x50 \b, 64 kbps
553+
>>>>2 byte&0xF0 0x60 \b, 80 kbps
554+
>>>>2 byte&0xF0 0x70 \b, 96 kbps
555+
>>>>2 byte&0xF0 0x80 \b, 112 kbps
556+
>>>>2 byte&0xF0 0x90 \b, 128 kbps
557+
>>>>2 byte&0xF0 0xA0 \b, 160 kbps
558+
>>>>2 byte&0xF0 0xB0 \b, 192 kbps
559+
>>>>2 byte&0xF0 0xC0 \b, 224 kbps
560+
>>>>2 byte&0xF0 0xD0 \b, 256 kbps
561+
>>>>2 byte&0xF0 0xE0 \b, 320 kbps
559562
# timing
560-
>2 byte&0x0C 0x00 \b, 44.1 kHz
561-
>2 byte&0x0C 0x04 \b, 48 kHz
562-
>2 byte&0x0C 0x08 \b, 32 kHz
563+
>>>2 byte&0x0C 0x00 \b, 44.1 kHz
564+
>>>2 byte&0x0C 0x04 \b, 48 kHz
565+
>>>2 byte&0x0C 0x08 \b, 32 kHz
563566
# channels/options
564-
>3 byte&0xC0 0x00 \b, Stereo
565-
>3 byte&0xC0 0x40 \b, JntStereo
566-
>3 byte&0xC0 0x80 \b, 2x Monaural
567-
>3 byte&0xC0 0xC0 \b, Monaural
568-
#>1 byte ^0x01 \b, Data Verify
569-
#>2 byte &0x02 \b, Packet Pad
570-
#>2 byte &0x01 \b, Custom Flag
571-
#>3 byte &0x08 \b, Copyrighted
572-
#>3 byte &0x04 \b, Original Source
573-
#>3 byte&0x03 1 \b, NR: 50/15 ms
574-
#>3 byte&0x03 3 \b, NR: CCIT J.17
567+
>>>3 byte&0xC0 0x00 \b, Stereo
568+
>>>3 byte&0xC0 0x40 \b, JntStereo
569+
>>>3 byte&0xC0 0x80 \b, 2x Monaural
570+
>>>3 byte&0xC0 0xC0 \b, Monaural
571+
#>>>1 byte ^0x01 \b, Data Verify
572+
#>>>2 byte &0x02 \b, Packet Pad
573+
#>>>2 byte &0x01 \b, Custom Flag
574+
#>>>3 byte &0x08 \b, Copyrighted
575+
#>>>3 byte &0x04 \b, Original Source
576+
#>>>3 byte&0x03 1 \b, NR: 50/15 ms
577+
#>>>3 byte&0x03 3 \b, NR: CCIT J.17
575578

576579
# MP2, M1A
577580
0 beshort&0xFFFE 0xFFFC MPEG ADTS, layer II, v1
@@ -855,7 +858,7 @@
855858
# Live MPEG-4 audio streams (instead of RTP FlexMux)
856859
0 beshort&0xFFE0 0x56E0 MPEG-4 LOAS
857860
!:mime audio/x-mp4a-latm
858-
#>1 beshort&0x1FFF x \b, %hu byte packet
861+
#>1 beshort&0x1FFF x \b, %u byte packet
859862
>3 byte&0xE0 0x40
860863
>>4 byte&0x3C 0x04 \b, single stream
861864
>>4 byte&0x3C 0x08 \b, 2 streams
@@ -927,24 +930,24 @@
927930
#
928931
# from Oskar Schirmer <schirmer@scara.com> Feb 3, 2001 (ISO 13818.1)
929932
# syncbyte 8 bit 0x47
930-
# error_ind 1 bit -
931-
# payload_start 1 bit 1
932-
# priority 1 bit -
933-
# PID 13 bit 0x0000
934-
# scrambling 2 bit -
935-
# adaptfld_ctrl 2 bit 1 or 3
936-
# conti_count 4 bit -
937-
0 belong&0xFF5FFF10 0x47400010
938-
>188 byte 0x47 MPEG transport stream data
933+
# 188 bytes per packet
934+
0 byte 0x47
935+
>188 byte 0x47
936+
>>376 byte 0x47
937+
>>>564 byte 0x47
938+
>>>>752 byte 0x47 MPEG transport stream data
939939
!:mime video/MP2T
940940
!:ext ts
941941

942942
# Blu-ray disc Audio-Video MPEG-2 transport stream
943943
# From: Alexandre Iooss <erdnaxe@crans.org>
944944
# URL: https://en.wikipedia.org/wiki/MPEG_transport_stream
945945
# Note: similar to ISO 13818.1 but with 4 extra bytes per packets
946-
4 belong&0xFF5FFF10 =0x47400010
947-
>196 byte =0x47 BDAV MPEG-2 Transport Stream (M2TS)
946+
4 byte 0x47
947+
>196 byte 0x47
948+
>>388 byte 0x47
949+
>>>580 byte 0x47
950+
>>>>772 byte 0x47 BDAV MPEG-2 Transport Stream (M2TS)
948951
!:mime video/MP2T
949952
!:ext m2ts/mts
950953

@@ -1195,3 +1198,56 @@
11951198
>30 lelong x \b, height: %d
11961199
>34 lelong x \b, %d bit
11971200
>38 lelong x \b, frames: %d
1201+
1202+
# https://wiki.multimedia.cx/index.php/Duck_IVF
1203+
0 string DKIF Duck IVF video file
1204+
!:mime video/x-ivf
1205+
>4 leshort >0 \b, version %d
1206+
>8 string x \b, codec %s
1207+
>12 leshort x \b, %d
1208+
>14 leshort x \bx%d
1209+
>24 lelong >0 \b, %d frames
1210+
1211+
1212+
# libplacebo cache file
1213+
# https://libplacebo.org
1214+
0 string pl_cache libplacebo cache
1215+
>8 ulelong x \b, version %u
1216+
>12 ulelong =0 \b, empty
1217+
>12 ulelong =1 \b, 1 entry
1218+
>12 ulelong >1 \b, %u entries
1219+
1220+
>4 byte 1 \b, version 3.00.00
1221+
>4 byte 2 \b, version 3.03.00
1222+
>4 byte 3 \b, version 4.00.00
1223+
>4 byte 4 \b, version 4.02.00
1224+
>4 byte 5 \b, version 5.00.00
1225+
1226+
# live2d: file(1) magic for Live2D Cubism file formats
1227+
# https://www.live2d.com/en/
1228+
0 string/4 MOC3 Live2D Cubism MOC3
1229+
>4 byte 0 \b, SDK version invalid/unknown (%d)
1230+
>4 byte 1 \b, SDK version 3.0.00 - 3.2.07 (%d)
1231+
>4 byte 2 \b, SDK version 3.3.00 - 3.3.03 (%d)
1232+
>4 byte 3 \b, SDK version 4.0.00 - 4.1.05 (%d)
1233+
>4 byte 4 \b, SDK version 4.2.00 - 4.2.02 (%d)
1234+
>4 byte 5 \b, SDK version 5.0.00 (%d)
1235+
>4 byte >5 \b, SDK version unknown (%d)
1236+
>5 byte 0 \b, little endian
1237+
>5 byte >0 \b, big endian
1238+
!:mime application/x-moc3-data
1239+
!:ext moc3
1240+
1241+
0 string/4 CAFF Live2D Cubism archive
1242+
>4 ubyte x version %d
1243+
>&0 ubyte x \b.%d
1244+
>&1 ubyte x \b.%d
1245+
>7 string/4 =---- \b, standard format
1246+
>7 string/4 !---- \b, unknown format (%.4s)
1247+
>11 ubyte x version %d
1248+
>&0 ubyte x \b.%d
1249+
>&1 ubyte x \b.%d
1250+
>14 belong =0 \b, no obfuscation
1251+
>14 belong !0 \b, XOR obfuscation key %d
1252+
!:mime application/x-cubism-archive
1253+
!:ext cmo3/can3

polyfile/magic_defs/apache

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11

22
#------------------------------------------------------------------------------
3-
# $File: apache,v 1.1 2017/04/11 14:52:15 christos Exp $
3+
# $File: apache,v 1.3 2025/05/30 13:25:13 christos Exp $
44
# apache: file(1) magic for Apache Big Data formats
55

66
# Avro files
7-
0 string Obj Apache Avro
8-
>3 byte x version %d
7+
0 string Obj\001 Apache Avro, version 1
98

109
# ORC files
1110
# Important information is in file footer, which we can't index to :(
1211
0 string ORC Apache ORC
1312

14-
# Parquet files
15-
0 string PAR1 Apache Parquet
13+
# Apache arrow file format
14+
# MIME: https://www.iana.org/assignments/media-types/application/vnd.apache.arrow.stream
15+
# Description: https://arrow.apache.org/docs/format/Columnar.html
16+
0 string ARROW1 Apache Arrow columnar file
17+
!:mime application/vnd.apache.arrow.file
18+
!:ext arrow/feather
19+
20+
# Apache parquet file format
21+
# MIME: https://www.iana.org/assignments/media-types/application/vnd.apache.parquet
22+
# Description: https://parquet.apache.org/docs/file-format/
23+
0 string PAR1 Apache Parquet file
24+
!:mime application/vnd.apache.parquet
25+
!:ext parquet
1626

1727
# Hive RC files
1828
0 string RCF Apache Hive RC file

0 commit comments

Comments
 (0)