A program to find regex patterns in binary files.
This solution includes:
- My own binary regex pattern and binary regex matcher
- A
Main.py
file for handling tthe program - A utilities file
The RegEx are binary and in Hexadecimal, this means that characters come in groups of two.
For Example: Unlike in normal RegEx, in the pattern "AA+" the "+" character relates to the preceding "AA".
All Regex expressions passed as arguments to the program must be in that format.
XX?
-XX
doesn't have tto appear, butt can appear onceXX*
- Matches at least 0 repetitions ofXX
XX+
- Matches at least 1 repetition ofXX
XX{a}
- Matches exactlya
occurrences ofXX
XX{a,b}
- Matches betweena
andb
occurrences ofXX
.
- Matches any byte[]
- Capture group[XXYY]
- next byte can be eitherXX
orYY
[XX-YY]
- next byte can be antything betweenXX
andYY
[ZZXX-YY]
- next byte can be antything betweenXX
andYY
, or it can beZZ
[^XX]
- negated set, acceptts all possible values but those in the set (here every byte butXX
will be acceptted)
()
- Sub-pattern, a nestted regex patttern. Modifiers after this pattern relate to the entire sub-pattern.
The output format is a list of objects.
Each object represents one occurence of a regular expression in the format:
{
"length": "int",
"name": "string",
"indices": {
"start": "int",
"end": "int"
}
}