-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix yara recursion bug #40. Allow FileObject to accept bytearrays.
- Loading branch information
Showing
12 changed files
with
196 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Parsers for test_yara_runner_sibling_dispatch | ||
""" | ||
|
||
from mwcp import Parser, FileObject | ||
|
||
|
||
class Parent(Parser): | ||
DESCRIPTION = "Parent" | ||
|
||
@classmethod | ||
def identify(cls, file_object): | ||
return b"parent" in file_object.data | ||
|
||
def run(self): | ||
self.dispatcher.add(FileObject(b"sibling 1")) | ||
self.dispatcher.add(FileObject(b"sibling 2")) | ||
|
||
|
||
class Sibling1(Parser): | ||
DESCRIPTION = "Sibling 1" | ||
|
||
@classmethod | ||
def identify(cls, file_object): | ||
return b"sibling 1" in file_object.data | ||
|
||
|
||
class Sibling2(Parser): | ||
DESCRIPTION = "Sibling 2" | ||
|
||
@classmethod | ||
def identify(cls, file_object): | ||
return b"sibling 2" in file_object.data | ||
|
||
def run(self): | ||
# Testing corner case where we dispatch a file that is a parent of an already processed sibling. | ||
sibling = self.file_object.siblings[0] | ||
assert sibling.description == "Sibling 1" # sanity check | ||
self.dispatcher.add(FileObject(b"grandchild"), parent=sibling) | ||
|
||
|
||
class Grandchild(Parser): | ||
DESCRIPTION = "Grandchild" | ||
|
||
@classmethod | ||
def identify(cls, file_object): | ||
return b"grandchild" in file_object.data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Rules for test_yara_runner_sibling_dispatch | ||
*/ | ||
|
||
rule Parent { | ||
meta: | ||
mwcp = "SiblingDispatch.Parent" | ||
strings: | ||
$str = "parent" | ||
condition: | ||
all of them | ||
} | ||
|
||
|
||
rule Sibling1 { | ||
meta: | ||
mwcp = "SiblingDispatch.Sibling1" | ||
strings: | ||
$str = "sibling 1" | ||
condition: | ||
all of them | ||
} | ||
|
||
|
||
rule Sibling2 { | ||
meta: | ||
mwcp = "SiblingDispatch.Sibling2" | ||
strings: | ||
$str = "sibling 2" | ||
condition: | ||
all of them | ||
} | ||
|
||
|
||
rule Grandchild { | ||
meta: | ||
mwcp = "SiblingDispatch.Grandchild" | ||
strings: | ||
$str = "grandchild" | ||
condition: | ||
all of them | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f895279
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Majikx0