<font size="4"><font face="times new roman,serif">Hi, </font></font><div><font size="4"><font face="times new roman,serif"><br></font></font></div><div><font size="4"><font face="times new roman,serif">I do follow the Binpac sample analyzer. And I also notice this part of code which use the value of is_orig to decide whether the packet is the request. <br>

</font></font><div>
<font face="&#39;times new roman&#39;, serif" size="4"><br></font></div><div><font face="&#39;times new roman&#39;, serif" size="4">When Bro is used to parse network traffic on the network card, it is obvious to see what traffic are coming in and what traffic are going out. But i am using the traffic dump to test, so how can Binpac know which traffic is coming in and going out? I use the Wireshark and actually, wireshark can tell whether the packet is a request or response. </font></div>


<div><font face="&#39;times new roman&#39;, serif" size="4"><br></font></div><div><font face="&#39;times new roman&#39;, serif" size="4">Also according to your logic, the Bro considers the originator of the traffic as the client and then this makes sense to my situation. Since the first packet in that dump is a response (without any request before it) and Binpac will consider the source of the packet as the client and the receiver as the server, then this can successfully fool the Binpac to think that this packet is a request. Then the exception can happen.  </font></div>


<div><font face="&#39;times new roman&#39;, serif" size="4"><br></font></div><div><font face="&#39;times new roman&#39;, serif" size="4">Best,</font></div><div><font face="&#39;times new roman&#39;, serif" size="4"><br>
</font></div><div><font face="&#39;times new roman&#39;, serif" size="4">Hui</font></div><div><font face="&#39;times new roman&#39;, serif" size="4"><br></font><div class="gmail_quote">
On Tue, Jul 12, 2011 at 8:09 AM, Robin Sommer <span dir="ltr">&lt;<a href="mailto:robin@icir.org" target="_blank">robin@icir.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><br>
On Mon, Jul 11, 2011 at 22:10 -0700, you wrote:<br>
<br>
&gt; tell whether the parsing packet is a &quot;request&quot; or a &quot;response&quot;. For example,<br>
&gt; in HTTP protocol, the http header will include such information.<br>
<br>
</div>While that&#39;s right, BinPAC/Bro is actually not using that information<br>
to decide which side it&#39;s parsing. Generally, Bro always considers the<br>
originator of a connection to be the client side[1], and then it<br>
drives BinPAC parsing accordingly.<br>
<br>
Take a look at http-procotol.pac, there&#39;s this piece:<br>
<br>
    type HTTP_PDU(is_orig: bool) = case is_orig of {<br>
        true -&gt;         request:        HTTP_Request;<br>
        false -&gt;        reply:          HTTP_Reply;<br>
};<br>
<br>
And in http-analyzer.pac, there is:<br>
<br>
    connection HTTP_Conn(bro_analyzer: BroAnalyzer) {<br>
        upflow = HTTP_Flow(true);<br>
        downflow = HTTP_Flow(false);<br>
    };<br>
<br>
    flow HTTP_Flow(is_orig: bool) {<br>
        flowunit = HTTP_PDU(is_orig) withcontext (connection, this);<br>
        ...<br>
<br>
    }<br>
<br>
<br>
When Bro passes in data, it tells BinPAC which of these flows to use.<br>
>From HTTP-binpac.cc:<br>
<br>
    void HTTP_Analyzer_binpac::DeliverStream(int len, const u_char* data, bool orig)<br>
        {<br>
        ....<br>
        // orig is true here if it&#39;s originator-side data.<br>
        interp-&gt;NewData(orig, data, data + len);<br>
        }<br>
<br>
There&#39;s a skeleton Bro analyzer on the web page that&#39;s based on<br>
binpac. If you us that skeleton, you should pretty much automatically<br>
get this direction stuff right. See<br>
<a href="http://www.bro-ids.org/development/binpac-sample-analyzer.html" target="_blank">http://www.bro-ids.org/development/binpac-sample-analyzer.html</a><br>
<br>
Robin<br>
<br>
[1] With a few additional heuristics for corner-cases.<br>
<font color="#888888"><br>
<br>
--<br>
Robin Sommer * Phone <a href="tel:%2B1%20%28510%29%20722-6541" value="+15107226541" target="_blank">+1 (510) 722-6541</a> * <a href="mailto:robin@icir.org" target="_blank">robin@icir.org</a><br>
ICSI/LBNL    * Fax   <a href="tel:%2B1%20%28510%29%20666-2956" value="+15106662956" target="_blank">+1 (510) 666-2956</a> *   <a href="http://www.icir.org" target="_blank">www.icir.org</a><br>
</font></blockquote></div><br></div>
</div><br clear="all"><br>-- <br>Hui Lin<br>Research Assistant<br>DEPEND Research Group, ECE Department<br>University of Illinois at Urbana-Champaign<br><a href="mailto:hlin33@illinois.edu" target="_blank">hlin33@illinois.edu</a><br>