fix NitrogenLoader YARA#3003
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the NitrogenLoader YARA rule by adding a check for the PE file header (0x5a4d) to the condition. Feedback was provided to move this header check to the beginning of the condition to optimize performance through short-circuiting.
Comment on lines
+34
to
+35
| ((2 of ($string*) and any of ($syscall*)) or 4 of ($decrypt*) or ((3 of ($taskman_*) or 3 of ($installers*)) and all of ($rc4decrypt_*))) | ||
| and uint16(0) == 0x5a4d |
Contributor
There was a problem hiding this comment.
For better performance, it is recommended to place the file header check (uint16(0) == 0x5a4d) at the beginning of the condition. This allows YARA to short-circuit the evaluation for non-PE files immediately, avoiding unnecessary processing of the more complex string and pattern matching logic.
uint16(0) == 0x5a4d and
((2 of ($string*) and any of ($syscall*)) or 4 of ($decrypt*) or ((3 of ($taskman_*) or 3 of ($installers*)) and all of ($rc4decrypt_*)))
Owner
|
Thank you |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rule matches on the ELF binary /usr/bin/git-remote-keybase (151e6dfdaa05c93e9c36e3e6dd015e9b8dc786ae9a88a373be9f1a04e3db7a20) so I added a
uint16(0) == 0x5a4dto limit it to PE.matched strings were:
It probably has more false positives on PE files if it hits on a ELF, you might want to check it out.