New Sguil Scripts and VM

I have not been happy with the performance of FreeBSD 6.0 under VMware Workstation or VMware Server Beta. I thought some workarounds helped, but that wasn't really the case.

Also, since releasing my original Sguil installation script, I've wanted to break it into scripts for the Sguil sensor, database, server, and client.

I decided today to kill two birds with one stone. First, I broke the master script into the following smaller scripts.

All of them are available in this archive: sguil_install_scripts.tar.gz.

These are not pretty. There is no error checking. There is no interaction. You will have to make modifications to get them to work flawlessly in your environment.

Important: As written these scripts download packages for FreeBSD 5, not 6. You can modify this.

These will work best "out of the box" if you want to install all Sguil components on a single host. This is the case because I did not make any adjustments to have MySQL listen on a public interface, for example.

So what good are these? Well, you can now see exactly what software is required for each Sguil component. It's possible I may have erred on the side of including one too many packages for a certain component, but I believe this configuration will work. I did some testing to iron out bugs, but I can't guarantee success.

Using these scripts, I created a new Sguil 0.6.1 complete (sensor/database/server/client) VM on FreeBSD 5.4 RELEASE. The following shows how I invoked the scripts, and the adjustments I made to get the patches to work on this VM.

First I downloaded the script collection.

taosecurity:/root# fetch
sguil_install_scripts.tar.gz 100% of 2552 B 1716 kBps
taosecurity:/root# tar -xzvf sguil_install_scripts.tar.gz
x scripts
x scripts/
x scripts/
x scripts/
x scripts/
x scripts/
x scripts/
taosecurity:/root# cd scripts/
taosecurity:/root/scripts# ls
taosecurity:/root/scripts# chmod +x *.sh

Next I started with the sensor installation.

taosecurity:/root/scripts# ./
Starting Sguil sensor installation.
Sguil server installation finished.

You must modify the following patches in /usr/local/etc/nsm
to match your environment.


When done, run

Next, modify the start scripts to match your environment.

These are in the /home/sguil directory:

You'll notice the end of the script suggests making changes to patches to match your environment. Here are the common changes:

  • sensor_agent.conf.patch: change hostname from 'gruden' to 'your_hostname'

  • snort.conf.patch: change 'var RULE_PATH /nsm/rules/gruden' to 'nsm/rules/your_hostname'

  • barnyard.conf.patch: change hostname from 'gruden' to 'your_hostname'; change interface from 'lnc1' to whatever your system uses

  • sancp.conf.patch: probably no changes

  • change hostname from 'gruden' to your_hostname; change interface from 'lnc1' to whatever your system uses

Once I made changes I needed, I ran

taosecurity:/root/scripts# ./
Patching Sguil sensor configuration and logging scripts.

Hmm... Looks like a unified diff to me...
The text leading up to this was:
|--- sensor_agent.conf Wed Dec 28 14:57:30 2005
|+++ sensor_agent.conf.diff Wed Dec 28 14:58:33 2005
Patching file sensor_agent.conf using Plan A...
Hunk #1 succeeded at 13.
Hunk #2 succeeded at 22.
Hunk #3 succeeded at 55 (offset 6 lines).
Hmm... Looks like a unified diff to me...
The text leading up to this was:
|--- snort.conf Wed Dec 28 14:30:42 2005
|+++ snort.conf.diff Wed Dec 28 15:07:23 2005
Patching file snort.conf using Plan A...
Hunk #1 succeeded at 107.
Hunk #2 succeeded at 621.
Hmm... Looks like a unified diff to me...
The text leading up to this was:
|--- barnyard.conf Wed Dec 28 14:30:42 2005
|+++ barnyard.conf.diff Wed Dec 28 15:00:38 2005
Patching file barnyard.conf using Plan A...
Hunk #1 succeeded at 23.
Hunk #2 succeeded at 38.
Hunk #3 succeeded at 133.
Hmm... Looks like a unified diff to me...
The text leading up to this was:
|--- sancp.conf Wed Dec 28 14:30:42 2005
|+++ sancp.conf.diff Wed Dec 28 15:01:49 2005
Patching file sancp.conf using Plan A...
Hunk #1 succeeded at 45.
Hmm... Looks like a unified diff to me...
The text leading up to this was:
|--- Wed Dec 28 20:11:54 2005
|+++ Wed Dec 28 20:12:39 2005
Patching file using Plan A...
Hunk #1 succeeded at 28.

The sensor installation provides several start scripts that must also be adjusted for your environment:

  • /root/ change 'gruden' to 'your_hostname' and 'lnc1' to your sniffing interface

  • /root/ change 'gruden' to 'your_hostname' and 'lnc1' to your sniffing interface

  • /home/sguil/ change 'gruden' to 'your_hostname'

At this point I was ready to install the Sguil database. I broke this into two scripts because I needed a delay to ensure MySQL was running before taking certain actions.

taosecurity:/root/scripts# ./
Starting Sguil database installation, part 1.
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at
Run after MySQL is running.
taosecurity:/root/scripts# Starting mysqld daemon with databases from /var/db/mysql
taosecurity:/root/scripts# sockstat -4 | grep 3306
mysql mysqld 1187 10 tcp4 *:3306 *:*

Now I start part 2 of the database installation after checking to be sure MySQL is listening on port 3306. Note that the script edits /etc/rc.conf to make MySQL listen on localhost on port 3306. You can also do the following:

# mysqladmin -p shutdown
Enter password:

To restart the server:

mysqld_safe --bind-address= --user=mysql &

taosecurity:/root/scripts# ./
Starting Sguil client installation, part 2.

| Tables_in_sguildb |
| history |
| nessus |
| nessus_data |
| portscan |
| sensor |
| sessions |
| status |
| user_info |
| version |
Sguil database installation complete.

The sensor and database are done. On the the Sguil server. You'll notice I install mysqltcl from the ports tree. I am no longer hosting a package for this. You'll also be prompted to enter a password for the Sguil client. This is proof that mysqltcl and sguild are working.

taosecurity:/root/scripts# ./
Starting Sguil server installation.
=> Attempting to fetch from
mysqltcl-3.01.tar.gz 100% of 164 kB 62 kBps
===> Extracting for mysqltcl-3.01
=> MD5 Checksum OK for mysqltcl-3.01.tar.gz.
===> Patching for mysqltcl-3.01
===> Applying FreeBSD patches for mysqltcl-3.01
===> mysqltcl-3.01 depends on shared library: tcl84 - found
===> mysqltcl-3.01 depends on shared library: mysqlclient.15 - found
===> Configuring for mysqltcl-3.01
===> Building for mysqltcl-3.01
Create a Sguil client user password when prompted.
Please enter a passwd for sguil:
Retype passwd:
User 'sguil' added successfully
SGUILD: Exiting...
Sguil server installation finished.

You must modify /usr/local/etc/nsm/sguild.conf.patch
to match your environment.

When done, apply it:

patch -p0 < sguild.conf.patch

As the end of the script notes, you should patch /usr/local/etc/nsm/sguild.conf. The /usr/local/etc/nsm/sguild.conf.patch by default should work as is for those with a local installation.

taosecurity:/root/scripts# cd /usr/local/etc/nsm/
taosecurity:/usr/local/etc/nsm# patch -p0 < sguild.conf.patch
Hmm... Looks like a unified diff to me...
The text leading up to this was:
|--- sguild.conf Wed Dec 28 16:29:21 2005
|+++ sguild.conf.diff Wed Dec 28 16:30:34 2005
Patching file sguild.conf using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 30.
Hunk #3 succeeded at 42.
Hunk #4 succeeded at 71.

At last we are ready to install the client. It's fairly simple.

taosecurity:/root/scripts# ./
Starting Sguil client installation.
Sguil client installation finished.

I'd like to share a few words on requirements for running these scripts.

  • Make sure you have users sguil and analyst on the system.

  • With FreeBSD 5.4, I applied the User installation. I manually extracted the ports tree by downloading it from and extracting it in /usr. I did that because the ports tree on the CD is 10 months old.

  • If you create a system with DHCP, make sure you have an entry in /etc/hosts for and the name of your sensor, like 'taosecurity'.

Here are the open ports on a system where all components are running. I omit sshd.

taosecurity:/home/analyst$ sockstat -4 | grep -v sshd
sguil barnyard 717 12 tcp4
sguil tclsh8.4 701 3 tcp4
sguil tclsh8.4 701 4 tcp4 *:*
sguil tclsh8.4 701 6 tcp4
sguil tclsh8.4 672 12 tcp4 *:7734 *:*
sguil tclsh8.4 672 13 tcp4 *:*
sguil tclsh8.4 672 14 tcp4
mysql mysqld 505 10 tcp4 *:*
root sendmail 430 3 tcp4 *:*
root syslogd 315 6 udp4 *:514 *:*
root dhclient 247 4 udp4 *:68 *:*

I plan to post the new VM when I get a chance.


Anonymous said…
Thanks for the scripts Richard, I intend on having a look at them over the weekend. You mentioned in the post that the scripts can be modified for FreeBSD 6. Do you have any pointers in relation to accomplishing this?
The only difference for FreeBSD 6 is the PACKAGESITE environment variable. Comment out the one for freebsd-5-stable and uncomment the one for freebsd-6-stable.

If used the scripts on both platforms and they seem to work fine.
Anonymous said…
First, thanks for taking the time to help us Sguil newbies get this software installed with minimal effort. It was a definite help for me.

I recently used your script to help install Sguil on a brand new FreeBSD box. Due to its SATA chipset, I had to use the FreeBSD 6.1BETA4 release. One thing I think you left out of your script/instructions is the creation of the Sguil user.

I found one of your earlier posts regarding the Sguil instructions that helped me get the Sguil user created.

Also, unless I missed something, how do you enable Snort to start after a system reboot?

Thanks for the feedback.

Check out /usr/local/etc/rc.d/ for info on how to use rc.d to start Snort automatically.
Anonymous said…
Just to leave a quick follow-up comment, I upgraded my system using these commands:

portsnap fetch
portsnap update
portupgrade -varRPP
portupgrade -varR

Now the sguil daemon runs, but it doesn't open port 7734 for the sguil client to connect to. I've exhausted my troubleshooting skills to get this working again.

I'm going to try a reinstall as a last resort, but I wanted to post a small comment just in case this is useful to you.

Anonymous said…
Where can I find this scrips now?
Always start here, where you'll see Sguil Installation Script. Note they probably need another round of modification and have not been tested since first written.
Anonymous said…
Thanks, I'm just going to give it a try on freebsd 5.5.
Anonymous said…
I'm having a problem with the startup scripts. It seems they are not pulling in the variables. For instance in the barnyard start up script

cd /usr/local/etc/nsm/

barnyard -c barnyard.conf -d /nsm/$SENSOR/ -g -s -f snort.log -w /nsm/$SENSOR/waldo.file

It doesn't then look for the inside the /nsm/taosecurity. It stays in the /usr/local/etc/nsm dir and looks for it. The snort startup script is doing the same. What am I doing wrong here?
I'm using freebsd 5.5
Hi Kevin,

You're in the /usr/local/etc/nsm directory when you tell barnyard to read and The -d flag tells barnyard where to find spool files, not anything else.

Popular posts from this blog

Five Reasons I Want China Running Its Own Software

Cybersecurity Domains Mind Map

A Brief History of the Internet in Northern Virginia