Rapid Report Generation for the System Administrator

Using the Snort database as an example, I will show you how to use HTSQL as a tool to simplify generation of reports and dashboards.

You can view the demo at http://htsql.org/gallery/snort/index.html

Presenter:Dan Ferris, Prometheus Research, LLC
Date:May 13th, 2011
Location:BSDCan, Ottawa Ontario

Introduction

What's so Special about Snort Anyway

The (Simplified) Snort DB Schema

img/snortdb.png

What is HTSQL?

HTSQL Example

HTSQL Example

/iphdr{inet(ip_src)-, inet(ip_dst)}.limit(10)

Translated SQL:

SELECT ('0.0.0.0'::INET + "iphdr"."ip_src"),
       ('0.0.0.0'::INET + "iphdr"."ip_dst")
FROM "public"."iphdr" AS "iphdr"
ORDER BY 1 DESC, "iphdr"."sid" ASC, "iphdr"."cid" ASC
LIMIT 10

What can HTSQL do for you?

The Nitty Gritty

The Nitty Gritty

Python using HTSQL directly:

from htsql import HTSQL
from htsql.request import produce
htsql = HTSQL('pgsql://user:pw@localhost:5432/snort')
with htsql:
    for row in produce('/signature{sig_name}'):
        print "Signature: " + row[0]

The Nitty Gritty

Bash with curl:

IFS=$'\n'
HTSQL='http://snort.htsql.org/signature\{sig_name\}/:csv'
for line in $(curl -s $HTSQL | tr '\r\n' '\n')
do
    echo "Signature: $line"
done

The Nitty Gritty

Perl using LWP:

my $server = 'http://snort.htsql.org';
my $htsql = '/signature{sig_name}/:csv';
use LWP::Simple;
my $results = get $server . $htsql;

@results = split(/\r\n/, $results);

foreach $row (@results)
{
    print "Signature: $row\n";
}

The Nitty Gritty

Partial Output:

Signature: PSNG_UDP_PORTSCAN
Signature: (http_inspect) NON-RFC DEFINED CHAR
Signature: (http_inspect) U ENCODING
Signature: (http_inspect) OVERSIZE REQUEST-URI DIRECTORY
Signature: PSNG_UDP_DISTRIBUTED_PORTSCAN

Insta-Blacklist Example

$server='http://snort.htsql.org';
$htsql='/distinct(event{inet(iphdr.ip_src)}
?signature.sig_priority=1)/:csv';

use LWP::Simple;

$result = get $server . $htsql;
@result = split(/\r\n/, $result);

shift(@result); #get rid of the column names

foreach $ip (@result)
{
    print "Blocking $ip\n";
    system("ipfw add deny all from $ip to any");
}

Brief HTSQL tutorial

Display the iphdr table from the snort DB:

/iphdr

Brief HTSQL tutorial

/iphdr{ip_src, ip_dst}

/iphdr{inet(ip_src), inet(ip_dst)}

/iphdr{inet(ip_src)-, inet(ip_dst)}

Brief HTSQL tutorial

/iphdr{inet(ip_dst)}?inet(ip_src)='216.243.150.122'

/tcphdr{tcp_dport}?tcp_dport='21'|tcp_dport='139'

/tcphdr{tcp_dport}?tcp_dport!='21'

Brief HTSQL tutorial

/event{signature.sig_name}?cid='1234'

/tcphdr{tcp_sport, inet(event.iphdr.ip_src)}?cid='1234'

Brief HTSQL tutorial

/count(iphdr?inet(ip_src)='10.90.90.91')

/distinct(iphdr{inet(ip_src)})

/event.limit(10)

/iphdr{inet(ip_src) :as 'IP Source'}

Formatters

Learning Curve

Licensing and Database Support

Installation

Running HTSQL

/usr/local/bin/htsql-ctl server pgsql://user:pw@localhost:5432/snort

/usr/local/bin/htsql-ctl shell pgsql://user:pw@localhost:5432/snort

HTSQL Security

Development Status

HTRAF

img/htraf.png

HTRAF Development Status

Snort Dashboard Demo

http://htsql.org/gallery/snort/index.html

Conclusion

Questions?

Questions?