1 /* @(#) $Id: ./src/analysisd/compiled_rules/generic_samples.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
12 * License details at the LICENSE file included with OSSEC or
13 * online at: http://www.ossec.net/en/licensing.html
18 #include "eventinfo.h"
23 /** Note: If the rule fails to match it should return NULL.
24 * If you want processing to continue, return lf (the eventinfo structure).
30 * Comparing if the srcuser and dstuser are the same. If they are the same,
32 * If any of them is not set, return true too.
34 void *comp_srcuser_dstuser(Eventinfo *lf)
36 if(!lf->srcuser || !lf->dstuser)
41 if(strcmp(lf->srcuser, lf->dstuser) == 0)
47 /* In here, srcuser and dstuser are present and are different. */
54 * Checking if the size of the id field is larger than 10.
56 void *check_id_size(Eventinfo *lf)
63 if(strlen(lf->id) >= 10)
74 * Comparing the Target Account Name and Caller User Name
76 * It will return NULL (not match) if any of these values
77 * are not present or if they are the same.
78 * This function will return TRUE if they are NOT the same.
80 void *comp_mswin_targetuser_calleruser_diff(Eventinfo *lf)
86 target_user = strstr(lf->log, "Target Account Name");
87 caller_user = strstr(lf->log, "Caller User Name");
89 if(!target_user || !caller_user)
95 /* We need to clear each user type and finish the string.
97 * Target Account Name: account\t
98 * Caller User Name: account\t
100 target_user = strchr(target_user, ':');
101 caller_user = strchr(caller_user, ':');
103 if(!target_user || !caller_user)
113 while(*target_user != '\0')
115 if(*target_user != *caller_user)
118 if(*target_user == '\t' ||
119 (*target_user == ' ' && target_user[1] == ' '))
122 target_user++;caller_user++;
126 /* If we got in here, the accounts are the same.
127 * So, we return NULL since we only want to alert if they are different.
134 * Checks if a HTTP request is a simple GET/POST without a query.
135 * This avoid that we call the attack rules for no reason.
137 void *is_simple_http_request(Eventinfo *lf)
140 /* Simple GET / request. */
141 if(strcmp(lf->url,"/") == 0)
147 /* Simple request, no query. */
148 if(!strchr(lf->url,'?'))
154 /* In here, we have an additional query to be checked. */
160 * Checks if the source ip is from a valid bot.
162 void *is_valid_crawler(Eventinfo *lf)
164 if((strncmp(lf->log, "66.249.",7) == 0)|| /* Google bot */
165 (strncmp(lf->log, "72.14.",6) == 0)|| /* Feedfetcher-Google */
166 (strncmp(lf->log, "209.85.",7) == 0)|| /* Feedfetcher-Google */
167 (strncmp(lf->log, "65.55.",6) == 0)|| /* MSN/Bing */
168 (strncmp(lf->log, "207.46.",7) == 0)|| /* MSN/Bing */
169 (strncmp(lf->log, "74.6.",5) == 0)|| /* Yahoo */
170 (strncmp(lf->log, "72.30.",6) == 0)|| /* Yahoo */
171 (strncmp(lf->log, "67.195.",7) == 0) /* Yahoo */
182 /* END generic samples. */