mandiant / capa-rules

Standard collection of rules for capa: the tool for enumerating the capabilities of programs
https://github.com/mandiant/capa/
Apache License 2.0
517 stars 157 forks source link

Create rule writing step-by-step guide #307

Open mr-tz opened 3 years ago

mr-tz commented 3 years ago

Motivation

We should make it more straight-forward to get started writing rules using a step-by-step guide. This guide should go into the doc or the CONTRIBUTING file and be easily accessible.

I'm collecting some initial ideas here. It's really rough for now, but I wanted to get this going.

Content

Most importantly, rule writing should be easy and fun! Even if you can't work on the rule yourself, please submit the rule idea in a GitHub issue.

Prerequisites

Using the capa-explorer IDA Pro plugin

Writing a rule in your favorite text editor

Linting/testing rules

TODOs

johnk3r commented 3 years ago

One difficulty I had initially was to use the binary "capafmt.py".

I cloned the repository on Ubuntu. When executing the binary, he informed that he was unable to import the "capa.rules".

It took me a while to understand what was going on. So I think it is important to document how to use these background tools.

mr-tz commented 3 years ago

Thanks, that's really valuable feedback. We'll document this better to make it easier for everyone.

johnk3r commented 3 years ago

Also, it is important to exemplify how to submit good samples to @capa-testfiles

Example: A good sample should be processed in 60 seconds.

There were cases where it took me a while to find a sample to validate the rule, but it was not a good sample to be referenced in the rule.

recvfrom commented 3 years ago

Another awesome topic would be how to debug rules that aren't matching as expected - specifically using show-features.py

mr-tz commented 3 years ago

Another awesome topic would be how to debug rules that aren't matching as expected - specifically using show-features.py

Exactly, I just went through it and encountered a case where IDA (lods) and vivisect (lodsb) use different instruction mnemonics. We should document how to do this and common gotchas like this (I've seen similar cases before).

Dextera0007 commented 1 year ago

Learning capa rules, objective is to analyze various packets using capa rules: PE, ELF and .net files any help you can provide would be greatly appreciated. Here are the errors below when attempting to run a PE files :

capa -s capa-master\sigs -r capa-rules-master file.exe error:capta: Input file does not appear to be a PE file or ELF file error:capa: capa currently only supports analyzing PE and ELF files (or shellcode, when using --fomrat sc32|sc64