Changeset 1614

Show
Ignore:
Timestamp:
04/03/08 23:20:41 (5 months ago)
Author:
till
Message:

nebula
- command line options for minimum segment length and entropy for segment selection added
- error in string concatenation routine fixed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nebula/trunk/src/nebula.c

    r1612 r1614  
    5858                "\t\t -c <similarity> cluster criterion (a similarity measure in percent)\n" 
    5959                "\t\t -d\t\t daemonize\n" 
     60                "\t\t -e\t\t minimum substring entropy\n" 
    6061                "\t\t -h\t\t this help\n" 
    6162                "\t\t -E <size>\t cluster element queue size\n" 
    6263                "\t\t -i <sid>\t initial snort signature ID\n" 
     64                "\t\t -l\t\t minimum substring length\n" 
    6365                "\t\t -O <size>\t outlier queue size\n" 
    6466                "\t\t -p <port>\t listen on this port\n" 
     
    132134 
    133135        // process args 
    134         while((option = getopt(argc, argv, "a:c:C:dE: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) { 
    135137                switch(option) { 
    136138                        case 'a': 
     
    154156                                daemonize = 1; 
    155157                                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; 
    156165                        case 'E': 
    157166                                clusterhashq_max = atoi(optarg); 
     
    165174                                if (!global_sid) { 
    166175                                        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"); 
    167183                                        exit(EXIT_FAILURE); 
    168184                                } 
     
    337353                                                        exit(EXIT_FAILURE); 
    338354                                                } 
    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 */ 
    343355                                                memcpy(tmp_submission, &s[i], sizeof(submission)); 
    344356                                                memset(&s[i], 0, sizeof(submission)); 
     
    357369 
    358370                                                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 */ 
    362371                                                break; 
    363372                                        case 0: 
  • nebula/trunk/src/nebula.h

    r1613 r1614  
    5454unsigned long int       initial_threshold; 
    5555 
     56ssize_t         min_sstr_len; 
     57double          min_sstr_ent; 
     58 
    5659queue           *clusterq; 
    5760queue           *outlierq; 
  • nebula/trunk/src/sig.c

    r1613 r1614  
    360360        u_int32_t       i, acnt, node_id, num_leaves, strllen; 
    361361        lchar           *strlist; 
    362         ssize_t         min_sstr_len; 
    363         double          min_sstr_ent; 
    364362        u_char          *byte; 
    365363        qelem           *qe; 
     
    377375        content         = NULL; 
    378376 
    379         min_sstr_len    = 0; 
    380         min_sstr_ent    = 0; 
    381377        acnt            = 0; 
    382378 
     
    409405                // concatenate attack strings 
    410406                // 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) { 
    412408                        fprintf(stderr, "Error - Unable to allocate memory: %m.\n"); 
    413409                        exit(EXIT_FAILURE); 
    414410                } 
    415                 memset(&strlist[strllen], 0, sizeof(lchar) * (attack->attack_len + 3)); 
    416411 
    417412                // extend string offset array 
     
    425420                        strlist[strllen+i+1] = attack->attack[i]; 
    426421                } 
    427                 strllen += attack->attack_len; 
    428  
     422                strllen += attack->attack_len + 1; 
    429423                strlist[strllen] = acnt << 8; 
    430                 strllen++; 
    431424 
    432425                // process port info 
     
    453446        if (verbose > 2) { 
    454447                printf("Concatenated string (%u) is '", strllen); 
    455                 for (i = 0; i < strllen; i++) { 
     448                for (i=1; i <= strllen; i++) { 
    456449                        byte = (u_char *) &strlist[i]; 
    457450                        if (strlist[i] && !(strlist[i] & 0x000000ff)) 
     
    588581                } 
    589582                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); 
    593586 
    594587                // process other segments 
  • nebula/trunk/src/stree.h

    r1558 r1614  
    8888void get_substring_endnodes(stnode *root, substr_list *cstr_list, ssize_t min_length); 
    8989void list_substrings(stree *t, stnode *cstr_node, ssize_t length); 
    90 avl_tree *build_substring_list(stree *t, ssize_t min_length); 
    9190 
    9291