-
Notifications
You must be signed in to change notification settings - Fork 198
A set of rules for Linux ELFs #442
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
Conversation
|
PR for test file: mandiant/capa-testfiles#104 |
| - string: "%02X-%02X-%02X-%02X-%02X-%02X" | ||
| - and: | ||
| - match: read file | ||
| - string: /\/sys\/class\/net\/\S+\/address/ |
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.
yuck these paths are ugly.
i wonder if substring literals are common enough for us to introduce a new feature/format. perhaps something like:
substring: "/etc/passwd"string/substring: "/etc/passwd"string: "/etc/passwd"g
note: this specific path isn't the best example because its actually a regex patter, but you get the idea.
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.
Yes, I think there's room for improvement here since this comes up a lot and has caused confusion (e.g. #390 (comment)).
I like option 1 then option 2.
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.
It may look ugly because it needs a wildcard for the name of the network adapter. For example /sys/class/net/lo/address, /sys/class/net/docker0/address.
| - Practical Malware Analysis Lab 01-04.exe_:0x4011FC | ||
| # ntdll | ||
| - 563653399B82CD443F120ECEFF836EA3678D4CF11D9B351BB737573C2D856299:0x1400025C4 | ||
| features: |
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.
this file is getting a bit unruly. the logic tree is so deep that its tricky to interpret as a human.
we should probably split this file into "write file on POSIX" and "write file on Windows".
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.
very cool, thanks for getting capa kickstarted for Linux/ELF support!
| @@ -0,0 +1,17 @@ | |||
| rule: | |||
| meta: | |||
| name: create unix reverse shell | |||
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.
we should document unix vs. linux and the preferred terms to use
I suspect the naming here comes from the ATT&CK name
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.
Yes the name is from ATT&CK. Also this is a higher level rule that depends on a few lower level rules that can be OS dependent.
| @@ -0,0 +1,16 @@ | |||
| rule: | |||
| meta: | |||
| name: get current user | |||
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.
Windows rule for this: get session user name
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.
Linux doesn't use the term session username. This checks for queries via the effective user id and extracting the user's info from "passwd" or the username of the user that started the process.
| - string: "%02X-%02X-%02X-%02X-%02X-%02X" | ||
| - and: | ||
| - match: read file | ||
| - string: /\/sys\/class\/net\/\S+\/address/ |
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.
Yes, I think there's room for improvement here since this comes up a lot and has caused confusion (e.g. #390 (comment)).
I like option 1 then option 2.
|
I'd like to propose the following conventions for naming rules:
let me know what you all think. the goal isn't to be annoying or add overhead - just to strive for consistency when it makes sense. once we reach a consensus, i'll update the rule documentation with these suggestions. |
|
im going to take a stab at mandiant/capa#737 (substring feature) because it will improve a bunch of these rules. then i'll propose some changes to this PR and we'll get this merged in. i have no major concerns with the logic in these rules - just some tweaks to naming, splitting up a couple rules, and making use of |
|
I'm on board with the OS conventions! Thanks for handling the substring and the updates here! |
|
i'm going to merge this and then open a new PR with proposed changes for os, substring, etc. @TcM1911 i'll tag you to review along with the rest of the crew |
This PR is for some Linux rules as part of mandiant/capa#699.
Example analysis: