-
-
Save stvemillertime/4fe615f9979c9403eb9fdea8daeaf18e to your computer and use it in GitHub Desktop.
Yara rule to find a string near to other strings
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
import "math" | |
rule example { | |
meta: | |
author = "David Cannings" | |
description = "Rule example - finding a chunk of code near other known code" | |
strings: | |
$chunk = { AA BB CC DD } | |
$chunk_prologue = { 11 22 33 44 } | |
$chunk_epilogue = { FF EE DD CC } | |
condition: | |
for 5 i in (1..math.min(#chunk, 50)) : ( | |
for any j in (1..math.min(#chunk_prologue, 50)) : ( | |
@chunk[i] > @chunk_prologue[j] and | |
@chunk[i] - @chunk_prologue[j] < 20 and | |
@chunk[i] - @chunk_prologue[j] > 0 and | |
) | |
and | |
for any k in (1..math.min(#chunk_epilogue, 50)) : ( | |
@chunk[i] < @chunk_epilogue[k] and | |
@chunk_epilogue[k] - @chunk[i] < 20 and | |
@chunk_epilogue[k] - @chunk[i] > 0 | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment