{"id":173,"date":"2016-12-20T15:22:59","date_gmt":"2016-12-20T15:22:59","guid":{"rendered":"http:\/\/info.ffteixeira.net\/2016\/12\/20\/suricata-teste\/"},"modified":"2016-12-20T15:22:59","modified_gmt":"2016-12-20T15:22:59","slug":"suricata-teste","status":"publish","type":"post","link":"https:\/\/blog.ffteixeira.net\/?p=173","title":{"rendered":"suricata *teste*"},"content":{"rendered":"<div>apt-get install build-essential module-assistant<\/div>\n<div>&nbsp; &nbsp;36 &nbsp;m-a prepare<\/div>\n<div>&nbsp; &nbsp;37 &nbsp;sh .\/VBoxLinuxAdditions.run<\/div>\n<div>&nbsp;<\/div>\n<div>&#8212;<\/div>\n<div>Installing Suricata, Snorby and Banyard2 on Debian<\/div>\n<div>&nbsp;<\/div>\n<div>I have used Snort quite extensively in the past and was curious about toying with Suricata which is similar to Snort but nicer in my view. It has been a few years since I looked at it. I can see the project seems to have evolved quite a lot. One functionality that I will be using down the line will be PF Ring.<\/div>\n<div>&nbsp;<\/div>\n<div>On a lazy Sunday afternoon, I thought this was the perfect time to take a look at what it can do in its current form. I used Debian 7.3 for my tests. Everything is packaged which is quite nice though the version of suricata is a bit old on this (1.2.1 vs 1.4.7 on the website). I am very likely to make packages for this later in order to have more functionality.<\/div>\n<div>&nbsp;<\/div>\n<div>NIC<\/div>\n<div>auto eth1<\/div>\n<div>iface eth1 inet manual<\/div>\n<div>up ifconfig $IFACE up<\/div>\n<div>#post-up ethtool -K eth1 gro off<\/div>\n<div>#post-up ethtool -K eth1 lro off<\/div>\n<div>&nbsp;<\/div>\n<div>Pre-installation requirements&para;<\/div>\n<div>&nbsp;<\/div>\n<div>apt-get -y install libpcre3 libpcre3-dbg libpcre3-dev build-essential autoconf automake libtool libpcap-dev libnet1-dev libyaml-0-2 libyaml-dev zlib1g zlib1g-dev libmagic-dev libcap-ng-dev libjansson-dev pkg-config apache2 apache2-dev libapr1-dev libaprutil1-dev libcurl4-openssl-dev openssl libssl-dev<\/div>\n<div>&nbsp;<\/div>\n<div>IPS<\/div>\n<div>By default, Suricata works as an IDS. If you want to use it as a IDS and IPS program, enter:<\/div>\n<div>&nbsp;<\/div>\n<div>apt-get -y install libnetfilter-queue-dev<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Once you have done the traditional apt-get install suricata<\/div>\n<div>&nbsp;<\/div>\n<div>#apt-get install suricata mysql-server postgresql-server-dev-9.4<\/div>\n<div>#mysql_secure_installation<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>There is not much to do to get it running, mostly edit: \/etc\/default\/suricata and change this line depending on your network interface, and also allow it to run:<\/div>\n<div>&nbsp;<\/div>\n<div># set to yes to start the server in the init.d script<\/div>\n<div>RUN=yes<\/div>\n<div># Interface to listen on (for pcap mode)<\/div>\n<div>IFACE=br0<\/div>\n<div>&nbsp;<\/div>\n<div>You then should grab the rules to get it all going and monitoring, check out the official page to set this up. I edited \/etc\/oinkmaster.conf to add the rules I wanted:<\/div>\n<div>1<\/div>\n<div>&nbsp;<\/div>\n<div>url = http:\/\/rules.emergingthreats.net\/open\/suricata\/emerging.rules.tar.gz<\/div>\n<div>&nbsp;<\/div>\n<div>You now need to grab the rules, a quick mkdir \/etc\/suricata\/rules &amp;&amp; oinkmaster -C \/etc\/oinkmaster.conf -o \/etc\/suricata\/rules should fix this, and give you something like this:<\/div>\n<div>&nbsp;<\/div>\n<div># oinkmaster -C \/etc\/oinkmaster.conf -o \/etc\/suricata\/rules<\/div>\n<div>Loading \/etc\/oinkmaster.conf<\/div>\n<div>Downloading file from http:\/\/rules.emergingthreats.net\/open\/suricata\/emerging.rules.tar.gz&#8230; done.<\/div>\n<div>Archive successfully downloaded, unpacking&#8230; done.<\/div>\n<div>Setting up rules structures&#8230; done.<\/div>\n<div>Processing downloaded rules&#8230; disablesid 0, enablesid 0, modifysid 0, localsid 0, total rules 18195<\/div>\n<div>Setting up rules structures&#8230; done.<\/div>\n<div>Comparing new files to the old ones&#8230; done.<\/div>\n<div>Updating local rules files&#8230; done.<\/div>\n<div>[***] Results from Oinkmaster started 20140119 18:15:26 [***]<\/div>\n<div>[*] Rules modifications: [*]<\/div>\n<div>&nbsp; &nbsp; None.<\/div>\n<div>[*] Non-rule line modifications: [*]<\/div>\n<div>&nbsp; &nbsp; None.<\/div>\n<div>[+] Added files (consider updating your snort.conf to include them if needed): [+]<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp; &nbsp; -&gt; botcc.rules<\/div>\n<div>&#8230;snip&#8230;<\/div>\n<div>&nbsp; &nbsp; -&gt; unicode.map<\/div>\n<div>&nbsp;<\/div>\n<div>Restart the thing with a simple service suricata restart and there you are, you can leave it running on your system to learn what kind of traffic is happening. It is worth noting that default rules are set to PASS to avoid messing your traffic up. It is up to you to tune this the right way(tm).<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&#8212; ??<\/div>\n<div>Configure Suricata and download the rules<\/div>\n<div>___ ??<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Create user for snorby<\/div>\n<div>&nbsp;<\/div>\n<div>Login to MySQL server with mysql -u root -p<\/div>\n<div>&nbsp;<\/div>\n<div>mysql&gt; create user &#039;admin&#039;@&#039;localhost&#039; identified by &#039;admin_password&#039;;<\/div>\n<div>Query OK, 0 rows affected (0.00 sec)<\/div>\n<div>&nbsp;<\/div>\n<div>mysql&gt; grant all privileges on snorby.* to &#039;admin&#039;@&#039;localhost&#039; with grant option;<\/div>\n<div>Query OK, 0 rows affected (0.02 sec)<\/div>\n<div>&nbsp;<\/div>\n<div>mysql&gt; flush privileges;<\/div>\n<div>Query OK, 0 rows affected (0.00 sec)<\/div>\n<div>&nbsp;<\/div>\n<div>mysql&gt;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Modify MySQL config file my.cnf<\/div>\n<div>By default MySQL only listens to localhost (127.0.0.1), however I want MySQL to listen to from all source addresses.<\/div>\n<div>&nbsp;<\/div>\n<div>#nano \/etc\/mysql\/my.cnf<\/div>\n<div>&nbsp;<\/div>\n<div>Comment the bind-address line. Then restart mysqld service.<span class=\"Apple-tab-span\"> <\/span><\/div>\n<div>#<\/div>\n<div># Instead of skip-networking the default is now to listen only on<\/div>\n<div># localhost which is more compatible and is not less secure.<\/div>\n<div>#bind-address &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 127.0.0.1<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>service mysql restart<\/div>\n<div>lsof -i | grep mysqld<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Snorby is a web interface that allows you see events in a nice web inteface. It will require a few things to work nicely, which you can install prior by doing:&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>#apt-get install bundler libxml2-dev libxslt-dev libmysqlclient-dev graphviz-dev libgv-ruby wkhtmltopdf<\/div>\n<div>&nbsp;<\/div>\n<div>Before you execute the next commands, be careful with your snorby_config.yml file and set your domain to a secure domain and random port, since this is a ruby on rails application, unless you plan on proxying it behind a http server. My 2 cents, opinions my own, etc&hellip;<\/div>\n<div>&nbsp;<\/div>\n<div>cd \/var\/www\/<\/div>\n<div>git clone http:\/\/github.com\/Snorby\/snorby.git<\/div>\n<div>cd snorby<\/div>\n<div>bundle install<\/div>\n<div>cd ..\/snorby\/config&nbsp;<\/div>\n<div>cp database.yml.example database.yml<\/div>\n<div>vi database.yml ( with the newly created snorby username and password)<\/div>\n<div>cp snorby_config.yml.example snorby_config.yml<\/div>\n<div>vi snorby_config.yml<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>And paste these lines:<\/div>\n<div>&#8212;<\/div>\n<div>production:<\/div>\n<div>&nbsp; domain: localhost:3000<\/div>\n<div>&nbsp; wkhtmltopdf: \/usr\/bin\/wkhtmltopdf<\/div>\n<div>&#8212;<\/div>\n<div>&nbsp;<\/div>\n<div>cd initializers\/<\/div>\n<div>vi mail_config.rb<\/div>\n<div>bundle exec rake snorby:setup<\/div>\n<div>bundle exec rails server -e production<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Passanger<\/div>\n<div>cd \/var\/www\/snorby<\/div>\n<div>gem install rails bundler &#8211;no-ri &#8211;no-rdoc passenger<\/div>\n<div>passenger-install-apache2-module -a<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Now you need to set up a parser between the suricata logs and the snorby interface, this is where banyard2 comes in. The new version is hosted on github. You will need a few things to get it compiled right.<\/div>\n<div>&nbsp;<\/div>\n<div>apt-get install flex bison<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>cd \/opt<\/div>\n<div>git clone https:\/\/github.com\/jncornett\/libdnet.git<\/div>\n<div>cd libdnet<\/div>\n<div>.\/configure &amp;&amp; make &amp;&amp; make install<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>wget https:\/\/www.snort.org\/downloads\/snort\/daq-2.0.6.tar.gz<\/div>\n<div>tar xvfz daq-2.0.6.tar.gz &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/div>\n<div>cd daq-2.0.6<\/div>\n<div>.\/configure &amp;&amp; make &amp;&amp; make install<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>cd \/opt<\/div>\n<div>git clone https:\/\/github.com\/firnsy\/barnyard2.git<\/div>\n<div>cd \/opt\/barnyard2\/<\/div>\n<div>apt-get install dh-autoreconf libpcap-dev<\/div>\n<div>autoreconf &#8211;install<\/div>\n<div># check out where your MySQL libs are before specifying the same folder<\/div>\n<div>.\/configure &#8211;with-mysql-libraries=\/usr\/lib\/x86_64-linux-gnu\/<\/div>\n<div>make &amp;&amp; make install<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>If there were no errors, you should have a nice running setup, time to configure it to send stuff to MySQL. Edit \/usr\/local\/etc\/barnyard2.conf and change the following:<\/div>\n<div>&nbsp;<\/div>\n<div># set the appropriate paths to the file(s) your Snort process is using.<\/div>\n<div># cat \/usr\/local\/etc\/barnyard2.conf &nbsp;| grep -n &lt;text&gt;<\/div>\n<div>&nbsp;<\/div>\n<div>config reference_file: &nbsp; &nbsp; &nbsp;\/etc\/suricata\/reference.config<\/div>\n<div>config classification_file: \/etc\/suricata\/classification.config<\/div>\n<div>config gen_file: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/etc\/suricata\/rules\/gen-msg.map<\/div>\n<div>config sid_file: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/etc\/suricata\/rules\/sid-msg.map<\/div>\n<div>&nbsp;<\/div>\n<div>Enable the interface in barnyard2.conf by Remove the comment # from config interface: line. Which looks like this:<\/div>\n<div>config interface: &nbsp; &nbsp; &nbsp; eth0<\/div>\n<div>&nbsp;<\/div>\n<div># define the full waldo filepath.<\/div>\n<div>config waldo_file: \/var\/log\/suricata\/suricata.waldo<\/div>\n<div>&nbsp;<\/div>\n<div># database: log to a variety of databases<\/div>\n<div>output database: log, mysql, user=snorbydbuser password=snorbydbpassword dbname=snorbydbname host=localhost &nbsp;&lt;??sensor_name=sensor1??&gt;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Create the log folder for barnyard2<\/div>\n<div>#mkdir \/var\/log\/barnyard2<\/div>\n<div>&nbsp;<\/div>\n<div>Create suricata.waldo and create the subdirectories:<\/div>\n<div>&nbsp;<\/div>\n<div>#mkdir \/var\/log\/barnyard2<\/div>\n<div>#mkdir \/var\/log\/suricata\/ &amp;&amp; touch \/var\/log\/suricata\/suricata.waldo<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Copy the barnyard2.conf&nbsp;<\/div>\n<div>#cp \/usr\/local\/etc\/barnyard2.conf \/etc\/suricata\/<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>You should then be able to start it and check that it works, if it does, then you can use -D to run as a daemon.<\/div>\n<div>&nbsp;<\/div>\n<div>touch \/var\/log\/suricata\/suricata.waldo<\/div>\n<div>&nbsp;1234 &nbsp;barnyard2 -c \/etc\/suricata\/barnyard2.conf -d \/var\/log\/suricata\/ -f unified2.alert -w \/var\/log\/suricata\/suricata.waldo -d<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;1234 &nbsp;barnyard2 -c \/usr\/local\/etc\/barnyard2.conf &nbsp;-d \/var\/log\/suricata\/ -f unified2.alert -w \/var\/log\/suricata\/suricata.waldo -d<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>barnyard2 -c \/etc\/suricata\/barnyard2.conf -d \/var\/log\/suricata -f unified2.alert -w \/var\/log\/suricata\/suricata.waldo -D<\/div>\n<div>&nbsp;<\/div>\n<div>barnyard2 -c \/usr\/local\/etc\/barnyard2.conf -d \/var\/log\/suricata\/ -f unified2.alert -w \/var\/log\/suricata\/suricata.waldo -D<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>SystemD Startup Scrip<\/div>\n<div>&nbsp;<\/div>\n<div>nano \/lib\/systemd\/system\/barnyard2.service<\/div>\n<div>&nbsp;<\/div>\n<div>With the following content.&nbsp;<\/div>\n<div>&#8212;<\/div>\n<div>[Unit]<\/div>\n<div>Description=Barnyard NIDS Daemon<\/div>\n<div>After=syslog.target network.target<\/div>\n<div>&nbsp;<\/div>\n<div>[Service]<\/div>\n<div>Type=simple<\/div>\n<div>ExecStart=\/usr\/local\/bin\/barnyard2 -c \/etc\/suricata\/barnyard2.conf -d \/var\/log\/suricata\/ -f unified2.alert -w \/var\/log\/suricata\/suricata.waldo -D<\/div>\n<div>&nbsp;<\/div>\n<div>[Install]<\/div>\n<div>WantedBy=multi-user.target<\/div>\n<div>&#8212;<\/div>\n<div>systemctl enable barnyard2<\/div>\n<div>&nbsp;<\/div>\n<div>Reboot the computer and check that both services are started: service barnyard2 status<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>More on this when I have time \ud83d\ude42<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>Note:<\/div>\n<div>Default User Credentials for Snorby<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp; &nbsp; E-mail: snorby@example.com<\/div>\n<div>&nbsp; &nbsp; Password: snorby<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp;<\/div>\n<div>https:\/\/www.frlinux.eu\/?p=351<\/div>\n<div>https:\/\/www.aldeid.com\/wiki\/Snorby<\/div>\n<div>https:\/\/cyruslab.net\/2012\/10\/18\/building-an-ids-part-1-installing-pre-requisites-and-snorby\/<\/div>\n","protected":false},"excerpt":{"rendered":"<p>apt-get install build-essential module-assistant &nbsp; &nbsp;36 &nbsp;m-a prepare &nbsp; &nbsp;37 &nbsp;sh .\/VBoxLinuxAdditions.run &nbsp; &#8212; Installing Suricata, Snorby and Banyard2 on Debian &nbsp; I have used Snort quite extensively in the past and was curious about toying with Suricata which is &hellip; <a href=\"https:\/\/blog.ffteixeira.net\/?p=173\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-173","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=173"}],"version-history":[{"count":0,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/173\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}