User Ratings
Rate This Project
Login To Rate This Project
User Reviews
-
I have tested Watchdog and Reputation. In reputation I found some of the segmentation fault which we fixed it. Please find below the patch attached : ------------------------------------------------------------------------------------------------------------------- <pre> diff -Naur Reputation/Reputation.c Reputation_modified/Reputation.c --- Reputation/Reputation.c 2008-12-09 20:19:20.000000000 +0530 +++ Reputation_modified/Reputation.c 2014-07-10 11:15:10.471771799 +0530 @@ -81,7 +81,7 @@ int gatewaytime = GW_TIME; routes paths; blockaded blck; -char gw_ip[16]; //Where to send the alerts. +char gw_ip[16]=GW_IP; //Where to send the alerts. int port=PORT; //Port of the GW. @@ -100,7 +100,7 @@ printf("\t[-b --bonus]\t\t\tReputation added for each established route (Default %d).\n", ROUTE_BONIFICATION); printf("\t[-d --debug]\t\t\tSet debug mode (Default %d).\n", DEBUG); printf("\t[-e --eject]\t\t\tReputation needed to discart the used route (Default %d).\n", EJECT_ROUTE_VALUE); - printf("\t[-f --file]\t\t\tStablished connections file (Default \"/proc/net/ip_conntrack\").\n"); + printf("\t[-f --file]\t\t\tStablished connections file (Default \"/proc/net/nf_conntrack\").\n"); printf("\t[-g --gw]\t\t\tIp of the gw to send the alerts (Default %s).\n", GW_IP); printf("\t[-h --help]\t\t\tShows this help.\n"); printf("\t[-i --interface]\t\tSet the interface where lisening.\n"); @@ -287,8 +287,8 @@ fp = fopen(pathToFile, "r"); if (fp == NULL){ printf ("Error reading file: "); - printf("Trying to load the ip_conntrack module...\n"); - system("modprobe ip_conntrack"); + printf("Trying to load the nf_conntrack module...\n"); + system("modprobe nf_conntrack"); exit(-1); } else { strcpy(source_string,"src="); @@ -409,7 +409,7 @@ int waiting=0; /* Default file */ - strcpy(pathToFile, "/proc/net/ip_conntrack"); + strcpy(pathToFile, "/proc/net/nf_conntrack"); options(argc, argv); setSignals(); obtainOwnIP(interface,ownIP); diff -Naur Reputation/alarm.h Reputation_modified/alarm.h --- Reputation/alarm.h 2014-07-08 16:28:21.123022681 +0530 +++ Reputation_modified/alarm.h 2014-07-08 16:28:19.234772092 +0530 @@ -57,9 +57,10 @@ if(connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0){ perror("Connection error"); printf("\tIs the syslog-ng waiting on the computer %s (%d)?\n\n", gwIP, port); - } - - if ((numbytes = send(sockfd, message, strlen(message), 0)) < 0) perror("Send");; + } + else{ + if ((numbytes = send(sockfd, message, strlen(message), 0)) < 0) perror("Send");; + } close(sockfd); } @@ -78,10 +79,10 @@ time ( &rawtime ); timeinfo = localtime ( &rawtime ); time_tmp = asctime(timeinfo); - - newstring = (char *)malloc(strlen(time_tmp)-1); - for(i = 0; i < strlen(time_tmp)-1; i++) + newstring = (char *)malloc(strlen(time_tmp)+1); + + for(i = 0; i <= strlen(time_tmp); i++) { newstring[i] = time_tmp[i]; } diff -Naur Reputation/config.h Reputation_modified/config.h --- Reputation/config.h 2008-12-09 20:15:22.000000000 +0530 +++ Reputation_modified/config.h 2014-07-09 17:19:21.326763824 +0530 @@ -40,4 +40,4 @@ #define GW_IP "127.0.0.1" #define PORT 1999 #define GW_TIME 2 - +#define MAX_RULES 20 diff -Naur Reputation/routes.h Reputation_modified/routes.h --- Reputation/routes.h 2008-12-09 20:26:59.000000000 +0530 +++ Reputation_modified/routes.h 2014-07-10 11:21:00.839014396 +0530 @@ -51,10 +51,10 @@ typedef struct { /* Stores all iptables rules used for deleting if the program is killed. */ int howmany; - char instructions[20][200]; + char instructions[MAX_RULES][200]; }blockaded; - +route *my_route; /*********************************** FUNCTIONS @@ -539,20 +539,17 @@ * Send to the system the instruction to blockade a specific route */ void IsolateRoute(route *rt, blockaded *blk, char * ownIP, char* gw_ip, int port){ - char final_rule[200]; + char final_rule[200]=""; char rule1[80]="iptables -I INPUT -m mac --mac-source "; char text[100]; - - ObtainRouteMAC(rt); + ObtainRouteMAC(rt); strcat(rule1, rt->mac); strcat(rule1, " -j DROP"); system(rule1); - char rule2[80]="iptables -I FORWARD -m mac --mac-source "; strcat(rule2, rt->mac); strcat(rule2, " -j DROP"); system(rule2); - strcpy(rule1,"iptables -D INPUT -m mac --mac-source "); strcat(rule1, rt->mac); strcat(rule1, " -j DROP"); @@ -563,12 +560,10 @@ strcat(final_rule, "; "); strcat(final_rule, rule2); strcpy(blk->instructions[blk->howmany], final_rule); - blk->howmany++; - + if(blk->howmany < MAX_RULES-1) blk->howmany++; sprintf(text, "Alarm! Alarm! route %s (%s) has no reputation\n", rt->ip, rt->mac); - SendAnAlarm(text, rt->ip, rt->mac, ownIP, gw_ip, port); - - rt->blockaded = 1; + SendAnAlarm(text, rt->ip, rt->mac, ownIP, gw_ip, port); + rt->blockaded = 1; } @@ -611,8 +606,10 @@ r=rts->group; while(r!=NULL){ - if ((r->reputation <= reputation) && (!r->blockaded) && (!r->default_route)) IsolateRoute(r, blk, ownMAC, gw_ip, port); - r = r->next; + if ((r->reputation <= reputation) && (!r->blockaded) && (!r->default_route)) { + IsolateRoute(r, blk, ownMAC, gw_ip, port); + } + r = r->next; } } </pre>
- Previous
- You're on page 1
- Next