Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bug fix and added results for MP4 files. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
319 changes: 14 additions & 305 deletions src/pyfsig/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,6 @@ class FileSignatureDict(TypedDict):
"hex": [73, 68, 51],
"offset": 0,
},
{
"display_string": "BM",
"description": "BMP file, abitmap format used mostly in theWindows world",
"file_extension": "bmp",
"hex": [66, 77],
"offset": 0,
},
{
"display_string": "BM",
"description": "BMP file, abitmap format used mostly in the Windows world",
Expand Down Expand Up @@ -1153,303 +1146,19 @@ class FileSignatureDict(TypedDict):
"hex": [39, 5, 25, 86],
"offset": 0,
},
{
"display_string": "ftypisom",
"description": "ISO Base Media file (MPEG-4)",
"file_extension": "mp4",
"hex": [0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6f, 0x6d],
"offset": 4,
},
{
"display_string": "ftypMSNV",
"description": "MPEG-4 video file",
"file_extension": "mp4",
"hex": [0x66, 0x74, 0x79, 0x70, 0x4d, 0x53, 0x4e, 0x56],
"offset": 4,
}
]


# {
# "display_string": "FORM.... ILBM",
# "description": "IFFInterleaved Bitmap Image",
# "file_extension": "ilbm",
# "hex": "46 4F 52 4D nn nn nn nn 49 4C 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ILBM",
# "description": "IFFInterleaved Bitmap Image",
# "file_extension": "lbm",
# "hex": "46 4F 52 4D nn nn nn nn 49 4C 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ILBM",
# "description": "IFFInterleaved Bitmap Image",
# "file_extension": "ibm",
# "hex": "46 4F 52 4D nn nn nn nn 49 4C 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ILBM",
# "description": "IFFInterleaved Bitmap Image",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 49 4C 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... 8SVX",
# "description": "IFF8-Bit Sampled Voice",
# "file_extension": "8svx",
# "hex": "46 4F 52 4D nn nn nn nn 38 53 56 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... 8SVX",
# "description": "IFF8-Bit Sampled Voice",
# "file_extension": "8sv",
# "hex": "46 4F 52 4D nn nn nn nn 38 53 56 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... 8SVX",
# "description": "IFF8-Bit Sampled Voice",
# "file_extension": "svx",
# "hex": "46 4F 52 4D nn nn nn nn 38 53 56 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... 8SVX",
# "description": "IFF8-Bit Sampled Voice",
# "file_extension": "snd",
# "hex": "46 4F 52 4D nn nn nn nn 38 53 56 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... 8SVX",
# "description": "IFF8-Bit Sampled Voice",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 38 53 56 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ACBM",
# "description": "Amiga Contiguous Bitmap",
# "file_extension": "acbm",
# "hex": "46 4F 52 4D nn nn nn nn 41 43 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ACBM",
# "description": "Amiga Contiguous Bitmap",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 41 43 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ANBM",
# "description": "IFFAnimated Bitmap",
# "file_extension": "anbm",
# "hex": "46 4F 52 4D nn nn nn nn 41 4E 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ANBM",
# "description": "IFFAnimated Bitmap",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 41 4E 42 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ANIM",
# "description": "IFFCEL Animation",
# "file_extension": "anim",
# "hex": "46 4F 52 4D nn nn nn nn 41 4E 49 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... ANIM",
# "description": "IFFCEL Animation",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 41 4E 49 4D",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FAXX",
# "description": "IFFFacsimile Image",
# "file_extension": "faxx",
# "hex": "46 4F 52 4D nn nn nn nn 46 41 58 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FAXX",
# "description": "IFFFacsimile Image",
# "file_extension": "faxx",
# "hex": "46 4F 52 4D nn nn nn nn 46 41 58 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FAXX",
# "description": "IFFFacsimile Image",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 46 41 58 58",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FTXT",
# "description": "IFFFormatted Text",
# "file_extension": "ftxt",
# "hex": "46 4F 52 4D nn nn nn nn 46 54 58 54",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FTXT",
# "description": "IFFFormatted Text",
# "file_extension": "txt",
# "hex": "46 4F 52 4D nn nn nn nn 46 54 58 54",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FTXT",
# "description": "IFFFormatted Text",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 46 54 58 54",
# "offset": "any",
# },
# {
# "display_string": "FORM.... SMUS",
# "description": "IFFSimple Musical Score",
# "file_extension": "smus",
# "hex": "46 4F 52 4D nn nn nn nn 53 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... SMUS",
# "description": "IFFSimple Musical Score",
# "file_extension": "smu",
# "hex": "46 4F 52 4D nn nn nn nn 53 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... SMUS",
# "description": "IFFSimple Musical Score",
# "file_extension": "mus",
# "hex": "46 4F 52 4D nn nn nn nn 53 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... SMUS",
# "description": "IFFSimple Musical Score",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 53 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... CMUS",
# "description": "IFFMusical Score",
# "file_extension": "cmus",
# "hex": "46 4F 52 4D nn nn nn nn 43 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... CMUS",
# "description": "IFFMusical Score",
# "file_extension": "mus",
# "hex": "46 4F 52 4D nn nn nn nn 43 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... CMUS",
# "description": "IFFMusical Score",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 43 4D 55 53",
# "offset": "any",
# },
# {
# "display_string": "FORM.... YUVN",
# "description": "IFFYUV Image",
# "file_extension": "yuvn",
# "hex": "46 4F 52 4D nn nn nn nn 59 55 56 4E",
# "offset": "any",
# },
# {
# "display_string": "FORM.... YUVN",
# "description": "IFFYUV Image",
# "file_extension": "yuv",
# "hex": "46 4F 52 4D nn nn nn nn 59 55 56 4E",
# "offset": "any",
# },
# {
# "display_string": "FORM.... YUVN",
# "description": "IFFYUV Image",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 59 55 56 4E",
# "offset": "any",
# },
# {
# "display_string": "FORM.... FANT",
# "description": "AmigaFantavision Movie",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 46 41 4E 54",
# "offset": "any",
# },
# {
# "display_string": "FORM.... AIFF",
# "description": "Audio Interchange File Format",
# "file_extension": "aiff",
# "hex": "46 4F 52 4D nn nn nn nn 41 49 46 46",
# "offset": "any",
# },
# {
# "display_string": "FORM.... AIFF",
# "description": "Audio Interchange File Format",
# "file_extension": "aif",
# "hex": "46 4F 52 4D nn nn nn nn 41 49 46 46",
# "offset": "any",
# },
# {
# "display_string": "FORM.... AIFF",
# "description": "Audio Interchange File Format",
# "file_extension": "aifc",
# "hex": "46 4F 52 4D nn nn nn nn 41 49 46 46",
# "offset": "any",
# },
# {
# "display_string": "FORM.... AIFF",
# "description": "Audio Interchange File Format",
# "file_extension": "snd",
# "hex": "46 4F 52 4D nn nn nn nn 41 49 46 46",
# "offset": "any",
# },
# {
# "display_string": "FORM.... AIFF",
# "description": "Audio Interchange File Format",
# "file_extension": "iff",
# "hex": "46 4F 52 4D nn nn nn nn 41 49 46 46",
# "offset": "any",
# },

# {
# "display_string": "........",
# "description": "Mach-O binary (32-bit)",
# "file_extension": "",
# "hex": "FE ED FA CE",
# "offset": "0x1000",
# },

# {
# "display_string": "........",
# "description": "Mach-O binary (64-bit)",
# "file_extension": "",
# "hex": "FE ED FA CF",
# "offset": "0x1000",
# },

# {
# "display_string": "CD001",
# "description": "ISO9660 CD/DVD image file",
# "file_extension": "iso",
# "hex": "43 44 30 30 31",
# "offset": "0x8001",
# },
# {
# "display_string": "CD001",
# "description": "ISO9660 CD/DVD image file",
# "file_extension": "iso",
# "hex": "43 44 30 30 31",
# "offset": "0x8801",
# },
# {
# "display_string": "CD001",
# "description": "ISO9660 CD/DVD image file",
# "file_extension": "iso",
# "hex": "43 44 30 30 31",
# "offset": "0x9001",
# },
14 changes: 14 additions & 0 deletions src/tests/test_pyfsig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import hashlib
import json

import pyfsig

def test_redundant_file_signatures():
hmap = {}

for signature in pyfsig.SIGNATURES:
hash = hashlib.md5(json.dumps(signature).encode("utf-8")).hexdigest()
if hash in hmap:
print(f"Found two colliding hashes ({hash}):\n{hmap[hash]} &\n{signature}")
else:
hmap[hash] = signature


def test_known_file_header_matches():
file_header = bytearray([237, 171, 238, 219])
Expand Down Expand Up @@ -30,3 +43,4 @@ def test_empty_file_header_doesnt_match():
file_header = bytearray()
matches = pyfsig.find_matches_for_file_header(file_header)
assert not matches