<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">How should I send the files to you? I did a restart, and then turned on wireshark and had it capturing on eth0, turned on suricata with both rules on, and then opened up chrome to visit the businessweek webpage for the first time and the number of http alerts vs pcre alerts are not the same. I saved the pcap file along with the logs and then tried to run suricata in offline mode using the -r option but in this run it generated no data in the fast.log or http.log.</span><br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 22, 2013 at 5:14 AM, Anoop Saldanha <span dir="ltr"><<a href="mailto:anoopsaldanha@gmail.com" target="_blank">anoopsaldanha@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Jan 22, 2013 at 2:27 AM, Vincent Fang <<a href="mailto:vincent.y.fang@gmail.com">vincent.y.fang@gmail.com</a>> wrote:<br>

> Looking at the snort documentation, regex, and what you suggested, I<br>
> modified my rule to look like this now and I set the protocol to ip to catch<br>
> everything going out of my machine<br>
><br>
> alert ip $HOME_NET any -> any any (msg:"alert fired";<br>
> pcre:"/Host:\s.*?\.<a href="http://businessweek.com/H" target="_blank">businessweek.com/H</a>";)<br>
><br>
> and when I start up my suricata with just that 1 rule and visit business<br>
> week on the front page, no alerts show. I click on some subsequent links and<br>
> the fast.log still doesn't populate. Only after I click on a few more links<br>
> do I see the rules fire. But it's significantly less alerts than if I used<br>
> the rule<br>
><br>
> alert ip $HOME_NET any -> any any (msg:"alert fired";<br>
> content:"<a href="http://businessweek.com" target="_blank">businessweek.com</a>"; http_header;)<br>
><br>
> Can anyone explain why I'm not seeing it fire when I visit the front page?<br>
><br>
> My setup is running wireshark, suricata, and google-chrome on VMPlayer with<br>
> the OS being Fedora 17 and the host machine is Windows 7. I can't understand<br>
> why the number of alerts isn't matching the number of packets I see matching<br>
> in my wireshark with the filter http && ip.src == <a href="http://192.168.0.0/16" target="_blank">192.168.0.0/16</a> &&<br>
> http.host contains "<a href="http://businessweek.com" target="_blank">businessweek.com</a>"<br>
><br>
<br>
</div>Any chance that you accessed the website first with rule containing<br>
"content:"<a href="http://businessweek.com" target="_blank">businessweek.com</a>"" loaded, and then restarted the engine<br>
with pcre rule.  If so, the connection might have been still alive<br>
from the browser and it would have reused the same old flow and<br>
suricata may not have picked it up(midstream flow).<br>
<br>
To rule out any alert discrepancy from the above case, try this - Load<br>
both the rules at once, instead of conducting separate trials for each<br>
rule.  So your rules file would now contain -<br>
<div class="im"><br>
alert ip $HOME_NET any -> any any (msg:"alert fired";<br>
</div>content:"<a href="http://businessweek.com" target="_blank">businessweek.com</a>"; http_header; sid:1;)<br>
<div class="im">alert ip $HOME_NET any -> any any (msg:"alert fired";<br>
</div>pcre:"/Host:\s.*?\.<a href="http://businessweek.com/H" target="_blank">businessweek.com/H</a>"; sid:2;)<br>
<br>
Now run it through the traffic.  You should see an equal no of alerts<br>
for both sig 1 and sig 2.  If you don't, please capture a pcap and<br>
send it over.  Will have it checked.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> On Tue, Jan 15, 2013 at 3:11 AM, Anoop Saldanha <<a href="mailto:anoopsaldanha@gmail.com">anoopsaldanha@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Tue, Jan 15, 2013 at 3:30 AM, Vincent Fang <<a href="mailto:vincent.y.fang@gmail.com">vincent.y.fang@gmail.com</a>><br>
>> wrote:<br>
>> > Since I cannot rely on external ip addresses, I've been testing out a<br>
>> > new<br>
>> > rule that examines the http content, specificially the http header.<br>
>> > Looking<br>
>> > at the http-keyword page on redmine, this is the new rule I created for<br>
>> > testing<br>
>> ><br>
>> > alert http any any -> any any (msg:"rule fired";<br>
>> > content:"<a href="http://businessweek.com" target="_blank">businessweek.com</a>";<br>
>> > http_header;)<br>
>> ><br>
>> > Looking at the example, it explains it would look at the http header for<br>
>> > any<br>
>> > matching and create an alert if it matches. My one question is how<br>
>> > exactly<br>
>> > does it do the matching?<br>
>> ><br>
>> ><br>
>> > For instance, the <a href="http://businessweek.com" target="_blank">businessweek.com</a> address can appear in two places<br>
>> > based on<br>
>> > what I examined in the wireshark http packets<br>
>> ><br>
>> > Host: <a href="http://www.businessweek.com" target="_blank">www.businessweek.com</a>\r\n<br>
>> ><br>
>> > or<br>
>> ><br>
>> > Referer: <a href="http://www.businessweek.com/\r\n" target="_blank">http://www.businessweek.com/\r\n</a><br>
>> ><br>
>> > The examples shown in redmine only show it matching to the Host field<br>
>> > but<br>
>> > would this same rule also match if the address showed up in the Referer<br>
>> > field? Right now I'm running into issues with Chrome caching which is<br>
>> > fuddling my results so I can't tell based on my testing, but I was<br>
>> > wondering<br>
>> > if anyone had any experience and knows what Suricata is doing with the<br>
>> > content matching in the header field.<br>
>> ><br>
>> > Also is it possible to specify a wildcard * in the content:<br>
>> > "*<a href="http://businessweek.com" target="_blank">businessweek.com</a>" for matching?<br>
>><br>
>> No.<br>
>><br>
>> ><br>
>> > The end goal is for me to maybe specify that<br>
>> ><br>
>> > content:"Host: *<a href="http://businessweek.com" target="_blank">businessweek.com</a>"; http_header;<br>
>><br>
>> This would work instead, although you are stuck with the subdomain -<br>
>><br>
>> content:"Host: <a href="http://www.businessweek.com" target="_blank">www.businessweek.com</a>"; http_header;<br>
>><br>
>> Contents can have fixed strings only.<br>
>><br>
>> If you'd want to use wildcards you can use pcre -<br>
>><br>
>> pcre:"/Host: .*<a href="http://businessweek.com" target="_blank">businessweek.com</a>"/H";<br>
>><br>
>> The option "H" refers to matching on the http header filed.  We have<br>
>> other such pcre options to match on different http fields/buffers.<br>
>><br>
>> ><br>
>> > so that Suricata would match all packets going to this address. I ran a<br>
>> > test<br>
>> > with the modified rule<br>
>> ><br>
>> > alert http any any -> any any (msg:"rule fired";<br>
>> > content:"*<a href="http://businessweek.com" target="_blank">businessweek.com</a>"; http_header;)<br>
>> ><br>
>> > and fast.log isn't populating. I'm not sure if I'm doing it wrong or if<br>
>> > wildcards are not supported in Suricata rules.<br>
>> ><br>
>><br>
<br>
<br>
<br>
--<br>
Anoop Saldanha<br>
</div></div></blockquote></div><br></div>