Module magic_parser

Module magic_parser 

Source
Expand description

Parser for libmagic-style hierarchical magic signature rule files (Magdir).

Structs§

HierarchicalMagicRule
A parsed hierarchical libmagic rule with optional child rules.
StringFlags
String matching modifiers for string and search tests.

Enums§

IndirectOp
Binary operation applied to indirect offset dereferenced pointer before applying adjustment.
IndirectType
Data type dereferenced by an indirect offset.
MagicCond
Rule branching condition type.
MagicTest
Type and comparison test of a magic rule.
NumOp
Arithmetic operations applied to read numeric values before comparison/format.
Offset
Location in file payload to inspect.
PascalLengthSize
Pascal string length prefix specification.
RelOp
Relational comparison operator for tests.

Functions§

calculate_rule_strength
Calculates rule strength faithful to upstream apprentice_magic_strength_1.
decode_magic_escapes
Decodes escape sequences (e.g. \037\235, \x1f, \n, \r, \t, \ ) from libmagic strings.
parse_magic_content
Parses an entire libmagic file content into a list of hierarchical root rules.
parse_magic_content_with_templates
Parses an entire libmagic file content into hierarchical root rules and named templates.
parse_magic_line
Parses a single libmagic rule line into components.
parse_offset
Parses offset string into an Offset enum variant.