Skip to content

Instantly share code, notes, and snippets.

@0xbc
Created February 21, 2019 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xbc/55e9e19e9bf1c61c7cf843744ff0a6a4 to your computer and use it in GitHub Desktop.
Save 0xbc/55e9e19e9bf1c61c7cf843744ff0a6a4 to your computer and use it in GitHub Desktop.
#include "libyara/include/yara.h"
int main()
{
YR_RULES* rules;
YR_RULE* rule;
YR_STRING* string;
YR_META* meta;
const char* tag;
int result;
yr_initialize();
result = yr_rules_load("rules.yara", &rules);
yr_rules_foreach(rules, rule){
printf("Rule: %s\n-----------\n", rule->identifier);
yr_rule_tags_foreach(rule, tag) {
printf("tag = %s\n", tag);
}
yr_rule_metas_foreach(rule, meta) {
printf("%s = %s\n", meta->identifier, meta->string);
}
yr_rule_strings_foreach(rule, string) {
printf("%s = %s\n", string->identifier, string->string);
}
}
yr_finalize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment