Setup a Sguil framework using ports under OpenBSD

From NSMWiki
Jump to: navigation, search

These instructions are written assuming use of OpenBSD 4.2 and sensor named 'sensor1' with all components residing on the same box.

If you need a concise guide to get started with OpenBSD, take a look at this page. It's intended for a VM install but also lends itself well to this project. Just go to OpenBSD download the latest Install42.iso and follow the instructions from the this link.

Next you need 4.2 ports tree:

cd /usr
ftp -V
tar zxvf ports.tar.gz

Sguil client

cd /usr/ports/devel
ftp -V
tar xvf tclx-8.4.tar
cd /usr/ports/security
ftp -V
tar xvf sguil-0.6.1.tar
cd sguil/client && make install

executing "" should run sguil client out of box. Configuration file used for is /etc/sguil.conf, if ~/sguil.conf does not exist.

Optionally you can install wireshark:

cd /usr/ports/net
ftp -V
tar xvf wireshark-0.99.6_4.2.tar
cd wireshark && make install

Sguil sensor

mkdir -p /nsm/sguild_data/rules/sensor1
mkdir -p /nsm/snort_data/sensor1/sancp
mkdir -p /nsm/snort_data/sensor1/portscans
cd /usr/ports/devel
ftp -V
tar xvf tclx-8.4.tar
cd /usr/ports/net
ftp -V
ftp -V
tar xvf barnyard-0.2.0.tar
tar xvf sancp-1.6.1.tar
cd /usr/ports/security
ftp -V
tar xvf sguil-0.6.1.tar
cd sguil/sensor && make install

install snort from ports or packages as you want: (Note: If you do not already have an oinkcode, you can register for free at to get one)

cd /usr/ports/net/snort && make install
cd /tmp && ftp -V*oinkcode*/snortrules-snapshot-CURRENT.tar.gz
tar zxvf snortrules-snapshot-CURRENT.tar.gz rules
ftp -V
tar zxvf bleeding.rules.tar.gz
cd rules && ls bleeding*.rules | awk '{print "include $RULE_PATH/" $1}' > bleeding.conf
mv * /nsm/sguild_data/rules/sensor1/
cp /nsm/sguild_data/rules/sensor1/ /etc/snort/
cd /etc/snort/
cat >>

Unless using SamSnort, edit /nsm/sguild_data/rules/sensor1/bleeding.conf


In /etc/snort/snort.conf check for following lines:

var RULE_PATH /nsm/sguild_data/rules/sensor1
output log_unified: filename snort.log, limit 128
preprocessor perfmonitor: time 300 file /nsm/snort_data/sensor1/snort.stats pktcnt 10000
config detection: search-method lowmem
include $RULE_PATH/bleeding.conf

In following configuration files you have to make appropriate changes:



config interface: <interface>
config hostname: sensor1
output sguil


set LOG_DIR /nsm/snort_data
set HOSTNAME sensor1

MySQL server

Install mysql server from ports or packages as you want:

pkg_add mysql-server
/usr/local/bin/mysqld_safe &
mysqladmin -u root -p password 'newrootpassword'
Enter Password: <enter>

If MySQL resides on remote box:

mysql -u root -p
[enter 'newrootpassword']
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'newrootpassword';

Sguil server

cd /usr/ports/devel
ftp -V
tar xvf tclx-8.4.tar
cd /usr/ports/databases
ftp -V
tar xvf mysqltcl-3.02.tar
cd /usr/ports/security
ftp -V
tar xvf sguil-0.6.1.tar
cd sguil/server && make install

Modify /etc/sguild/sguild.conf for right database configuration

set RULESDIR /nsm/sguild_data/rules
set DBPASS "newrootpassword"
set DBHOST localhost
set DBPORT 3306
set DBUSER root
set LOCAL_LOG_DIR /nsm/sguild_data/archive

Start everything up.

chown -R _sguil /nsm/*

On sguil server, for first time you will have to hit 'y':

# sudo -u _sguil sguild
pid(438)  Loading access list: /etc/sguild/sguild.access
pid(438)  Sensor access list set to ALLOW ANY.
pid(438)  Client access list set to ALLOW ANY.
pid(438)  Email Configuration:
pid(438)    Config file: /etc/sguild/
pid(438)    Enabled: No
pid(438)  Connecting to localhost on 3306 as root
pid(438)  MySQL Version: version 5.0.45-log
pid(438)  Error: mysqluse/db server: Unknown database 'sguildb'
The database sguildb does not exist. Create it ([y]/n)?: y
Path to create_sguildb.sql [/usr/local/share/sguild/sql_scripts/create_sguildb.sql]:
Creating the DB sguildb...Okay.
Creating the structure for sguildb: .......

On sguil sensor:

sh /etc/ start
snort -l /nsm/snort_data/sensor1 -c /etc/snort/snort.conf -A none -m 122 -u _sguil -g _sguil -t /nsm/snort_data/sensor1 -i <yournetworkinterface>
sancp -d /nsm/snort_data/sensor1/sancp/ -c /etc/sancp_sguil.conf -u _sguil -g _sguil -i <yournetworkinterface>
sudo -u _sguil barnyard -c /etc/barnyard.conf -d /nsm/snort_data/sensor1 \
-g /etc/snort/ -p /etc/snort/classification.config \
-s /etc/snort/ -f snort.log -w /nsm/snort_data/sensor1/waldo.file

add to crontab: crontab -e

*/15 * * * * /bin/sh /etc/ restart

On Server, add user to Sguild

sguild -adduser <username>