Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Modify pcap_agent.tcl to support ip & vlan tagged interfaces #222

Closed
GoogleCodeExporter opened this issue Mar 24, 2015 · 11 comments
Closed

Comments

@GoogleCodeExporter
Copy link


pcap_agent.tcl is the sguil component that handles, among other things, the 
pcap detail extraction launched in wireshark from the sguil.tk console.  By 
default, pcap_agent.tcl can be configured to support interfaces with either 
straight IP or VLANs using the "set VLAN" parameter in pcap_agent.conf.

We can support both use cases and links running mixed ip/vlan traffic by 
modifying pcap_agent.tcl with:

   set tcpdumpFilter "(ip and $tmpTcpdumpFilter) or (vlan and $tmpTcpdumpFilter)"

just after the if loop and not using the "set vlan" tag in pcal_agent.conf.

Original issue reported on code.google.com by liam.ran...@gmail.com on 8 Feb 2012 at 10:35

@GoogleCodeExporter
Copy link
Author

Will deploy this in conjunction with updated tcpflow:
http://code.google.com/p/security-onion/issues/detail?id=148

Original comment by doug.bu...@gmail.com on 9 Feb 2012 at 1:40

  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Updated code section:

    if {$proto != "6" && $proto != "17"} {

        # Modified by Doug Burks for Security Onion
        set tmpTcpdumpFilter "${tmpFilter}host $srcIP and host $dstIP and proto $proto"

    } else {

        # Modified by Doug Burks for Security Onion
        set tmpTcpdumpFilter "${tmpFilter}host $srcIP and host $dstIP and port $srcPort and port $dstPort and proto $proto"

    }

        # Modified by Doug Burks for Security Onion
        set tcpdumpFilter "(ip and $tmpTcpdumpFilter) or (vlan and $tmpTcpdumpFilter)"

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 1:05

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Packaged:
/usr/local/lib/ruby/gems/1.9.1/gems/fpm-0.3.11/bin/fpm -s dir -t deb -n 
securityonion-pcap-agent -v 20120224 /usr/local/bin/pcap_agent.tcl

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 1:06

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Added the following to security-onion-upgrade.sh:


sed -i 's| |=|g' $CONF
source $CONF
if [ "$VERSION" = "20120222" ]; then
        NEW="20120224"
        echo "**********************************************"   | $LOGGER
        echo "* Upgrading from $VERSION to $NEW."               | $LOGGER
        echo "**********************************************"   | $LOGGER
        DIR="/nsm/backup/$NEW"
        mkdir -p $DIR                                           | $LOGGER
        cd $DIR

    apt-get -y remove tcpflow               >> $LOG

        echo "* Installing new pcap_agent.tcl"                  | $LOGGER
        FILE=securityonion-pcap-agent_"$NEW"_i386.deb
        wget -q http://sourceforge.net/projects/security-onion/files/$NEW/$FILE -O $FILE | $LOGGER
        dpkg -i $FILE                                           | $LOGGER

        echo "* Installing new tcpflow"                     | $LOGGER
        FILE=securityonion-tcpflow_"$NEW"-1_i386.deb
        wget -q http://sourceforge.net/projects/security-onion/files/$NEW/$FILE -O $FILE | $LOGGER
        dpkg -i $FILE                                           | $LOGGER

    nsm_sensor_ps-restart --only-pcap-agent

        sed -i "s|VERSION=$VERSION|VERSION=$NEW|g" $CONF        | $LOGGER
        echo "* Upgrade to $NEW complete."                      | $LOGGER
        echo 
fi

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 1:06

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Tested by:
Doug Burks
Liam Randall
Scott Runnels

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 1:06

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Doug with the release of this code we might want to add a little description 
for testing out the issue that we are trying to address.  Maybe drop a little 
description regarding monitoring complex interfaces- ie, interfaces with vlans, 
ip, and ethernet.  

Original comment by liam.ran...@gmail.com on 28 Feb 2012 at 1:22

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Yeah, I was planning on including the following in the blog post.  What do you 
think?

PROBLEM #1
Suppose you're monitoring traffic that has VLAN tags (in both directions).  By 
default, when you right-click the Alert ID and request the transcript/pcap, you 
would get nothing.  In order to get transcripts/pcaps to work correctly in 
Sguil, you would have to manually set VLAN to "1" in pcap_agent.conf.

PROBLEM #2
Suppose you're monitoring traffic that has VLAN tags in one direction but not 
the other.  When you right-click the Alert ID and request the transcript/pcap, 
you would only get the non-VLAN side of the flow.  If you set VLAN to "1" in 
pcap_agent.conf, you would then receive just the VLAN side of the flow.

SOLUTION
The updated pcap_agent.tcl and tcpflow allow Sguil to transparently support all 
cases of traffic with VLAN tags, without VLAN tags, and with mixed VLAN tags.  
When you right-click the Alert ID and request the transcript/pcap, you should 
now get the entire flow.

NOTE
If you had manually set VLAN to "1" in pcap_agent.conf, then you should set it 
back to the default of 0 and restart pcap_agent:
sudo nsm_sensor_ps-restart --only-pcap-agent

CAVEAT
httpry doesn't support VLAN tags, so if the above cases apply to you, you still 
won't see HTTP events in Sguil where VLAN tags are involved.  However, we'll 
soon be removing httpry in favor of Bro's HTTP logging, which does handle VLAN 
tags properly.

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 1:40

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Perfect.  The only addition might be to refer people to /nsm/bro/log:

"
If you're already running a recent version of SO then Bro is already configured 
to capture and generate your http logs by default- and it works seemlessly with 
IP, Vlan, QinQ, MPLS traffic and pretty much everything else we've thrown at 
it.  There are lots of ways to process and query the bro logs, however to get 
you started you could do something like this:

cd /nsm/bro/logs
find . -name 'notice*.*' -print0 | xargs -0 zgrep cnn.com
"

Original comment by liam.ran...@gmail.com on 28 Feb 2012 at 1:50

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

cd /nsm/bro/logs
find . -name 'notice*.*' -print0 | xargs -0 zgrep cnn.com

notice?  Did you mean http.log?

What are the advantages of using find/xargs over a simple zgrep?
zgrep "cnn.com" /nsm/bro/logs/*/http*

Might be simpler syntax for newbies.

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 2:07

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Yes, on the http instead of notice; errant cut and paste.

On the preference for searching there are a ton of different ways to get this 
done; I like using find because it let's me drill right down to a specific date 
range, etc.

Why don't we just provide a couple of examples for people to work off of:

find . -newermt '2012-02-26' -a -not -newermt '2012-02-28 22:00' -name 
'notice*.*' -print0 | xargs -0 zgrep Server_Found

Although, we may want to confirm that the .bro script that generates this code 
is included by default or change it out to a http query.




Original comment by liam.ran...@gmail.com on 28 Feb 2012 at 2:48

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Published:
http://securityonion.blogspot.com/2012/02/security-onion-20120224-now-available.
html

Original comment by doug.bu...@gmail.com on 28 Feb 2012 at 8:03

  • Changed state: Verified
  • Added labels: ****
  • Removed labels: ****

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant