sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"ViCtOr nocase test\"; sid:2000; rev:13; content:ViCtOr; nocase; depth:150;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
/*
sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"ViCtOr case test\"; sid:2001; content:ViCtOr; depth:150;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"offset, depth, within test\"; flow:to_client; sid:2002; content:HTTP; depth:4; content:Server:; offset:15; within:100; depth:200;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"Inliniac blog within test\"; flow:to_client; sid:2003; content:inliniac; content:blog; within:9;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"abcdefg distance 1 test\"; flow:to_server; sid:2004; content:abcd; content:efgh; within:4; distance:0; content:ijkl; within:4; distance:0;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"abcdef distance 0 test\"; flow:to_server; sid:2005; content:abcdef; content:ghijklmnop; distance:0;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert ip 192.168.0.0 any -> 80.126.224.247 any (msg:\"abcdefg distance 1 test\"; flow:to_server; sid:2006; content:abcdef; content:ghijklmnop; distance:1;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP response code cap\"; flow:to_client; content:HTTP; depth:4; pcre:\"/^HTTP\\/\\d\\.\\d (?<http_response>[0-9]+) [A-z\\s]+\\r\\n/\"; depth:50; sid:3;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP server code cap\"; flow:to_client; content:Server:; depth:500; pcre:\"/^Server: (?<http_server>.*)\\r\\n/m\"; sid:4;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"\to_client nocase test\"; flow:to_client; content:Servere:; nocase; sid:400;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP UA code cap\"; flow:to_server; content:User-Agent:; depth:300; pcre:\"/^User-Agent: (?<http_ua>.*)\\r\\n/m\"; sid:5;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP host code cap\"; flow:to_server; content:Host:; depth:300; pcre:\"/^Host: (?<http_host>.*)\\r\\n/m\"; sid:6;)");
if(sig==NULL)
return;
prevsig->next=sig;
prevsig=sig;
*/
/*
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP http_host flowvar www.inliniac.net\"; flow:to_server; flowvar:http_host,\"www.inliniac.net\"; sid:7;)");
if(sig){
prevsig->next=sig;
prevsig=sig;
}
*/
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP http_uri flowvar MattJonkman\"; flow:to_server; flowvar:http_uri,\"MattJonkman\"; sid:8;)");
if(sig){
prevsig->next=sig;
prevsig=sig;
}
sig=SigInit("alert tcp 192.168.0.0 any -> 0.0.0.0 any (msg:\"HTTP uricontent VictorJulien\"; flow:to_server; uricontent:\"VJ\"; sid:9;)");
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; recursive; sid:1;)");
//printf("URI0 \"%s\", len %u\n", th_v.http_uri.raw[0], th_v.http_uri.raw_size[0]);
//printf("URI1 \"%s\", len %u\n", th_v.http_uri.raw[1], th_v.http_uri.raw_size[1]);
if(p.http_uri.raw_size[0]==5&&
memcmp(p.http_uri.raw[0],"/one/",5)==0&&
p.http_uri.raw_size[1]==5&&
memcmp(p.http_uri.raw[1],"/two/",5)==0)
{
result=1;
}
PatternMatcherThreadDeinit(&th_v,(void*)pmt);
PatternMatchDestroy();
end:
returnresult;
}
intSigTest02(void){
u_int8_t*buf=(u_int8_t*)
"GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n"
"\r\n\r\n"
"GET /two/ HTTP/1.1\r\n"
"Host: two.example.org\r\n"
"\r\n\r\n";
u_int16_tbuflen=strlen((char*)buf);
Packetp;
ThreadVarsth_v;
PatternMatcherThread*pmt;
intresult=0;
memset(&th_v,0,sizeof(th_v));
memset(&p,0,sizeof(p));
p.tcp_payload=buf;
p.tcp_payload_len=buflen;
SigParsePrepare();
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host: one.example.org\"; offset:20; depth:41; sid:1;)");
if(sig_list==NULL){
result=0;
gotoend;
}
PatternMatchPrepare(sig_list);
PatternMatcherThreadInit(&th_v,(void*)&pmt);
SigMatchSignatures(&th_v,pmt,&p);
if(PacketAlertCheck(&p,1))
result=1;
PatternMatcherThreadDeinit(&th_v,(void*)pmt);
PatternMatchDestroy();
end:
returnresult;
}
intSigTest03(void){
u_int8_t*buf=(u_int8_t*)
"GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n"
"\r\n\r\n"
"GET /two/ HTTP/1.1\r\n"
"Host: two.example.org\r\n"
"\r\n\r\n";
u_int16_tbuflen=strlen((char*)buf);
Packetp;
ThreadVarsth_v;
PatternMatcherThread*pmt;
intresult=0;
memset(&th_v,0,sizeof(th_v));
memset(&p,0,sizeof(p));
p.tcp_payload=buf;
p.tcp_payload_len=buflen;
SigParsePrepare();
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host: one.example.org\"; offset:20; depth:40; sid:1;)");
if(sig_list==NULL){
result=0;
gotoend;
}
PatternMatchPrepare(sig_list);
PatternMatcherThreadInit(&th_v,(void*)&pmt);
SigMatchSignatures(&th_v,pmt,&p);
if(!PacketAlertCheck(&p,1))
result=1;
PatternMatcherThreadDeinit(&th_v,(void*)pmt);
PatternMatchDestroy();
end:
returnresult;
}
intSigTest04(void){
u_int8_t*buf=(u_int8_t*)
"GET /one/ HTTP/1.1\r\n"
"Host: one.example.org\r\n"
"\r\n\r\n"
"GET /two/ HTTP/1.1\r\n"
"Host: two.example.org\r\n"
"\r\n\r\n";
u_int16_tbuflen=strlen((char*)buf);
Packetp;
ThreadVarsth_v;
PatternMatcherThread*pmt;
intresult=0;
memset(&th_v,0,sizeof(th_v));
memset(&p,0,sizeof(p));
p.tcp_payload=buf;
p.tcp_payload_len=buflen;
SigParsePrepare();
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host:\"; offset:20; depth:25; content:\"Host:\"; distance:47; within:52; sid:1;)");
if(sig_list==NULL){
result=0;
gotoend;
}
PatternMatchPrepare(sig_list);
PatternMatcherThreadInit(&th_v,(void*)&pmt);
SigMatchSignatures(&th_v,pmt,&p);
if(PacketAlertCheck(&p,1))
result=1;
PatternMatcherThreadDeinit(&th_v,(void*)pmt);
PatternMatchDestroy();
end:
returnresult;
}
intSigTest05(void){
u_int8_t*buf=(u_int8_t*)
"GET /one/ HTTP/1.1\r\n"/* 20 */
"Host: one.example.org\r\n"/* 23, 43 */
"\r\n\r\n"/* 4, 47 */
"GET /two/ HTTP/1.1\r\n"/* 20, 67 */
"Host: two.example.org\r\n"/* 23, 90 */
"\r\n\r\n";/* 4, 94 */
u_int16_tbuflen=strlen((char*)buf);
Packetp;
ThreadVarsth_v;
PatternMatcherThread*pmt;
intresult=0;
memset(&th_v,0,sizeof(th_v));
memset(&p,0,sizeof(p));
p.tcp_payload=buf;
p.tcp_payload_len=buflen;
SigParsePrepare();
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP TEST\"; content:\"Host:\"; offset:20; depth:25; content:\"Host:\"; distance:48; within:52; sid:1;)");
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; recursive; sid:1;)");
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<http_uri>.*) HTTP\\/\\d\\.\\d\\r\\n/G\"; recursive; sid:1;)");
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<http_uri>.*) HTTP\\/1\\.0\\r\\n/G\"; sid:1;)");
sig_list=SigInit("alert tcp any any -> any any (msg:\"HTTP URI cap\"; content:\"GET \"; depth:4; pcre:\"/GET (?P<http_uri>.*) HTTP\\/1\\.0\\r\\n/G\"; sid:1;)");