2024-08-27 13:16:45 +07:00
|
|
|
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
|
2024-08-30 21:22:49 +07:00
|
|
|
|
2024-09-19 09:32:02 +07:00
|
|
|
def view(self, match, root_folder=None):
|
2024-08-30 21:22:49 +07:00
|
|
|
pass
|