{"id":3444,"date":"2018-11-15T09:02:42","date_gmt":"2018-11-15T09:02:42","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=3444"},"modified":"2018-11-17T15:14:27","modified_gmt":"2018-11-17T15:14:27","slug":"snort-open-source-ids-ls-blog","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/15\/snort-open-source-ids-ls-blog\/","title":{"rendered":"Snort Open Source IDS \u2013 ls \/blog"},"content":{"rendered":"<p>Snort is an open source Intrusion Detection System that you can use on your Linux systems. This tutorial will go over basic configuration of Snort IDS and teach you how to create rules to detect different types of activities on the system.<\/p>\n<p>For this tutorial the network we will use is: 10.0.0.0\/24. Edit your \/etc\/snort\/snort.conf file and and replace the \u201cany\u201d next to $HOME_NET with your network information as shown in the example screen shot below:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s-2.png\" alt=\"\" width=\"736\" height=\"490\" \/><\/a><\/p>\n<p>Alternatively you can also define specific IP addresses to monitor separated with comma between [ ] as shown in this screen shot:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s1-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s1-2.png\" alt=\"\" width=\"736\" height=\"490\" \/><\/a><\/p>\n<p>Now let\u2019s get started and run this command on the command line:<\/p>\n<p># snort -d -l \/var\/log\/snort\/ -h 10.0.0.0\/24 -A console -c \/etc\/snort\/snort.conf<\/p>\n<p>Where:<br \/>\nd= tells snort to show data<br \/>\nl= determines the logs directory<br \/>\nh= specifies the network to monitor<br \/>\nA= instructs snort to print alerts in the console<br \/>\nc= specifies Snort the configuration file<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s2-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i2.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s2-2.png\" alt=\"\" width=\"732\" height=\"438\" \/><\/a> <a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s3-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i1.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s3-2.png\" alt=\"\" width=\"732\" height=\"438\" \/><\/a><\/p>\n<p>Lets launch a fast scan from a different device using nmap:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s4-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s4-2.png\" alt=\"\" width=\"1051\" height=\"610\" \/><\/a><\/p>\n<p>And lets see what happens in the snort console:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s5-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i1.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s5-2.png\" alt=\"\" width=\"732\" height=\"438\" \/><\/a><\/p>\n<p>Snort detected the scan, now, also from a different device lets attack with DoS using hping3<\/p>\n<p># hping3 -c 10000 -d 120 -S -w 64 -p 21 \u2013flood \u2013rand-source 10.0.0.3<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s6-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i2.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s6-2.png\" alt=\"\" width=\"1051\" height=\"376\" \/><\/a><\/p>\n<p>The device displaying Snort is detecting bad traffic as shown here:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s7-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s7-2.png\" alt=\"\" width=\"732\" height=\"438\" \/><\/a><\/p>\n<p>Since we instructed Snort to save logs, we can read them by running:<\/p>\n<h3><em>Introduction to Snort Rules<\/em><\/h3>\n<p>Snort\u2019s NIDS mode works based on rules specified in the \/etc\/snort\/snort.conf file.<\/p>\n<p>Within the snort.conf file we can find commented and uncommented rules as you can see below:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s8-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s8-2.png\" alt=\"\" width=\"1140\" height=\"621\" \/><\/a><\/p>\n<p>The rules path normally is \/etc\/snort\/rules , there we can find the rules files:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s9-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i1.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s9-2.png\" alt=\"\" width=\"1140\" height=\"289\" \/><\/a><\/p>\n<p>Lets see the rules against backdoors:<br \/>\n<a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s10-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i1.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s10-2.png\" alt=\"\" width=\"1140\" height=\"621\" \/><\/a><\/p>\n<p>There are several rules to prevent backdoor attacks, surprisingly there is a rule against NetBus, a trojan horse which became popular a couple of decades ago, lets look at it and I will explain its parts and how it works:<\/p>\n<p>alert tcp $HOME_NET 20034 \u2013&gt; $EXTERNAL_NET any (msg:\u201cBACKDOOR NetBus Pro 2.0 connection<br \/>\nestablished\u201d; flow:from_server,established;<br \/>\nflowbits:isset,backdoor.netbus_2.connect; content:\u201cBN|10 00 02 00|\u201d; depth:6; content:\u201c|<br \/>\n05 00|\u201d; depth:2; offset:8; classtype:misc-activity; sid:115; rev:9;)<\/p>\n<p>This rule instructs snort to alert about TCP connections on port 20034 transmitting to any source in a external network.<\/p>\n<p>-&gt; = specifies the traffic direction, in this case from our protected network to an external one<\/p>\n<p>msg = instructs the alert to include a specific message when displaying<\/p>\n<p>content = search for specific content within the packet. It can include text if between \u201c \u201c or binary data if between | |<br \/>\ndepth = Analysis intensity, in the rule above we see two different parameters for two different contents<br \/>\noffset = tells Snort the starting byte of each packet to start searching for the content<br \/>\nclasstype = tells what kind of attack Snort is alerting about<\/p>\n<p>sid:115 = rule identifier<\/p>\n<h3><em>Creating our own rule<\/em><\/h3>\n<p>Now we\u2019ll create a new rule to notify about incoming SSH connections. Open \/etc\/snort\/rules\/yourrule.rules, and inside paste the following text:<\/p>\n<p>alert tcp $EXTERNAL_NET any \u2013&gt; $HOME_NET 22 (msg:\u201cSSH incoming\u201d;<br \/>\nflow:stateless; flags:S+; sid:100006927; rev:1;)<\/p>\n<p>We are telling Snort to alert about any tcp connection from any external source to our ssh port (in this case the default port) including the text message \u201cSSH INCOMING\u201d, where stateless instructs Snort to ignore the connection\u2019s state.<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s11-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s11-2.png\" alt=\"\" width=\"1140\" height=\"284\" \/><\/a><\/p>\n<p>Now, we need to add the rule we created to our \/etc\/snort\/snort.conf file. Open the config file in an editor and search for #7, which is the section with rules. Add an uncommented rule like in the image above by adding:<\/p>\n<p>include $RULE_PATH\/yourrule.rules<\/p>\n<p>Instead of \u201cyourrule.rules\u201d, set your file name, in my case it was test3.rules.<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/snort_rules_add.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i2.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/snort_rules_add.png\" alt=\"\" width=\"889\" height=\"556\" \/><\/a><\/p>\n<p>Once it is done run Snort again and see what happens.<\/p>\n<p>#snort -d -l \/var\/log\/snort\/ -h 10.0.0.0\/24 -A console -c \/etc\/snort\/snort.conf<\/p>\n<p>ssh to your device from another device and see what happens:<\/p>\n<p><a href=\"http:\/\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s12-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i1.wp.com\/linuxhint.com\/wp-content\/uploads\/2018\/03\/s12-2.png\" alt=\"\" width=\"736\" height=\"490\" \/><\/a><\/p>\n<p>You can see that SSH incoming was detected.<\/p>\n<p>With this lesson I hope you know how to make basic rules and use them for detecting activity on a system.<\/p>\n<p>Full article:<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/configure-snort-ids-create-rules\/\">https:\/\/linuxhint.com\/configure-snort-ids-create-rules\/<\/a><\/p>\n<p><a href=\"https:\/\/linuxsecurityblog.com\/2018\/11\/14\/snort-open-source-ids\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Snort is an open source Intrusion Detection System that you can use on your Linux systems. This tutorial will go over basic configuration of Snort IDS and teach you how to create rules to detect different types of activities on the system. For this tutorial the network we will use is: 10.0.0.0\/24. Edit your \/etc\/snort\/snort.conf &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/15\/snort-open-source-ids-ls-blog\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Snort Open Source IDS \u2013 ls \/blog&#8221;<\/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-3444","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/3444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=3444"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/3444\/revisions"}],"predecessor-version":[{"id":3706,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/3444\/revisions\/3706"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=3444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=3444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=3444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}