SnortSMS Quick (and dirty) Setup Guide

Ver 1.7.8 - Last Updated 10/06/2007

  1.  System Requirements

    This is a quick guide to help you setup a functional SnortSMS IDS network. It will be assumed you have at least two unix-based systems available to fuction as the SnortSMS Collector and the SnortSMS IDS Sensor (although these could be technically the same single system).

    Here's what should be on each system:

    Notes:

    As you can see the SnortSMS network is collection of various technologies working together. Although you could replace some of these technologies with other variants, the overall concept remains. The custom piece that "glues" it all together is the SnortSMS Collector Website and the SnortSMS Web Portal Agent PHP scripts.

    The SnortSMS IDS Sensor has an Agent which uses a web portal listener to receive and send information to and from the SnortSMS Collector. The Agent scripts are written in PHP and thus require some type of web server on the sensor itself to listen for incoming requests from the Collector. You could choose to use Apache web server, but we have opted to use 'lighttpd' as it has a very small footprint (just under 1MB) and can support HTTP authentication, php-cgi, and SSL.

    Barnyard is an optional tool which allows Snort alerts to be propagated to a central database in the background. Although Snort has the functionality to write to the event database directly, we recommend Barnyard as it is more reliable and frees Snort of latency and fail-over issues which could result in dropped events.

    A quick note about reducing overall file space on the sensor system. The sensor system shouldn't need Perl. Depending on which Unix OS you are running, you might want to consider removing or not installing Perl as it can easily consume 50+MB of harddrive space. This is completely optional, but worth mentioning if you are interested in reducing your sensor's overall OS footprint. Also, if you plan to use custom Perl scripts on the sensor, consider rewriting them in PHP as PHP only takes up about 7MB and shares much of the same fundamental capabilities.

  2.  SnortSMS IDS Sensor Setup

    Prerequisites

    It will be assumed you have an available server established with all the software installed and configured as stated in the above SnortSMS IDS Sensor "System Requirements" - (also Barnyard and MySQL Client libraries if you desire to propagate Snort Events to a remote central database).

    The sensor system requires a Web portal listener for the Agent scripts. This will partly cover setting up the web server listener and the agent scripts. Snort, PHP and other requirements should have been already configured by this time.

    Configuring lighttpd

    LigHTTPd requires a single config file we will call 'lighttpd.conf'. A sample file is provided with SnortSMS Collector distribution under the 'Agent' sub-directory. The important settings you will need to note are the web-root path, the listening port, and if your are choosing SSL (HTTPS) mode or not. Refer to the lighttpd documentation for how to configure and start the server.

    It's also important to run lighttpd web daemon as 'root' user since root priviledge are required to start/stop daemons on the sensor. This is done by not specifying and user/group in the config file.

    The agent should be protected by http basic authentication. Our sample lighttpd.conf file already has this enable, however you will need to create the user/password file. It is simply a plain text file with userid and password seperated by a colon.
    sensor:mypassword

    Installing the SnortSMS Agent

    The SnortSMS Agent is designed to reside on the remote Snort sensor. This Agent allows the SnortSMS Collector server to communicate and remotely control the sensor. The Agent is simply a PHP script called 'agent.php' (a copy can now be found included in the SnortSMS Collector distribution under the 'Agent' sub-directory). Simply copy this PHP script to your sensor's web-root directory as defined in your lighttpd config file.

    Testing the SnortSMS Agent

    It is possible to test the Agent directly via a web browser. Point your web browser to:

    http://<userid>:<password>@<sensorip>:<port>/agent.php?ac=test

    Be sure to use the correct protocol (http/https), the correct login/password, sensor IP, and port.
    For example:

    UserID = snortsms
    Passwd = crazy
    IP = 192.168.1.50
    Port = 10000

    https://snortsms:crazy@192.168.1.50:10000/agent.php?ac=test

    If all is configured correctly, you should see a simple webpage called "SnortSMS Agent Test Page". If not, well then double check the web server config file and network/firewall possbile restrictions.

  3.  SnortSMS Collector Setup

    Prerequisites

    We assume you have an available server established with all the software installed and configured as stated in the above SnortSMS Collector "System Requirements".

    Insure Apache is properly configured and you have configure a web-root location.

    Installing the SnortSMS Collector Website

    1. Extract the SnortSMS archive files to a preferred web-root location. ( For example: /usr/local/www/snortsms )
    2. Insure that the subdirectory "conf/" and the file "conf/conf.php" are read/writeable by the webserver (www).
      	# chown :www conf/ conf/conf.php
      	# chmod 775 conf/
      	# chmod 664 conf/conf.php
    3. Important: Your PHP server configuration might need some tweaking. Here are a few settings for your 'php.ini' file:
      	short_open_tag = On
      	magic_quotes_gpc = Off
      	magic_quotes_runtime = Off
      	max_execution_time = 120
      	max_input_time = 120
      	memory_limit = 100M 
      	post_max_size = 20M
      	upload_max_filesize = 20M
      	include_path = ".:/usr/local/share/pear"
    4. SnortSMS needs a temporary place to write files. Take note of this location for your Global Configuration Settings for later on. We suggest you create a subdirectory within your system's temp directory:
      	# mkdir /var/tmp/snortsms
      	# chmod 1777 /var/tmp/snortsms
    5. Verify your Apache webserver settings are correct and pointing to this new web-root location. ( For example: /usr/local/www/snortsms )

    Creating the SnortSMS Database

    1. Create a new database, preferably called 'SNORTSMS'. Use the supplied MySQL dump to restore the database tables.
      	# mysql -u root -p < {snortsms_source}/schema/SNORTSMS.mysql
    2. Create a new database user 'snortsms' (or use an existing user) and grant permissions to the SNORTSMS database. Take note of the username and password for your Global Configuration Settings for later on.

    Creating the Snort Alert Database (optional)

    If you would like a central database where all Snort sensors can send the Alert events to, you can create a Snort database on the SnortSMS collector or an alternate server.

    1. Create a new database, preferably called 'SNORT'. The Snort distribution source files include an automated script which can build out the proper table structure.
      Use the supplied MySQL script to create the database tables:
      	# mysql -u root -p < {snort-x.x.x}/schemas/create_mysql
    2. Create a new database user 'snortsms' (or use an existing user) and grant permissions to the SNORTSMS database. Take note of the username and password for your Global Configuration Settings.
    3. Modify the Snort Event Database

      Note: If you plan to use the SnortSMS Alert Browser to view incoming alerts, you will need to modify Snort's default database.

    4. Modify the 'events' table in your SNORT central database by adding the 'viewed' field. Execute the following from your mysql console:
      	mysql> use {your snort db name};
      	mysql> alter table event add column viewed tinyint (1);
      Or execute the script we've supplied with SnortSMS:
      	# mysql -d {SnortDB} -u root -p < {snortsms_source}/schema/SNORT_DB_mod.mysql
      	
  4.  Configuring the SnortSMS Web Application

    Prerequisites

    At this juncture, you should have a SnortSMS Collector and at least one SnortSMS sensor established and functional. We will now walk you through a few steps required to get SnortSMS configured and start managing your Snort sensor(s).

      Configure SnortSMS global settings

    1. Browse to the SnortSMS web location. If all is well you should see the SnortSMS interface.
    2. For your 1st time logging in, Userid -> 'admin' Password -> 'admin'.
    3. On the top menu, under "Settings", click the "Global Settings".
    4. Enter the database settings from the previous database section.
    5. Verify the remainder of the settings insuring all paths are correct for your system.
    6. On the top menu, under "Settings", click the "Test Configuration". Be sure to resolve any errors reported here before continuing.

      Create a Snort Daemon Profile
      You MUST create at least one Snort Daemon Profile. This is used to tell SnortSMS how to launch the snort process on the remote sensor.

    7. Browse to Libraries -> Snort Daemon Profiles.
    8. Click 'New Snort Profile' link.
    9. Give it a name, set the interface snort will sniff, and path to where the snort.conf file will reside on the sensor (be sure this path exists).
    10. Be sure you enter the correct path to the Snort executable on your sensors.
    11. Also be sure the PID file and path are valid.
    12. Provide the correct values foreach of the Snort command line switches (arguments).
    13. Now save the profile.

      Populating the libraries
      Before you can assign configurations to your sensors, you must first populate the SnortSMS configuration libraries. The easiest way to fill up the libraries is to import the various Snort snapshot tarball files. The Snort source code tarball contains much of the default varaibles and config directives. There are also many VRT and Community rules now available in seperate files.

      So start by importing the Snort source tarball (i.e. Snort-x.x.x.tar.gz). Don't worry, SnortSMS will only find what it needs. Next, import any of the Rule distribution tarballs (i.e. Community-Rules-x.x.tar.gz). You can either download it to your local desktop or import it from the web.

    14. Click on the "Import" link under the "Libraries" menu.
    15. Enter the URL or tarball file, then press "Import".

      This will parse the tarball file, detecting any and all rules and directives, thus populating the SnortSMS libraries accordingly. Once this is done, you should be able to browse the libraries and verify the imported resources.

      Create a Rule Profile
      Now that your resource libraries are full, we suggest you 1st create at least one rule profile. You cannot assign rules directly to sensors, only rule profiles can be assigned to each sensor.

    16. Browse to Libraries -> Rules -> Rule Profiles.
    17. Click on the "New Profile" link, enter a profile name and save the new profile.
    18. Now, click the "Pick" link on your profile to browse through the rule libraries and assign rules you want to this profile.

      Adding Sensors
      Now you are ready to start adding sensor profiles into the SnortSMS console.

    19. Click on the Sensors -> Administration Console link.
    20. Click "Add Sensor".
    21. Enter the Sensor name and save. Note: Do not include special characters.
    22. Click on the individual tabs to configure the rest of the sensor properties. Remember to 'Update' each tab settings before moving on to the next tab.
    23. TIP: If you have multiple sensors to add which are similar, configure at least one sensor, then use the 'Clone Sensor' link on the Administration Console.
    24. It might be a good idea to check communications between SnortSMS and the sensors. Click on the "Status" tab in Sensor Administration, and clicj on 'Refresh Status'. If everything is working correctly, you should get a green connection indication and Sensor statistics.
    25. Verify communication to the sensor's Snort daemon by clicking on the 'info' link.
    26. If communications are working, you may now start pushing out the configurations to the sensors.

      Testing
      At this point, SnortSMS should be properly configured. We also assume you have at least one functional Snort-base sensor defined. From the Administration Console, click anywhere on your sensor line. You should be able to get statistical data from the 'Status' tab. There is also a "Test Configuration" under the Settings menu. This is very helpful in determining common issues.

  5.  Troubleshooting - FAQ

    Issue: I get the error:
    "Warning: require_once(DB.php) [function.require-once]: failed to open stream: No such file or directory in /www/snortsms/FMK_Hooks.php"
    Resolution:
    • This is a common error when your system does not have PEAR with DB installed/configured correctly. Recommend you insure the proper PEAR DB packages installed and proper PHP include paths to the php.ini file.

    Issue: I get an error while trying to save the Global Settings.
    Resolution:
    • Be sure the "conf.php" file has read/write permissions by the webserver. * This also applies to the parent directories as well.

    Issue: SnortSMS Collector cannot connect to the remote sensor agent.
    Resolution:
    • Are you using the correct protocol (http/https)?
    • HTTP authentication is correct?
    • Test connectivity via the web browser (refer to Sensor Test method in this Quick Start Guide).
    • Are there any firewall or ACL issues between the Collector and the Sensor?
    • Check the SnortSMS Collector log file (if configured) for clues?

    Issue: I get a database connection error.
    Resolution:
    • Verify your database server and table installation. Insure you have the correct username and password configured in SnortSMS Global Settings and in your database permissions section.

    Issue: I get an error "Missing DB.php".
    Resolution:
    • Be sure the PEAR-DB abstraction layer is properly installed.
    • Check that your PHP "include" path is correct and includes the path to the PEAR files.

    Issue: Importing Snort snapshot file failed.
    Resolution:
    • Verify your path setting for temporary files in 'SnortSMS Global Settings'.
    • Verify your temp path is read/writable by your web server userid (chmod 1777 /tmp/path).
    • Verify correct path for 'tar' on your web server in 'SnortSMS Global Settings'.
    • Verify your max upload, max memory, and max execution parameters in 'php.ini' config file (refer to Quick Start Guide).

    Issue: Snort Fails to start via SnortSMS.
    Resolution:
    • In Snort Daemon Profiles section, verifiy path to snort executable for the sensor is correct.
    • In Snort Daemon Profiles section, verifiy path to PID file on sensor.
    • Take a look at the Snort command trace file. Should be located on the sensor in the snort config directory under the filename 'SMS_snort.<interface>.conf.CMD'.
      The contents of this file stores the command syntax used to start snort. For troubleshooting you should be able to execute this command line locally on the sensor.

    Issue: Barnyard Fails to start via SnortSMS.
    Resolution:
    • In Barnyard Daemon Profiles section, verifiy path to barnyard executable for the sensor is correct.
    • In Barnyard Daemon Profiles section, verifiy path to PID file on sensor.
    • Take a look at the Barnyard command trace file. Should be located on the sensor in the snort config directory under the filename 'SMS_barnyard.<interface>.conf.CMD'.
      The contents of this file stores the command syntax used to start barnyard. For troubleshooting you should be able to execute this command line locally on the sensor.