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

Modify rule token different_geoip rule to different_srcgeoip #929

Merged
merged 3 commits into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analysisd/analysisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int main_analysisd(int argc, char **argv)
geoipdb = GeoIP_open(Config.geoipdb_file, GEOIP_INDEX_CACHE);
if (geoipdb == NULL)
{
merror("%s: Unable to open GeoIP database from: %s (disabling GeoIP).", ARGV0, Config.geoipdb_file);
merror("%s: ERROR: Unable to open GeoIP database from: %s (disabling GeoIP).", ARGV0, Config.geoipdb_file);
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/analysisd/decoders/geoip.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ char *GetGeoInfobyIP(char *ip_addr)
return(NULL);
}

if(geoiprecord->country_code == NULL || geoiprecord->country_code == NULL)
if(geoiprecord->country_code == NULL)
{
GeoIPRecord_delete(geoiprecord);
return(NULL);
Expand Down
13 changes: 13 additions & 0 deletions src/analysisd/eventinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ Eventinfo *Search_LastSids(Eventinfo *my_lf, RuleInfo *rule)
}
}

/* GEOIP version of check for repetitions from same src_ip */
if (rule->context_opts & DIFFERENT_SRCGEOIP) {
if ((!lf->srcgeoip) || (!my_lf->srcgeoip)) {
continue;
}

if (strcmp(lf->srcgeoip, my_lf->srcgeoip) == 0) {
continue;
}
}

/* Check if the number of matches worked */
if (rule->__frequency <= 10) {
rule->last_events[rule->__frequency]
Expand Down Expand Up @@ -404,6 +415,8 @@ Eventinfo *Search_LastEvents(Eventinfo *my_lf, RuleInfo *rule)
}




/* Check if the number of matches worked */
if (rule->__frequency < rule->frequency) {
if (rule->__frequency <= 10) {
Expand Down
10 changes: 7 additions & 3 deletions src/analysisd/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int Rules_OP_ReadRules(const char *rulefile)

const char *xml_different_url = "different_url";
const char *xml_different_srcip = "different_srcip";
const char *xml_different_geoip = "different_geoip";
const char *xml_different_srcgeoip = "different_srcgeoip";

const char *xml_notsame_source_ip = "not_same_source_ip";
const char *xml_notsame_user = "not_same_user";
Expand Down Expand Up @@ -825,8 +825,8 @@ int Rules_OP_ReadRules(const char *rulefile)
if(!(config_ruleinfo->alert_opts & SAME_EXTRAINFO))
config_ruleinfo->alert_opts |= SAME_EXTRAINFO;
} else if(strcmp(rule_opt[k]->element,
xml_different_geoip) == 0) {
config_ruleinfo->context_opts|= DIFFERENT_GEOIP;
xml_different_srcgeoip) == 0) {
config_ruleinfo->context_opts|= DIFFERENT_SRCGEOIP;

if(!(config_ruleinfo->alert_opts & SAME_EXTRAINFO))
config_ruleinfo->alert_opts |= SAME_EXTRAINFO;
Expand Down Expand Up @@ -1228,6 +1228,10 @@ int Rules_OP_ReadRules(const char *rulefile)

/* Mark rules that match this id */
OS_MarkID(NULL, config_ruleinfo);

/* Set function pointer */
config_ruleinfo->event_search = (void *(*)(void *, void *))
Search_LastEvents;
}

/* Mark the rules that match if_matched_group */
Expand Down
2 changes: 1 addition & 1 deletion src/analysisd/rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define SAME_LOCATION 0x008 /* 8 */
#define DIFFERENT_URL 0x010 /* */
#define DIFFERENT_SRCIP 0x200
#define DIFFERENT_GEOIP 0x400
#define DIFFERENT_SRCGEOIP 0x400
#define SAME_SRCPORT 0x020
#define SAME_DSTPORT 0x040
#define SAME_DODIFF 0x100
Expand Down
2 changes: 1 addition & 1 deletion src/headers/rules_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define SAME_LOCATION 0x008 /* 8 */
#define DIFFERENT_URL 0x010
#define DIFFERENT_SRCIP 0x200
#define DIFFERENT_GEOIP 0x400
#define DIFFERENT_SRCGEOIP 0x400
#define SAME_SRCPORT 0x020
#define SAME_DSTPORT 0x040
#define SAME_DODIFF 0x100
Expand Down