A. Adding Yara Rules
- Get yara-connector working with the default rule first. (/etc/cb/integrations/cb-yara-connector/yara_rules/sample.yar)
- Only add a few rules at a time.
- Cut-n-paste can add extra characters and cause troubleshooting issues. If cut-n-paste, copy from a text editor.
- Validate they are working – Currently by reviewing the logs. Validate tool should be fixed in next release
- Review yara.readthedocs.io (see link below) for additional information.
B. Validating the Yara Rules
Note: The option ./yaraconnector --validate-yara-rules is currently broken. The fix is expected in the next release post version 2.2.0
1. Run:
yara <yar file name> <directory>
Example:
yara /tmp/sample.yar .
2. No output indicates the rule compiled without error. Any errors encountered may note the line number and error encountered. Example errors:
error: rule "sample" in /tmp/sample.yar(3): non-ascii character
error: rule "sample" in /tmp/sample.yar(3): syntax error, unexpected end of file
3. Yara syntax errors may also appear in the Yara Connector logs.
less /var/log/cb/integrations/cb-yara-connector/yaraconnector.log
4. To verify the compiled Yara rules are actually tagging binaries, run this search query in the Process Search page:
alliance_score_yara:*