Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add decorator @Extractor.rule for specific rules #6

Closed
ITAYC0HEN opened this issue Jun 18, 2020 · 0 comments · Fixed by #24
Closed

Add decorator @Extractor.rule for specific rules #6

ITAYC0HEN opened this issue Jun 18, 2020 · 0 comments · Fixed by #24

Comments

@ITAYC0HEN
Copy link
Contributor

Description
I believe it will be great to have something like @Extractor.rule that will have a function name that matches one of the items in yara_rules = [...] and will only trigger per this rule.

class Evil(Extractor):
    yara_rules = ["trojan_cn_evil", "test_evil_v3"]
    family = "evil"
    ...    
    @Extractor.rule
    def trojan_cn_evil(self, p, matches):
        ...
    @Extractor.rule
    def test_evil_v3(self, p, matches):
        ...

Most likely, the call to this decorator should happen after the calls to specific strings in @Extractor.extractor.

I'd like the @Extractor.rule decorator to receive a matches argument of type YaraMatches (or similar) that will provide access to the following info

[
    {
        name: "matched_str_1",
        offset: 0x123456
        content: b"Hello World!\x00\x148"
    },
    {
        name: "matched_str_1",
        offset: 0x4346
        content: b"Hello World!\x06\x07\x148"
    },
    {
        name: "other_str",
        offset: 0x876
        content: b"\xe8\x02\x75\x07\x81\x04\x24\x00\x01\x00\x00\x50\xe8"
    },
    ...
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant