-
Notifications
You must be signed in to change notification settings - Fork 163
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
Create self-delete-using-alternate-data-streams.yml #895
Conversation
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.
nice, this may be a bit detailed and specific to the example compilation. can we relax the counts and instructions or do you think those are already focused on the core?
It's a good question, I would lean towards those as being part of the core. FWIW, the rule also triggers on the x86/x64 PoC compiled versions. I am happy to adjust it though, I was mainly trying to make sure it wouldn't generate FP's as well. |
- and: | ||
- instruction: | ||
- mnemonic: lea | ||
- offset: -0x1D |
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.
can you add a description detailing this offset value?
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.
Yeh, for sure. Feel free to adjust it as well.
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.
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.
FileRenameInfo = 3
and FileDispositionInfo = 4
are already covered, so that should be fine
Gotcha, it's definitely better to avoid FPs. |
What do you think of this simplification? features:
- and:
- count(api(kernel32.SetFileInformationByHandle)): 2
- basic block:
- and:
- api: kernel32.SetFileInformationByHandle
- optional:
- number: 3 = FileRenameInfo
- basic block:
- and:
- api: kernel32.SetFileInformationByHandle
- number: 4 = FileDispositionInfo
- number: 1 = TRUE // fDelete.DeleteFile = TRUE;
- and:
- count(api(kernel32.CreateFile)): 2
- number: 0x10000 = DELETE
|
Yeh, that's much better and cleaner. Thanks for the recommendation, I will adjust and send it back. Thanks! |
- basic block: | ||
- and: | ||
- api: kernel32.SetFileInformationByHandle | ||
- optional: | ||
- number: 3 = FileRenameInfo | ||
- basic block: | ||
- and: | ||
- api: kernel32.SetFileInformationByHandle | ||
- number: 4 = FileDispositionInfo | ||
- number: 1 = TRUE // fDelete.DeleteFile = TRUE; |
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.
last thing while we're at it, let's add an or block each and add a call subscope so this works in the dynamic flavor
so, e.g.:
- or:
- basic block:
- and:
- api: kernel32.SetFileInformationByHandle
- optional:
- number: 3 = FileRenameInfo
- call:
- and:
- api: SetFileInformationByHandle
- number: 3 = FileRenameInfo
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.
Ok, thanks. I tried to implement this, let me know if I missed something.
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.
fantastic, thank you very much!
thanks @dstepanic! |
Reference: #894
Test data: mandiant/capa-testfiles#231
Adding capa rule for self-deletion technique. I tried to capture the main behaviors in the rule across two implementations. I am open for suggestions or improvements to the rule. Thanks in advance!