mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-11 04:07:39 +02:00
Just tidy up the multistring searchers slightly.
This commit is contained in:
@@ -21,3 +21,9 @@ class MultiRegexp(object):
|
||||
raise TypeError("Search haystack must be a byte string")
|
||||
for match in re.finditer(self._regex, haystack):
|
||||
yield (match.start(0), match.group())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import multistring_testrig
|
||||
|
||||
multistring_testrig.tester(MultiRegexp())
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
def tester(searcher):
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(usage = "Searches through a haystack for a set of needles")
|
||||
parser.add_argument("-n", "--needles", help = "The filename of the file containing newline separated needles",
|
||||
required = True)
|
||||
parser.add_argument("haystack", help = "The filename of the binary haystack file to search")
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.needles, "rb") as needles_fp:
|
||||
needles = needles_fp.read().split(b"\n")
|
||||
with open(args.haystack, "rb") as haystack_fp:
|
||||
haystack = haystack_fp.read()
|
||||
for needle in needles:
|
||||
if len(needle):
|
||||
searcher.add_pattern(needle)
|
||||
searcher.preprocess()
|
||||
for result in searcher.search(haystack):
|
||||
print("0x{:x} - {}".format(*result))
|
||||
@@ -72,22 +72,6 @@ class WuManber(object):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
import multistring_testrig
|
||||
|
||||
parser = argparse.ArgumentParser(usage = "Searches through a haystack for a set of needles")
|
||||
parser.add_argument("-n", "--needles", help = "The filename of the file containing newline separated needles",
|
||||
required = True)
|
||||
parser.add_argument("haystack", help = "The filename of the binary haystack file to search")
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.needles, "rb") as needles_fp:
|
||||
needles = needles_fp.read().split(b"\n")
|
||||
with open(args.haystack, "rb") as haystack_fp:
|
||||
haystack = haystack_fp.read()
|
||||
wm = WuManber()
|
||||
for needle in needles:
|
||||
if len(needle):
|
||||
wm.add_pattern(needle)
|
||||
wm.preprocess()
|
||||
for result in wm.search(haystack):
|
||||
print("0x{:x} - {}".format(*result))
|
||||
multistring_testrig.tester(WuManber())
|
||||
|
||||
Reference in New Issue
Block a user