{"id":117,"date":"2024-10-11T11:54:00","date_gmt":"2024-10-11T16:54:00","guid":{"rendered":"https:\/\/danielbondurantcybersecurityportfolio.online\/?p=117"},"modified":"2024-11-07T10:00:55","modified_gmt":"2024-11-07T16:00:55","slug":"custom-firewall-with-suricata-part-3-ip-reputation","status":"publish","type":"post","link":"https:\/\/danielbondurantcybersecurityportfolio.online\/?p=117","title":{"rendered":"Custom Firewall with Suricata     Part 3: IP Reputation"},"content":{"rendered":"\n<p>This is the final part for building a custom firewall with the utilization of IP Reputation within Suricata.<\/p>\n\n\n\n<p>The first step to take is to go into &#8216;suricata.yaml&#8217;, go to the IP Reputation section, and remove the comment tags from the configurations. The next step is to create the necessary files and directory that are listed. So make the &#8216;iprep&#8217; directory and make &#8216;categories.txt&#8217; and &#8216;reputation.list&#8217; inside of the directory.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"94\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-10.png\" alt=\"\" class=\"wp-image-121\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-10.png 525w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-10-300x54.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>For formatting these two files properly, here are screenshots from the Suricata documentation:<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdidA3jLUCIFzot74o5F4iY54wjeFf9SmZGOvZGZ-LG_lJGpb7WluHBTkRYRjyYa141XvCTueGtjTuzaN7VN3YXuZM2IU3lVicQBgVHSKGSqU8m5VGVgQkX7Td8gvg45z4X5Q6UoSpDATI7trC-mNS39qI?key=Xl2R8Pg9vT2Qc-46eUj7fQ\" width=\"624\" height=\"303\"><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeLddkYunbT39RIWgZ9LOuSxFIeepgyw3uXmUjv2W0i2tT4O9KFmNxVlz6sX0NJnKjrap4FQ7UpGtMqZdgV_rew-TW-GWNx1SczDB9oP0jZ-RPT4x0aunkX-69flX5NSxZhZNVm-S3cKcvsRqJlGBLB6jk?key=Xl2R8Pg9vT2Qc-46eUj7fQ\" width=\"624\" height=\"552\"><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>For this example, here is the &#8216;categories.txt&#8217; file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"98\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-11.png\" alt=\"\" class=\"wp-image-122\" style=\"width:374px;height:auto\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-11.png 352w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-11-300x84.png 300w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/figure>\n\n\n\n<p>And here is the &#8216;reputation.list&#8217; file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"358\" height=\"99\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-12.png\" alt=\"\" class=\"wp-image-123\" style=\"width:394px;height:auto\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-12.png 358w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-12-300x83.png 300w\" sizes=\"auto, (max-width: 358px) 100vw, 358px\" \/><\/figure>\n\n\n\n<p>This example reputation will trigger on any IP address in the 1.0.0.0\/24 range.<\/p>\n\n\n\n<p>Now we need to go to the &#8216;custom.rules&#8217; file we made with the custom Suricata alert rules and add a new rule using IP Rep.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"548\" height=\"70\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-13.png\" alt=\"\" class=\"wp-image-125\" style=\"width:618px;height:auto\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-13.png 548w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-13-300x38.png 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/figure>\n\n\n\n<p>This rule alerts on IP activity from the home network going to any IP address. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iprep:dst,Custom,&gt;,0;<\/code><\/pre>\n\n\n\n<p>For the &#8216;iprep&#8217; section of the rule, we are using destination, not source, to prevent blocking our internal IP address. &#8216;Custom&#8217; is the category name from the &#8216;categories.txt&#8217; file. The &#8216;&gt;,0&#8217; indicates that anything with a reputation greater than 0 will be detected and blocked. This allows the potential to block thousands of IP addresses without having to make thousands of rules in the firewall.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Now to put everything together, first we will check firewall with &#8216;iptables&#8217;:<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeLkRjmc00McmTA8kRMKSDXpsKOu9Lze2B-twVbDmhOAO6SHDMSx_Dl-dkqAcVY7mmWUQJrS5bMYd32kgWMZDDvmyh5pSyQwZ-3bqjhLBO4HUEeh3t1mGsiGLIS8ufky2PeMYbkEmeGmVmLJJDH2vJ4LG9S?key=Xl2R8Pg9vT2Qc-46eUj7fQ\" width=\"434\" height=\"127\"><\/p>\n\n\n\n<p>Currently nothing being blocked. <\/p>\n\n\n\n<p>Next, we will make sure Supervisor is running with our alert daemon:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"478\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-14.png\" alt=\"\" class=\"wp-image-126\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-14.png 567w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-14-300x253.png 300w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/figure>\n\n\n\n<p>This shows the alert daemon is running.<\/p>\n\n\n\n<p>Now we can start Suricata, then ping any address in the 1.0.0.0\/24 range:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"569\" height=\"380\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-15.png\" alt=\"\" class=\"wp-image-127\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-15.png 569w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-15-300x200.png 300w\" sizes=\"auto, (max-width: 569px) 100vw, 569px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"575\" height=\"361\" src=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-16.png\" alt=\"\" class=\"wp-image-128\" srcset=\"https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-16.png 575w, https:\/\/danielbondurantcybersecurityportfolio.online\/wp-content\/uploads\/2024\/10\/image-16-300x188.png 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\n\n\n\n<p>We can see that the alert was generated in the fast log, and if we try to ping 1.0.0.1 again, there is 100% packet loss this time. Checking the &#8216;iptables&#8217; shows that 1.0.0.1 has been added to the firewall and is being blocked.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is the final part for building a custom firewall with the utilization of IP Reputation within Suricata. The first step to take is to go into &#8216;suricata.yaml&#8217;, go to the IP Reputation section, and remove the comment tags from the configurations. The next step is to create the necessary files and directory that are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,9],"tags":[],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-linux","category-suricata"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=117"}],"version-history":[{"count":6,"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions\/139"}],"wp:attachment":[{"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danielbondurantcybersecurityportfolio.online\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}