As an excellent open-source host intrusion detection system, Snort can be installed and run on both windows and Linux platforms. As a Linux operating system based on desktop applications, Ubuntu can also install Snort. Install the Snort [install LAMP, Snort and some software libraries] Because Ubuntu is a Debian Linux system, it is very simple to install the software.
As an excellent open-source host intrusion detection system, Snort can be installed and run on both windows and Linux platforms. As a Linux operating system based on desktop applications, Ubuntu can also install Snort.
Install Snort
[Install LAMP, Snort and some software libraries]
Because Ubuntu is a Debian Linux system, the installation of software is very simple, and Ubuntu has images at the University of Science and Technology of China, the download speed is very fast (2 ~ 6 M/s), saving the trouble of downloading the installation package abroad. you only need one command to install all the software in dozens of seconds. Use the default Ubuntu command line package manager apt for installation.
$ Sudo apt-get install libpcap0.8-dev libMysqlClient15-devMysql-Client-5.0 mysql-server-5.0 bison flex apache2libapache2-mod-php5 php5-gd php5-mysql libphp-adodb php-pearpcregrep snort-rules-default
Note that the page for setting the MySQL root user password is displayed when you install the MySQL database, and it is set as "test" temporarily ".
[Create a database for Snort in the MySQL database]
The Ubuntu software warehouse has a default software package snort-mysql to provide auxiliary functions. use the software package manager to download and install the software package.
$ Sudo apt-get install snort-mysql
After installation, view the help documentation:
$ Less/usr/share/doc/snort-mysql/README-database.Debian.
Create an Snort database user and database in MySQL according to the instructions in the help document. The command used is as follows:
$ Mysql Cu root Cp
Enter the above password test at the prompt.
Mysql> create database snort;
Mysql> grant CREATE, INSERT, SELECT, UPDATE on snort. * tosnort @ localhost;
Mysql> grant CREATE, INSERT, SELECT, UPDATE on snort. * tosnort;
Mysql> set password FORsnort @ localhost = PASSWORD ('snort-db ');
Mysql> exit
The above command is used to create an snort database in the MySQL database, create an snort user to manage the database, and set the snort user password to snort-db.
Then build the structure of the snort database based on the instructions in the README-database.Debian.
$ Cd/usr/share/doc/snort-mysql
$ Zcat create_mysql.gz | mysql-u snort-D snort-psnort-db
In this way, the database structure is created for snort in MySQL, including the tables required by each snort.
[Set snort to output log files to the MySQL database]
Modify the Snort configuration file:/etc/snort. conf
$ Sudo vim/etc/snort. conf
Comment out HOME_NET related items in the configuration file, set HOME_NET to the network where the local IP is located, comment out EXTERNAL_NET related items, and set it to a non-local network, as shown below:
# Var HOME_NET any
Var HOME_NET 192.168.0.0/16
# Var EXTERNAL_NET any
Var EXTERNAL_NET! $ HOME_NET
Comment out related items of the output database and set the log output to the MySQL database, as shown below:
Output database: log, mysql, user = snort password = snort-dbdbname = snort host = localhost
# Output database: log, mysql
In this way, snort no longer writes records to files in the/var/log/snort Directory, instead stores records in the MySQL snort database. At this time, you can test whether the Snort works properly:
$ Sudo snort-c/etc/snort. conf
If a piglet drawn with ASCII characters appears, the Snort works normally. you can use Ctrl-C to exit. if the Snort exits abnormally, you need to check whether the above configuration is correct.
[Test whether Apache and PHP on the Web server are working properly]
Configure the php module of apache and add msql and gd extensions.
$ Sudo vim/etc/php5/apache2/php. ini
Extension = msql. so
Extension = gd. so
Restart apache
$/Etc/init. d/apache2 restart
Create a text file test. php in the/var/www/directory.
$ Sudo vim/var/www/test. php
Input content:
Phpinfo ();
?>
Enter http: // localhost/test. php in the browser. if the configuration is correct, the classic php info interface will appear, marking that LAMP works normally.
[Install and configure acid-base]
Installing acid-base is simple. use the Ubuntu package manager to download and install it:
$ Sudo apt-get install acidbase
During the installation process, enter the database selected by acidbase. here, select MySQL, root user password test, and acid-base password (it seems that you can skip or not set the password ).
Copy acidbase from the installation directory to the www Directory. you can also directly create a virtual directory in apache to point to the installation directory. the copied directory is mainly for security considerations.
Sudo cp CR/usr/share/acidbase // var/www/
Because the base_conf.php under the acidbase directory is originally a symbolic link pointing to base_conf.php under/etc/acidbase/, to ensure control of permissions, we need to delete this link and create a new base_conf.php file.
$ Rm base_conf.php
$ Touch base_conf.php
Temporarily change the/var/www/acidbase/directory permission to writable by all users, mainly used to configure acidbase.
$ Sudo chmod 757 acidbase/
Now you can start to configure acid-base. enter http: // localhost/acidbase in the address bar of the browser, and the page will be transferred to the installation interface. then click "continue" to install it step by step:
Select english as the language, and the adodb path is/usr/share/php/adodb. select MySQL as the database, snort as the database host, and localhost as the database host, the database username is snort, the password is snort-db, the acidbase system administrator username and password are set, the system administrator username is admin, and the password is test. Then, the installation is complete.
After the installation is complete, you can enter the logon interface, enter the user name and password, and enter the acidbase system.
Here we need to change the permissions of the acidbase Directory back to ensure security, and then start snort in the background, it indicates that the snort intrusion detection system has been installed and started properly:
$ Sudo chmod 775 acidbase/
$ Sudo snort-c/etc/snort. conf-I eth0 CD
[Check the working status of the intrusion detection system and change the intrusion detection rules]
Under normal circumstances, in an insecure network, after logging on to acidbase, you will be able to detect network attacks. If no network attack is detected, you can add more strict rules so that normal network connections may also be attacked to test the correctness of Snort IDS, for example, add the following at the end of/etc/snort/rules/web-misc.rules:
$ Sudo vi/etc/snort/rules/web-misc.rules
Alert tcp any: 1024-> $ HTTP_SERVER 500:
This line means that an alarm is triggered for tcp packets sent from any address less than port 1024 to port 500 or above of the local machine. Kill the background process of Snort and restart it. then, normal packets can be detected as attacks.
$ Sudo kill 'pgrep snort'
$ Sudo snort Cc/etc/snort. conf Ci eth0-D
Summary
Using Ubuntu to install the Snort intrusion detection system and the web console is quite easy, because Ubuntu provides a convenient software package installation function, but sometimes the customization performance is too poor, you need to manually find the installation location of the software package.