Browse code

YARA: implement basic string matching, temporarily disable simple YARA condition to lsig conversions.

Steven Morgan authored on 2015/03/20 00:59:35
Showing 2 changed files
... ...
@@ -3456,7 +3456,7 @@ static int load_oneyara(YR_RULE *rule, struct cl_engine *engine, unsigned int op
3456 3456
             cli_yaramsg("STRING_FITS_IN_ATOM       yes\n");
3457 3457
         */
3458 3458
 #endif
3459
-        string->subsig_id = ytable.tbl_cnt;
3459
+        string->subsig_id = ytable.tbl_cnt-1;
3460 3460
     }
3461 3461
 
3462 3462
     if (str_error > 0) {
... ...
@@ -3481,7 +3481,7 @@ static int load_oneyara(YR_RULE *rule, struct cl_engine *engine, unsigned int op
3481 3481
 
3482 3482
     /*** conditional verification step (ex. do we define too many strings versus used?)  ***/
3483 3483
     /*** additional string table population (ex. offsets), second translation table pass ***/
3484
-
3484
+#if 0
3485 3485
     if (rule->g_flags & RULE_ALL ||  rule->g_flags & RULE_ANY) {
3486 3486
         lsize = 3*ytable.tbl_cnt;
3487 3487
         logic = cli_calloc(lsize, sizeof(char));
... ...
@@ -3507,6 +3507,8 @@ static int load_oneyara(YR_RULE *rule, struct cl_engine *engine, unsigned int op
3507 3507
         
3508 3508
         /*** END CONDITIONAL HANDLING ***/
3509 3509
     }
3510
+#endif
3511
+
3510 3512
     /* TDB */
3511 3513
     if (rule->g_flags & RULE_EP && ytable.tbl_cnt == 1)
3512 3514
         target_str = cli_strdup(YARATARGET1);
... ...
@@ -420,7 +420,7 @@ int yr_execute_code(
420 420
 #if REAL_YARA
421 421
           rule->t_flags[tidx] |= RULE_TFLAGS_MATCH;
422 422
 #else
423
-        rule_matches++;
423
+          rule_matches++;
424 424
 #endif
425 425
 
426 426
         #ifdef PROFILING_ENABLED
... ...
@@ -548,8 +548,7 @@ int yr_execute_code(
548 548
 #if REAL_YARA
549 549
         push(string->matches[tidx].tail != NULL ? 1 : 0);
550 550
 #else
551
-        //TBD: find clamav matches
552
-        push(1); //TEMP
551
+        push(acdata->lsigsuboff_first[aclsig->id][string->subsig_id] != CLI_OFF_NONE ? 1 : 0);
553 552
 #endif
554 553
         break;
555 554