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

New Analyzer: Fireeye Capa (WIP) #822

Closed
weslambert opened this issue Jul 22, 2020 · 26 comments
Closed

New Analyzer: Fireeye Capa (WIP) #822

weslambert opened this issue Jul 22, 2020 · 26 comments
Labels
category:feature-request Issue is related to a feature request category:new-analyzer New analyzer submitted
Milestone

Comments

@weslambert
Copy link
Contributor

I've started working on an analyzer for capa from Fireeye. Will submit PR soon.

From https://github.com/fireeye/capa:

capa detects capabilities in executable files. You run it against a PE file or shellcode and it tells you what it thinks the program can do. For example, it might suggest that the file is a backdoor, is capable of installing services, or relies on HTTP to communicate.

@weslambert weslambert added the category:feature-request Issue is related to a feature request label Jul 22, 2020
@dadokkio
Copy link
Contributor

We tested it this week.. it's actually missing a safe/malicious indicator that is necessary for the taxonomy that was available in the past but is broken right now..

@dadokkio dadokkio added the category:new-analyzer New analyzer submitted label Jul 23, 2020
@weslambert
Copy link
Contributor Author

Ah, I see -- should close I this out then?

@dadokkio
Copy link
Contributor

we can keep this open and start to code. Even without safe/malicious this have a lot of interesting information imho.

@weslambert
Copy link
Contributor Author

Agreed. Sounds good! 👍

@weslambert
Copy link
Contributor Author

@dadokkio Thoughts on this?

mandiant/capa#50

Assuming we should wait until it's fully supported for Python 3?

@dadokkio
Copy link
Contributor

That's bad, unfortunately at the moment we tested only the executable on windows and the python3 port seems will take a lot of time.
A possibility is to run the linux executable with subprocess until the library will be update and then parse the tabular output, I've just tested it locally and it works fine.
Let me know if you need any help.

@dadokkio
Copy link
Contributor

I've created a little executable output parser here https://gist.github.com/dadokkio/32f0791f3572122ef3d7924ab315babb if you want to use it as example.

The output is something like:

{'ATT&CK Tactic_ATT&CK Technique': [{'ATT&CK Tactic': 'DEFENSE EVASION',
                                     'ATT&CK Technique': 'Process Injection '
                                                         '[T1055]'},
                                    {'ATT&CK Tactic': 'DEFENSE EVASION',
                                     'ATT&CK Technique': 'Virtualization/Sandbox '
                                                         'Evasion::System '
                                                         'Checks [T1497.001]'},
                                    {'ATT&CK Tactic': 'DISCOVERY',
                                     'ATT&CK Technique': 'Application Window '
                                                         'Discovery [T1010]'},
                                    {'ATT&CK Tactic': 'DISCOVERY',
                                     'ATT&CK Technique': 'Process Discovery '
                                                         '[T1057]'},
                                    {'ATT&CK Tactic': 'DISCOVERY',
                                     'ATT&CK Technique': 'Query Registry '
                                                         '[T1012]'},
                                    {'ATT&CK Tactic': 'DISCOVERY',
                                     'ATT&CK Technique': 'System Information '
                                                         'Discovery [T1082]'},
                                    {'ATT&CK Tactic': 'DISCOVERY',
                                     'ATT&CK Technique': 'System Network '
                                                         'Configuration '
                                                         'Discovery [T1016]'},
                                    {'ATT&CK Tactic': 'DISCOVERY',
                                     'ATT&CK Technique': 'System Owner/User '
                                                         'Discovery [T1033]'},
                                    {'ATT&CK Tactic': 'EXECUTION',
                                     'ATT&CK Technique': 'Shared Modules '
                                                         '[T1129]'}],
 'CAPABILITY_NAMESPACE': [{'CAPABILITY': 'check for OutputDebugString error',
                           'NAMESPACE': 'anti-analysis/anti-debugging/debugger-detection'},
                          {'CAPABILITY': 'check for time delay via '
                                         'GetTickCount',
                           'NAMESPACE': 'anti-analysis/anti-debugging/debugger-detection'},
                          {'CAPABILITY': 'execute anti-debugging instructions '
                                         '(2 matches)',
                           'NAMESPACE': 'anti-analysis/anti-debugging/debugger-detection'},
                          {'CAPABILITY': 'execute anti-VM instructions (8 '
                                         'matches)',
                           'NAMESPACE': 'anti-analysis/anti-vm/vm-detection'},
                          {'CAPABILITY': 'reference anti-VM strings',
                           'NAMESPACE': 'anti-analysis/anti-vm/vm-detection'},
                          {'CAPABILITY': 'contain a resource (.rsrc) section',
                           'NAMESPACE': 'executable/pe/section/rsrc'},
                          {'CAPABILITY': 'contain a thread local storage '
                                         '(.tls) section',
                           'NAMESPACE': 'executable/pe/section/tls'},
                          {'CAPABILITY': 'interact with driver via control '
                                         'codes',
                           'NAMESPACE': 'host-interaction/driver'},
                          {'CAPABILITY': 'write file',
                           'NAMESPACE': 'host-interaction/file-system/write'},
                          {'CAPABILITY': 'find graphical window',
                           'NAMESPACE': 'host-interaction/gui/window/find'},
                          {'CAPABILITY': 'get memory capacity',
                           'NAMESPACE': 'host-interaction/hardware/memory'},
                          {'CAPABILITY': 'get disk information (2 matches)',
                           'NAMESPACE': 'host-interaction/hardware/storage'},
                          {'CAPABILITY': 'print debug messages',
                           'NAMESPACE': 'host-interaction/log/debug/write-event'},
                          {'CAPABILITY': 'get local IPv4 addresses (2 matches)',
                           'NAMESPACE': 'host-interaction/network/address'},
                          {'CAPABILITY': 'resolve DNS',
                           'NAMESPACE': 'host-interaction/network/dns/resolve'},
                          {'CAPABILITY': 'get system information',
                           'NAMESPACE': 'host-interaction/os/info'},
                          {'CAPABILITY': 'get OS version',
                           'NAMESPACE': 'host-interaction/os/version'},
                          {'CAPABILITY': 'allocate RWX memory',
                           'NAMESPACE': 'host-interaction/process/inject'},
                          {'CAPABILITY': 'enumerate processes',
                           'NAMESPACE': 'host-interaction/process/list'},
                          {'CAPABILITY': 'terminate process',
                           'NAMESPACE': 'host-interaction/process/terminate'},
                          {'CAPABILITY': 'open registry key (2 matches)',
                           'NAMESPACE': 'host-interaction/registry/open'},
                          {'CAPABILITY': 'query registry entry',
                           'NAMESPACE': 'host-interaction/registry/query'},
                          {'CAPABILITY': 'query registry value',
                           'NAMESPACE': 'host-interaction/registry/query'},
                          {'CAPABILITY': 'get session user name',
                           'NAMESPACE': 'host-interaction/session'},
                          {'CAPABILITY': 'link function at runtime (7 matches)',
                           'NAMESPACE': 'linking/runtime-linking'}],
 'md5': '9159edb64c4a21d8888d088bf2db23f3',
 'path': 'pafish.exe'}

@weslambert
Copy link
Contributor Author

Awesome, thanks! I've thought about using an executable with another analyzer before, but wasn't sure if that would be acceptable. So, it would just be run from the analyzer directory (unless Dockerized) correct?

@dadokkio
Copy link
Contributor

yes, it should be available on the docker image of the analyzer (maybe the path could be a settings)
if you search for subprocess you should find other tools that runs in this way.

@williballenthin
Copy link

for the time being, we would (unfortunately) suggest that you run capa as a subprocess.

however, you should also consider using the -j command line option that emits a standardized json format. this is the document that drives all the output, so you should find everything you need in there. we consider this document format part of our public API, so you can rely on it not changing unless we bump the major version of capa.

@williballenthin
Copy link

if you want to sketch out integration with py3, then you can play with the branch in mandiant/capa#234. however, we don't consider it supported yet, so i can't guarantee things won't change. should get you most of the way there.

please reach out if i can assist at all - would definitely like to help capa be used more widely.

@weslambert
Copy link
Contributor Author

Thanks @williballenthin !

@weslambert
Copy link
Contributor Author

Currently running into an issue w/ permissions and the file creation associated with the following: mandiant/capa#244

@weslambert
Copy link
Contributor Author

Should be fixed very soon upstream, at which point, I'll finish the implementation of this analyzer.

@weslambert
Copy link
Contributor Author

1.3.0 was released today. Continuing to test/develop.

@weslambert
Copy link
Contributor Author

@dadokkio what do you think of something like the following?

(Tactic -> Technique -> Capability -> Metadata (rule, examples))

image

@weslambert
Copy link
Contributor Author

weslambert commented Sep 23, 2020

@dadokkio , this is almost ready to PR, but was just curious about the best approach for including the Capa binary. I haven't contributed a Docker-based analyzer/responder yet, so any guidance would be appreciated there. Also need to finish up TheHive templates.

@dadokkio
Copy link
Contributor

Probably @To-om has better answers.
I think the option are: include the binary with your python code or add a Dockerfile that downloads the executables.

@weslambert
Copy link
Contributor Author

This should be wrapped up very soon. Apologies for the delay.

@Passimist
Copy link

Hi @weslambert how is the development of this analyzer going? Do you need help with anything? I was thinking of developing one for cortex and found out its already beeing worked on here.

@m5050
Copy link

m5050 commented Jul 25, 2021

me too was looking for capa analyzer since the new capa version just released. Would like to hear any update about the analyzer development status @weslambert

@weslambert
Copy link
Contributor Author

@Passimist @m5050 This has been in my backlog, but given the interest, I'll see if I can re-test and get it wrapped up by the end of this week.

@Passimist
Copy link

hi @weslambert, thanks for the reply! Will the analyzer use the new python 3 version of capa? Let me know if I can help you with this project.

@weslambert
Copy link
Contributor Author

@Passimist Correct, it is using the Python 3 version. I believe I just needed to adjust the format of the results/template(s) to get it finished up.

@weslambert
Copy link
Contributor Author

PR: #1027

@weslambert
Copy link
Contributor Author

Example templated report:

image

@nusantara-self nusantara-self added this to the 3.3.8 milestone Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:feature-request Issue is related to a feature request category:new-analyzer New analyzer submitted
Projects
None yet
Development

No branches or pull requests

6 participants