@ -1,4 +1,4 @@
/* Copyright (C) 2007-20 17 Open Information Security Foundation
/* Copyright (C) 2007-20 2 1 Open Information Security Foundation
*
* You can copy , redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -374,19 +374,16 @@ static int PayloadTestSig01 (void)
" abcabcd " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" abc \" ; content: \" d \" ; distance:0; within:1; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/** \test Nocase matching */
@ -396,19 +393,16 @@ static int PayloadTestSig02 (void)
" abcaBcd " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" abc \" ; nocase; content: \" d \" ; distance:0; within:1; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/** \test Negative distance matching */
@ -418,19 +412,16 @@ static int PayloadTestSig03 (void)
" abcaBcd " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" aBc \" ; nocase; content: \" abca \" ; distance:-10; within:4; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -441,21 +432,18 @@ static int PayloadTestSig04(void)
uint8_t * buf = ( uint8_t * ) " now this is is big big string now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" this \" ; content: \" is \" ; within:6; content: \" big \" ; within:8; "
" content: \" string \" ; within:8; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -466,21 +454,18 @@ static int PayloadTestSig05(void)
uint8_t * buf = ( uint8_t * ) " now this is is is big big big string now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" this \" ; content: \" is \" ; within:9; content: \" big \" ; within:12; "
" content: \" string \" ; within:8; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -491,21 +476,18 @@ static int PayloadTestSig06(void)
uint8_t * buf = ( uint8_t * ) " this this now is is big string now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" now \" ; content: \" this \" ; content: \" is \" ; within:12; content: \" big \" ; within:8; "
" content: \" string \" ; within:8; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -516,21 +498,17 @@ static int PayloadTestSig07(void)
uint8_t * buf = ( uint8_t * ) " thus thus is a big " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" thus \" ; offset:8; content: \" is \" ; within:6; content: \" big \" ; within:8; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -542,20 +520,17 @@ static int PayloadTestSig08(void)
uint8_t * buf = ( uint8_t * ) " we need to fix this and yes fix this now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" fix \" ; content: \" this \" ; within:6; content:! \" and \" ; distance:0; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 1 ) {
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 1 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -566,21 +541,17 @@ static int PayloadTestSig09(void)
uint8_t * buf = ( uint8_t * ) " this is a super duper nova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" pcre:/super/; content: \" nova \" ; within:7; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -591,21 +562,17 @@ static int PayloadTestSig10(void)
uint8_t * buf = ( uint8_t * ) " this is a super duper nova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert udp any any -> any any (msg: \" crash \" ; "
" byte_test:4,>,2,0,relative; sid:11;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -616,21 +583,17 @@ static int PayloadTestSig11(void)
uint8_t * buf = ( uint8_t * ) " this is a super duper nova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert udp any any -> any any (msg: \" crash \" ; "
" byte_jump:1,0,relative; sid:11;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -641,21 +604,17 @@ static int PayloadTestSig12(void)
uint8_t * buf = ( uint8_t * ) " this is a super duper nova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert udp any any -> any any (msg: \" crash \" ; "
" isdataat:10,relative; sid:11;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -683,20 +642,17 @@ static int PayloadTestSig13(void)
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
uint16_t mpm_type = mpm_default_matcher ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" aa \" ; content: \" aa \" ; distance:0; content: \" aa \" ; distance:0; "
" byte_test:1,>,200,0,relative; sid:1;) " ;
struct timeval tv_start , tv_end , tv_diff ;
gettimeofday ( & tv_start , NULL ) ;
do {
DecodeThreadVars dtv ;
ThreadVars th_v ;
DetectEngineThreadCtx * det_ctx = NULL ;
@ -705,53 +661,29 @@ static int PayloadTestSig13(void)
memset ( & th_v , 0 , sizeof ( th_v ) ) ;
DetectEngineCtx * de_ctx = DetectEngineCtxInit ( ) ;
if ( de_ctx = = NULL ) {
printf ( " de_ctx == NULL: " ) ;
goto end ;
}
FAIL_IF_NULL ( de_ctx ) ;
de_ctx - > inspection_recursion_limit = 3000 ;
de_ctx - > flags | = DE_QUIET ;
de_ctx - > mpm_matcher = mpm_type ;
de_ctx - > sig_list = SigInit ( de_ctx , sig ) ;
if ( de_ctx - > sig_list = = NULL ) {
printf ( " signature == NULL: " ) ;
goto end ;
}
FAIL_IF_NULL ( de_ctx - > sig_list ) ;
SigGroupBuild ( de_ctx ) ;
DetectEngineThreadCtxInit ( & th_v , ( void * ) de_ctx , ( void * ) & det_ctx ) ;
SigMatchSignatures ( & th_v , de_ctx , det_ctx , p ) ;
if ( PacketAlertCheck ( p , de_ctx - > sig_list - > id ) ! = 1 ) {
goto end ;
}
result = 1 ;
end :
SigGroupCleanup ( de_ctx ) ;
SigCleanSignatures ( de_ctx ) ;
FAIL_IF_NOT ( PacketAlertCheck ( p , de_ctx - > sig_list - > id ) ! = 1 ) ;
if ( det_ctx ! = NULL )
DetectEngineThreadCtxDeinit ( & th_v , ( void * ) det_ctx ) ;
if ( de_ctx ! = NULL )
DetectEngineCtxFree ( de_ctx ) ;
} while ( 0 ) ;
gettimeofday ( & tv_end , NULL ) ;
tv_diff . tv_sec = tv_end . tv_sec - tv_start . tv_sec ;
tv_diff . tv_usec = tv_end . tv_usec - tv_start . tv_usec ;
printf ( " %ld.%06ld \n " , ( long int ) tv_diff . tv_sec , ( long int ) tv_diff . tv_usec ) ;
result = 1 ;
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -762,21 +694,18 @@ static int PayloadTestSig14(void)
uint8_t * buf = ( uint8_t * ) " User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b4) Gecko/20090423 Firefox/3.6 GTB5 " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" User-Agent|3A| Mozilla/5.0 |28|Macintosh|3B| \" ; content: \" Firefox/3. \" ; distance:0; content:! \" Firefox/3.6.12 \" ; distance:-10; content:! \" Mozilla/5.0 |28|Macintosh|3B| U|3B| Intel Mac OS X 10.5|3B| en-US|3B| rv|3A|1.9.1b4|29| Gecko/20090423 Firefox/3.6 GTB5 \" ; sid:1; rev:1;) " ;
//char sig[] = "alert tcp any any -> any any (content:\"User-Agent: Mozilla/5.0 (Macintosh; \"; content:\"Firefox/3.\"; distance:0; content:!\"Firefox/3.6.12\"; distance:-10; content:!\"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b4) Gecko/20090423 Firefox/3.6 GTB5\"; sid:1; rev:1;)";
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) {
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig15 ( void )
@ -784,22 +713,17 @@ static int PayloadTestSig15(void)
uint8_t * buf = ( uint8_t * ) " this is a super duper nova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" nova \" ; isdataat:18,relative; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig16 ( void )
@ -807,22 +731,17 @@ static int PayloadTestSig16(void)
uint8_t * buf = ( uint8_t * ) " this is a super duper nova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" nova \" ; isdataat:!20,relative; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig17 ( void )
@ -830,23 +749,18 @@ static int PayloadTestSig17(void)
uint8_t buf [ ] = { 0xEB , 0x29 , 0x25 , 0x38 , 0x78 , 0x25 , 0x38 , 0x78 , 0x25 } ;
uint16_t buflen = 9 ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" % \" ; depth:4; offset:0; "
" content: \" % \" ; within:2; distance:1; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig18 ( void )
@ -858,24 +772,19 @@ static int PayloadTestSig18(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
" byte_extract:1,2,one,string,dec,relative; "
" content: \" |0C 0D 0E 0F| \" ; distance:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig19 ( void )
@ -887,24 +796,19 @@ static int PayloadTestSig19(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
" byte_extract:1,2,one,string,hex,relative; "
" content: \" |0C 0D 0E 0F| \" ; distance:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig20 ( void )
@ -916,24 +820,19 @@ static int PayloadTestSig20(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
" byte_extract:1,2,one,string,dec,relative; "
" content: \" |06 35 07 08| \" ; offset:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig21 ( void )
@ -945,24 +844,19 @@ static int PayloadTestSig21(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
" byte_extract:1,2,one,string,dec,relative; "
" content: \" |03 04 05 06| \" ; depth:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig22 ( void )
@ -974,24 +868,19 @@ static int PayloadTestSig22(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
" byte_extract:1,2,one,string,dec,relative; "
" content: \" |09 0A 0B 0C| \" ; within:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig23 ( void )
@ -1003,7 +892,8 @@ static int PayloadTestSig23(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
@ -1011,17 +901,11 @@ static int PayloadTestSig23(void)
" byte_extract:1,3,two,string,dec,relative; "
" byte_test:1,=,one,two,string,dec,relative; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig24 ( void )
@ -1033,7 +917,8 @@ static int PayloadTestSig24(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |01 02 03 04| \" ; "
@ -1041,17 +926,11 @@ static int PayloadTestSig24(void)
" byte_jump:1,one,string,dec,relative; "
" content: \" |0D 0E 0F| \" ; distance:0; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/*
@ -1066,24 +945,19 @@ static int PayloadTestSig25(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |35 07 08 09| \" ; "
" byte_extract:1,-4,one,string,dec,relative; "
" content: \" |0C 0D 0E 0F| \" ; distance:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/*
@ -1098,24 +972,19 @@ static int PayloadTestSig26(void)
} ;
uint16_t buflen = sizeof ( buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" content: \" |35 07 08 09| \" ; "
" byte_extract:1,-3000,one,string,dec,relative; "
" content: \" |0C 0D 0E 0F| \" ; distance:one; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 0 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/*
@ -1125,23 +994,19 @@ static int PayloadTestSig27(void)
{
uint8_t buf [ ] = " dummypayload " ;
uint16_t buflen = sizeof ( buf ) - 1 ;
int result = 0 ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" dummy \" ; "
" depth:5; sid:1;) " ;
p - > flags | = PKT_STREAM_ADD ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 1 )
goto end ;
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 1 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/*
@ -1151,23 +1016,19 @@ static int PayloadTestSig28(void)
{
uint8_t buf [ ] = " dummypayload " ;
uint16_t buflen = sizeof ( buf ) - 1 ;
int result = 0 ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" payload \" ; "
" offset:4; depth:12; sid:1;) " ;
p - > flags | = PKT_STREAM_ADD ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 1 )
goto end ;
result = 1 ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) ! = 1 ) ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -1178,21 +1039,17 @@ static int PayloadTestSig29(void)
uint8_t * buf = ( uint8_t * ) " this is a super dupernova in super nova now " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" dummy \" ; "
" pcre:/^.{4}/; content: \" nova \" ; within:4; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) {
result = 0 ;
goto end ;
}
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 1 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig30 ( void )
@ -1201,19 +1058,16 @@ static int PayloadTestSig30(void)
" xyonexxxxxxtwojunkonetwo " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" one \" ; pcre: \" /^two/R \" ; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
static int PayloadTestSig31 ( void )
@ -1222,19 +1076,16 @@ static int PayloadTestSig31(void)
" xyonexxxxxxtwojunkonetwo " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (content: \" one \" ; pcre: \" /(fiv|^two)/R \" ; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) {
result = 0 ;
goto end ;
}
result = 1 ;
end :
if ( p ! = NULL )
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -1245,19 +1096,17 @@ static int PayloadTestSig32(void)
uint8_t * buf = ( uint8_t * ) " dummy2xxcardmessage " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" crash \" ; "
" content: \" message \" ; byte_jump:2,-14,string,dec,relative; content: \" card \" ; within:4; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 )
goto end ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -1268,19 +1117,17 @@ static int PayloadTestSig33(void)
uint8_t * buf = ( uint8_t * ) " dummy2xxcardmessage " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" crash \" ; "
" content: \" message \" ; byte_test:1,=,2,-14,string,dec,relative; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 )
goto end ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
/**
@ -1291,19 +1138,17 @@ static int PayloadTestSig34(void)
uint8_t * buf = ( uint8_t * ) " dummy2xxcardmessage " ;
uint16_t buflen = strlen ( ( char * ) buf ) ;
Packet * p = UTHBuildPacket ( buf , buflen , IPPROTO_TCP ) ;
int result = 0 ;
FAIL_IF_NULL ( p ) ;
char sig [ ] = " alert tcp any any -> any any (msg: \" crash \" ; "
" content: \" message \" ; byte_extract:1,-14,boom,string,dec,relative; sid:1;) " ;
if ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 )
goto end ;
FAIL_IF ( UTHPacketMatchSigMpm ( p , sig , mpm_default_matcher ) = = 0 ) ;
result = 1 ;
end :
if ( p ! = NULL )
UTHFreePacket ( p ) ;
return result ;
PASS ;
}
# endif /* UNITTESTS */