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

verbose: show process name and other human-level details #1825

Merged
merged 19 commits into from
Nov 14, 2023

Conversation

williballenthin
Copy link
Collaborator

@williballenthin williballenthin commented Oct 20, 2023

closes #1816

major parts:

  • add DynamicFeatureExtractor.get_process_name() and DynamicFeatureExtractor.get_call_name()
  • update DynamicLayout (result document and proto) to record processes/threads/calls used during matching.
  • update verbose and vverbose renderers to show human readable process name and API call trace entry:

image

image

Checklist

  • No CHANGELOG update needed
  • No new tests needed
  • No documentation update needed

@williballenthin williballenthin added enhancement New feature or request dynamic related to dynamic analysis flavor labels Oct 20, 2023
@williballenthin williballenthin added this to the v7.0 milestone Oct 20, 2023
@williballenthin williballenthin marked this pull request as ready for review October 20, 2023 14:24
@williballenthin

This comment was marked as outdated.

@williballenthin
Copy link
Collaborator Author

williballenthin commented Oct 20, 2023

the lines are getting to be pretty long, so interested to hear what you all think of the example above.

it might be possible to render this:

0000A65749F5902C4D82.exe[3052:2792][828] NtDuplicateObject(SourceProcessHandle=0xffffffff, SourceHandle=0xfffffffe, TargetProcessHandle=0xffffffff, TargetHandle=0x274, Options=0x2) -> 0x0, and 3 more...

as this:

0000A65749F5902C4D82.exe[3052:2792][828] 
  NtDuplicateObject(
    SourceProcessHandle=0xffffffff, 
    SourceHandle=0xfffffffe, 
    TargetProcessHandle=0xffffffff, 
    TargetHandle=0x274, 
    Options=0x2
  ) -> 0x0, and 3 more...

at the expense of more vertical real estate

Copy link
Collaborator

@mr-tz mr-tz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really cool, some things to discuss inline

for later potentially: would be really cool to highlight the match part in the rendered call line (not worth the effort right now!)

capa/render/vverbose.py Outdated Show resolved Hide resolved
capa/render/vverbose.py Outdated Show resolved Hide resolved
capa/render/vverbose.py Outdated Show resolved Hide resolved
capa/render/vverbose.py Outdated Show resolved Hide resolved
capa/render/vverbose.py Outdated Show resolved Hide resolved
capa/render/vverbose.py Outdated Show resolved Hide resolved
@williballenthin
Copy link
Collaborator Author

image

putting args on their own line makes the output much more readable (imho) but also makes the output really long. keeping the full call information on a single line is harder to read (imho):

Screenshot 2023-10-20 4 23 11 PM

@williballenthin
Copy link
Collaborator Author

i find myself often wanting to see the full details of each matching call so that i can extract indicators. for example, seeing all the CreateFile calls to extract the filename parameter. but we only show a single example to prove the rule matched correctly. i think this suggests that maybe we want to explore how to use capa/dynamic to extract indicators, not just behaviors.

@williballenthin
Copy link
Collaborator Author

would be really cool to highlight the match part in the rendered call line

this is probably possible, though it requires us to record the full tuple (func name, [arguments], return value) for each call, rather than a single rendered string. and, handle things like human readable vs raw value of arguments. im hesitant to try to define these structures today, since we've only looked at CAPE and the data it provides. i think we should integrate another sandbox before we attempt to find the right abstraction.

@williballenthin
Copy link
Collaborator Author

image

API call rendered on its own lines, indented to help highlight the function name and differentiate the arguments. the whole block is muted (grey) so the rule logic can remain the focus of attention.

i dont really like the duplication of the event at the rule root and each of the features, but i haven't brainstormed on a better policy yet.

@williballenthin
Copy link
Collaborator Author

when in dynamic flavor and in call scope, only render the call at the top level of the rule output, and don't repeat it for each matching feature (which is necessarily a call-scope feature):

image

@williballenthin williballenthin requested a review from mr-tz November 6, 2023 10:41
Copy link
Collaborator

@mr-tz mr-tz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think we can fine tune this down the road, if needed. Thanks!

capa/main.py Outdated Show resolved Hide resolved
@williballenthin

This comment was marked as resolved.

Copy link
Collaborator

@yelhamer yelhamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@mr-tz

This comment was marked as resolved.

@williballenthin williballenthin merged commit a705bf9 into dynamic-feature-extraction Nov 14, 2023
13 checks passed
@williballenthin williballenthin deleted the fix/issue-1816 branch November 14, 2023 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dynamic related to dynamic analysis flavor enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants