32 lines
805 B
Python
32 lines
805 B
Python
class Match:
|
|
# store match data, whatever it is
|
|
def __init__(self, offset, length, data = {}):
|
|
self.offset = offset
|
|
self.length = length
|
|
self.data = data
|
|
|
|
def __repr__(self):
|
|
return f"offset:{hex(self.offset)} size:{hex(self.length)} data:{self.data}"
|
|
|
|
class SignatureMatcher:
|
|
__slot__ = ['name', 'signature', 'file', 'matches']
|
|
def __init__(self, file):
|
|
self.file = open(file, 'rb').read()
|
|
self.matches = []
|
|
|
|
# util function
|
|
def search(self):
|
|
i = 0
|
|
while True:
|
|
idx = self.file.find(self.signature, i)
|
|
if idx == -1:
|
|
break
|
|
i = idx + 1
|
|
yield idx
|
|
|
|
def is_valid(self):
|
|
return False
|
|
|
|
def view(self, match, root_folder=None):
|
|
pass
|