Changeset 1614
- Timestamp:
- 04/03/08 23:20:41 (5 months ago)
- Files:
-
- nebula/trunk/src/nebula.c (modified) (6 diffs)
- nebula/trunk/src/nebula.h (modified) (1 diff)
- nebula/trunk/src/sig.c (modified) (6 diffs)
- nebula/trunk/src/stree.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nebula/trunk/src/nebula.c
r1612 r1614 58 58 "\t\t -c <similarity> cluster criterion (a similarity measure in percent)\n" 59 59 "\t\t -d\t\t daemonize\n" 60 "\t\t -e\t\t minimum substring entropy\n" 60 61 "\t\t -h\t\t this help\n" 61 62 "\t\t -E <size>\t cluster element queue size\n" 62 63 "\t\t -i <sid>\t initial snort signature ID\n" 64 "\t\t -l\t\t minimum substring length\n" 63 65 "\t\t -O <size>\t outlier queue size\n" 64 66 "\t\t -p <port>\t listen on this port\n" … … 132 134 133 135 // process args 134 while((option = getopt(argc, argv, "a:c:C:d E:hi:O:p:r:s:t:v?")) > 0) {136 while((option = getopt(argc, argv, "a:c:C:de:E:hi:l:O:p:r:s:t:v?")) > 0) { 135 137 switch(option) { 136 138 case 'a': … … 154 156 daemonize = 1; 155 157 break; 158 case 'e': 159 min_sstr_ent = atoi(optarg); 160 if (min_sstr_ent < 0) { 161 fprintf(stderr, "Error - Minimum substring entropy cannot be negative.\n"); 162 exit(EXIT_FAILURE); 163 } 164 break; 156 165 case 'E': 157 166 clusterhashq_max = atoi(optarg); … … 165 174 if (!global_sid) { 166 175 fprintf(stderr, "Error - Invalid initial snort signature ID.\n"); 176 exit(EXIT_FAILURE); 177 } 178 break; 179 case 'l': 180 min_sstr_len = atoi(optarg); 181 if (min_sstr_len < 0) { 182 fprintf(stderr, "Error - Minimum substring length cannot be negative.\n"); 167 183 exit(EXIT_FAILURE); 168 184 } … … 337 353 exit(EXIT_FAILURE); 338 354 } 339 /*340 int j;341 for (j=1; j<=pollfd_set_size; j++) printf("-- session %d: fd %d, state %u\n", j, pfdset[j].fd, s[j].state);342 */343 355 memcpy(tmp_submission, &s[i], sizeof(submission)); 344 356 memset(&s[i], 0, sizeof(submission)); … … 357 369 358 370 session_reset(&s[i], i); 359 /*360 for (j=1; j<=pollfd_set_size; j++) printf("== session %d: fd %d, state %u\n", j, pfdset[j].fd, s[j].state);361 */362 371 break; 363 372 case 0: nebula/trunk/src/nebula.h
r1613 r1614 54 54 unsigned long int initial_threshold; 55 55 56 ssize_t min_sstr_len; 57 double min_sstr_ent; 58 56 59 queue *clusterq; 57 60 queue *outlierq; nebula/trunk/src/sig.c
r1613 r1614 360 360 u_int32_t i, acnt, node_id, num_leaves, strllen; 361 361 lchar *strlist; 362 ssize_t min_sstr_len;363 double min_sstr_ent;364 362 u_char *byte; 365 363 qelem *qe; … … 377 375 content = NULL; 378 376 379 min_sstr_len = 0;380 min_sstr_ent = 0;381 377 acnt = 0; 382 378 … … 409 405 // concatenate attack strings 410 406 // byte strlist[0] must not be used, it simplifies the GST algorithm which uses offset 0 for the root node 411 if ((strlist = realloc(strlist, sizeof(lchar) * (strllen + attack->attack_len + 3))) == NULL) {407 if ((strlist = realloc(strlist, sizeof(lchar) * (strllen + attack->attack_len + 2))) == NULL) { 412 408 fprintf(stderr, "Error - Unable to allocate memory: %m.\n"); 413 409 exit(EXIT_FAILURE); 414 410 } 415 memset(&strlist[strllen], 0, sizeof(lchar) * (attack->attack_len + 3));416 411 417 412 // extend string offset array … … 425 420 strlist[strllen+i+1] = attack->attack[i]; 426 421 } 427 strllen += attack->attack_len; 428 422 strllen += attack->attack_len + 1; 429 423 strlist[strllen] = acnt << 8; 430 strllen++;431 424 432 425 // process port info … … 453 446 if (verbose > 2) { 454 447 printf("Concatenated string (%u) is '", strllen); 455 for (i = 0; i <strllen; i++) {448 for (i=1; i <= strllen; i++) { 456 449 byte = (u_char *) &strlist[i]; 457 450 if (strlist[i] && !(strlist[i] & 0x000000ff)) … … 588 581 } 589 582 if (!printable) fprintf(rfile, "|"); 590 fprintf(rfile, "\"; depth: %lu; offset: %lu;",591 (long unsigned int) seglist[num_frags-1].max_off+seglist[num_frags-1].len,592 (long unsigned int) (seglist[num_frags-1].min_off > seglist[num_frags-1].len ? seglist[num_frags-1].min_off - seglist[num_frags-1].len : 0));583 fprintf(rfile, "\"; offset: %lu; depth: %lu;", 584 (long unsigned int) (seglist[num_frags-1].min_off > seglist[num_frags-1].len ? seglist[num_frags-1].min_off - seglist[num_frags-1].len : 0), 585 (long unsigned int) seglist[num_frags-1].max_off+seglist[num_frags-1].len); 593 586 594 587 // process other segments nebula/trunk/src/stree.h
r1558 r1614 88 88 void get_substring_endnodes(stnode *root, substr_list *cstr_list, ssize_t min_length); 89 89 void list_substrings(stree *t, stnode *cstr_node, ssize_t length); 90 avl_tree *build_substring_list(stree *t, ssize_t min_length);91 90 92 91
