Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Taming the beasts… aka suricata blueprint

    Scheduled Pinned Locked Moved IDS/IPS
    504 Posts 64 Posters 325.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      G.D. Wusser Esq.
      last edited by

      Give me a ping, Vasili. One ping only.

      1 Reply Last reply Reply Quote 0
      • D
        dmitripr
        last edited by

        Hi,

        Trying to code a custom rule and getting an error. The rule is basically to block the traffic to closed ports, something like:

        alert tcp $EXTERNAL_NET any -> any [1:1024,![XX,XX,XX,XXX]]

        However, I'm getting an error:
        [ERRCODE: SC_ERR_NEGATED_VALUE_IN_PORT_RANGE(56)] - Can't have a negated value in a range.

        I thought this was a valid syntax. What am I missing here?

        Thanks for your help!

        1 Reply Last reply Reply Quote 0
        • BBcan177B
          BBcan177 Moderator
          last edited by

          @dmitripr:

          I thought this was a valid syntax. What am I missing here?

          This is from an older manual, but I believe its still the same format.

          2.2.4 Port Numbers

          Port numbers may be specified in a number of ways, including "any" ports, static port definitions, ranges, and by negation. "Any" ports are a wildcard value, meaning literally any port. Static ports are indicated by a single port number, such as 111 for port mapper, 23 for telnet, or 80 for http, etc. Port ranges are indicated with the range operator ":". The range operator may be applied in a number of ways to take on different meanings, such as in Figure 2.6.

          log udp any any -> 192.168.1.0/24 1:1024 log udp

          traffic coming from any port and destination ports ranging from 1 to 1024
          log tcp any any -> 192.168.1.0/24 :6000

          log tcp traffic from any port going to ports less than or equal to 6000

          log tcp any :1024 -> 192.168.1.0/24 500:

          log tcp traffic from privileged ports less than or equal to 1024 going to ports greater than or equal to 500

          Port negation is indicated by using the negation operator "!". The negation operator may be applied against any of the other rule types (except any, which would translate to none, how Zen…). For example, if for some twisted reason you wanted to log everything except the X Windows ports, you could do something like the rule in Figure 2.7.

          log tcp any any -> 192.168.1.0/24 !6000:6010

          "Experience is something you don't get until just after you need it."

          Website: http://pfBlockerNG.com
          Twitter: @BBcan177  #pfBlockerNG
          Reddit: https://www.reddit.com/r/pfBlockerNG/new/

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by

            @dmitripr:

            Hi,

            Trying to code a custom rule and getting an error. The rule is basically to block the traffic to closed ports, something like:

            alert tcp $EXTERNAL_NET any -> any [1:1024,![XX,XX,XX,XXX]]

            However, I'm getting an error:
            [ERRCODE: SC_ERR_NEGATED_VALUE_IN_PORT_RANGE(56)] - Can't have a negated value in a range.

            I thought this was a valid syntax. What am I missing here?

            Thanks for your help!

            You need to remove the regular ports from the rule and only select the negated range. It wouldn't be any use anyway to include 1:1024. If you don't allow that range, the rule will still alert for those ports, since that's what you told the IDS to do. Alert on any port other than the open ports (used ports). Any port you don't specifically allow, will generate the alert.

            @G.D. Wusser Esq.: It's not a matter of one ping only Vasili. It's a matter of not using a screwdriver and a hammer to remove a 1/2" bolt. Yes it can be done, yes it's extremely useful if the head of the bolt is broken off for any reason, but it's not the right tool for the job. Use the 1/2" wrench to remove the 1/2" bolt.

            To ping a host you first need to resolve the host, then ping it.
            To find out the IP of a host, you just need to resolve the host.

            1 Reply Last reply Reply Quote 0
            • C
              Cino
              last edited by

              @jflsakfja next time you speak to that user, tell them to use nslookup on windows. you can look up by hostname or ip…

              1 Reply Last reply Reply Quote 0
              • D
                dmitripr
                last edited by

                @jflsakfja:

                You need to remove the regular ports from the rule and only select the negated range. It wouldn't be any use anyway to include 1:1024. If you don't allow that range, the rule will still alert for those ports, since that's what you told the IDS to do. Alert on any port other than the open ports (used ports). Any port you don't specifically allow, will generate the alert.

                Thanks jflsakfja. That makes sense. However, the reason I stated 1:1024 is because I want ports 1024: onwards to remain open as well. Basically I would like to block all destination privileged port, except a few (IPsec, OpenVPN, etc.), but also leave non-privileged ports open as well (as you suggested :) ). What would be the appropriate syntax for the port part of the rule? Based on the documentation I found online, my proposed syntax should work, but it doesn't and I get the error that I mentioned.

                Maybe I'm over-thinking this. Can I use pfsense port alias here?

                Also, I've been using snort for a while before this, and it seems that suricata is utilizing more CPU than snort. I got a 50/10 line at home, and during speedtests while with snort my CPU utilization would spike to 30-40% (I have an Atom D2550). However, with suricata during the same test the CPU spikes to 85-95%. And during regular Netflix/youtube streaming suricata seems to use 2x more CPU (snort: ~2-4% avg, suricata: ~5-7%). Anyone else notice that?

                Again, thanks for the help!

                1 Reply Last reply Reply Quote 0
                • ?
                  A Former User
                  last edited by

                  @dmitripr:

                  Thanks jflsakfja. That makes sense. However, the reason I stated 1:1024 is because I want ports 1024: onwards to remain open as well. Basically I would like to block all destination privileged port, except a few (IPsec, OpenVPN, etc.), but also leave non-privileged ports open as well (as you suggested :) ). What would be the appropriate syntax for the port part of the rule? Based on the documentation I found online, my proposed syntax should work, but it doesn't and I get the error that I mentioned.

                  As suggested, keep the rule alerting on all unused ports: ![port1,port2,port3,port4:port25,port1024:port65535]
                  You just need to set up the ports you use inside that [ ]. I highly suggest to include all the unprivileged ports in there, unless you manually go into every program you use and tell it to use a specific unprivileged range.

                  @dmitripr:

                  Maybe I'm over-thinking this. Can I use pfsense port alias here?

                  Nope. I used to be able to declare the variables at the start of the custom rules tab (eg USED_PORTS) but last time I tried it, it didn't work. Didn't fiddle with it anymore, since it's not that many ports you need to open up anyway.

                  @dmitripr:

                  Also, I've been using snort for a while before this, and it seems that suricata is utilizing more CPU than snort. I got a 50/10 line at home, and during speedtests while with snort my CPU utilization would spike to 30-40% (I have an Atom D2550). However, with suricata during the same test the CPU spikes to 85-95%. And during regular Netflix/youtube streaming suricata seems to use 2x more CPU (snort: ~2-4% avg, suricata: ~5-7%). Anyone else notice that?

                  Again, thanks for the help!

                  Yeap seen that too. I'm putting my money on the old version of suricata as being the culprit for this.

                  @Cino: Will do, thanks.

                  1 Reply Last reply Reply Quote 0
                  • D
                    dmitripr
                    last edited by

                    Thanks, jflsakfja. That rule syntax worked.

                    I see that the latest Suricata release is 2.0.3. Any ideas when pfsense package will be upgraded to that version? Is there a way to manually update?

                    I have noticed that as of late I'm being pinged from multiple hosts for several minutes at a time. Feels like an attack from hijacked hosts. I put a rule to block those, and I was able to block almost 500 hosts in 24 hours via suricata.

                    Thanks again!

                    1 Reply Last reply Reply Quote 0
                    • ?
                      A Former User
                      last edited by

                      @dmitripr:

                      Thanks, jflsakfja. That rule syntax worked.

                      I see that the latest Suricata release is 2.0.3. Any ideas when pfsense package will be upgraded to that version? Is there a way to manually update?

                      I have noticed that as of late I'm being pinged from multiple hosts for several minutes at a time. Feels like an attack from hijacked hosts. I put a rule to block those, and I was able to block almost 500 hosts in 24 hours via suricata.

                      Thanks again!

                      I think 2.x is coming with the next release of the suricata package. How long that takes, dunno though.

                      The pings are regular internet noise. Don't worry about it. As long as you are not responding back, then you are still flying under the radar.

                      1 Reply Last reply Reply Quote 0
                      • D
                        dmitripr
                        last edited by

                        After doing some testing of Snort vs Suricata, I've decided to go back to Snort.

                        For whatever reason, looks like Comcast upgraded my line to 100/10 tier in the last couple of days. Now, with my D2550 Atom CPU Suricata was maxing out my CPU cycles and my max throughput was 95 mbps (@100% CPU load). I've tried snort and @45% CPU load I'm getting about 108 mbps (plus it's a more stable/smooth download vs suricata, which was more "jumpy"). I've ran the test 2x between the two, and same result. Suricata came to be the bottleneck for me. And Suricata couldn't download Snort VRT rule set, so, snort had a larger rule set running as well. (although I've never seen a single VRT rule triggered, only the custom rules and the ET rules).

                        I'll try Suricata again once the 2.0 comes to pfsense. Hopefully that'll perform better.

                        Just my 2 cents. Thanks for the help!

                        1 Reply Last reply Reply Quote 0
                        • ?
                          A Former User
                          last edited by

                          It would be interesting to see more details about your setup. Did you disable the rules I recommended in this topic? Even the amazon one (yes that single rule does matter)? How much RAM was used? Nice to see that a dual core atom @ 1.86Ghz can (nearly) max out 100Mbps. I'm sure with a bit of tuning it could get there, unless you have already removed suricata and installed snort.

                          Don't worry about the VRT rules.

                          1 Reply Last reply Reply Quote 0
                          • C
                            Cino
                            last edited by

                            I have TWC. I'm currently 100/5. I have both snort and suricata running on my D510 Atom with no issue. Running speed test, I can max out at 107-110mbps. CPU% anywhere from 45% to 100%. If I download torrents, cpu will peg at 100% but i'm still able to browse with no issues.

                            1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User
                              last edited by

                              Respect for the little atoms that could  ;D. The newer 4 core models (technically a celeron, or is it the other way around?) are interesting, thinking about getting a couple for testing. A fully loaded psfsense system based on those should be close to 30W (cpu+cards+hdd).

                              1 Reply Last reply Reply Quote 0
                              • C
                                Cino
                                last edited by

                                I want to say my D510 box is running around 20-25watts. Have to find my build notes to confirm. off topic but I have a few interfaces, traffic shaping, snort, pfblocker, suricta, squid, ntop, vnstat… she runs good... Need to change her it 64bit so I can use all of the 4gb of memory but I think i'll wait for 2.2 to be release then do a fresh install and rebuild the config for fun  :o

                                1 Reply Last reply Reply Quote 0
                                • ?
                                  A Former User
                                  last edited by

                                  @Cino:

                                  I want to say my D510 box is running around 20-25watts. Have to find my build notes to confirm. off topic but I have a few interfaces, traffic shaping, snort, pfblocker, suricta, squid, ntop, vnstat… she runs good... Need to change her it 64bit so I can use all of the 4gb of memory but I think i'll wait for 2.2 to be release then do a fresh install and rebuild the config for fun  :o

                                  Ah, the Debian bug. Nothing happens to it, to the point where you want to upgrade to testing just for the hope of something breaking? :p

                                  Atoms are perfect for personal use, IMHO.

                                  1 Reply Last reply Reply Quote 0
                                  • bmeeksB
                                    bmeeks
                                    last edited by

                                    @jflsakfja:

                                    @dmitripr:

                                    Thanks, jflsakfja. That rule syntax worked.

                                    I see that the latest Suricata release is 2.0.3. Any ideas when pfsense package will be upgraded to that version? Is there a way to manually update?

                                    I have noticed that as of late I'm being pinged from multiple hosts for several minutes at a time. Feels like an attack from hijacked hosts. I put a rule to block those, and I was able to block almost 500 hosts in 24 hours via suricata.

                                    Thanks again!

                                    I think 2.x is coming with the next release of the suricata package. How long that takes, dunno though.

                                    The pings are regular internet noise. Don't worry about it. As long as you are not responding back, then you are still flying under the radar.

                                    I am hopefully just a week or so away from posting the Pull Request for 2.0.x Suricata.  I ran into a small snag compiling the new package for 2.2 of pfSense, but I think I have a solution for that now.  I have been developing/testing with 2.0.2, but if it's not too big of a change I will bump it to 2.0.3 before I post the Pull Request.

                                    Bill

                                    1 Reply Last reply Reply Quote 0
                                    • M
                                      Mr. Jingles
                                      last edited by

                                      @bmeeks:

                                      I am hopefully just a week or so away from posting the Pull Request for 2.0.x Suricata.  I ran into a small snag compiling the new package for 2.2 of pfSense, but I think I have a solution for that now.  I have been developing/testing with 2.0.2, but if it's not too big of a change I will bump it to 2.0.3 before I post the Pull Request.

                                      Bill

                                      Hi Bill  ;D

                                      Would that also include the suggestion from one of the biggest noobs on this board to have an easy way to multi-enable/disable the rules per category (the same check boxes you see in the left side of the firewall rules screens)?

                                      That would be quite lovely, so to speak :P

                                      6 and a half billion people know that they are stupid, agressive, lower life forms.

                                      1 Reply Last reply Reply Quote 0
                                      • M
                                        Mr. Jingles
                                        last edited by

                                        A most stupid question, for which I am by now famous: wat is the OpenVPN-interface; WAN or LAN?

                                        Virtual Private Network would suggest LAN, but on the other hand: it is connected to the WAN  ???

                                        6 and a half billion people know that they are stupid, agressive, lower life forms.

                                        1 Reply Last reply Reply Quote 0
                                        • D
                                          dmitripr
                                          last edited by

                                          @jflsakfja:

                                          It would be interesting to see more details about your setup. Did you disable the rules I recommended in this topic? Even the amazon one (yes that single rule does matter)? How much RAM was used? Nice to see that a dual core atom @ 1.86Ghz can (nearly) max out 100Mbps. I'm sure with a bit of tuning it could get there, unless you have already removed suricata and installed snort.

                                          Don't worry about the VRT rules.

                                          My setup is pretty simple, bough off the newegg:
                                          ** OEM Production 2550L2D-MxPC Intel NM10 Black Mini / Booksize Barebone System - OEM (http://www.newegg.com/Product/Product.aspx?Item=N82E16856205007)
                                          ** 4GB of RAM
                                          ** 32GB SSD
                                          ** Latest version of pfsense
                                          ** 1 LAN+ 1 WAN + IPsec + OpenVPN
                                          ** Bind, snort/suricata (not at the same time), pfblocker

                                          It has dual Broadcom nics, which is not too bad. If I disable the snort/suricata IPS, then @108 mbps down the CPU load is only 33% or so. So, theoretically this thing should be able to push 250 mbps easily. Not too shabby.

                                          On the suricata setup, I followed your instructions for the rules. So, I did turn off the ones you mentioned in the posts here. However, I did have dshield and DROP categories enabled – apparently pfblocker doesn't have all the latest IPs for those, and some get though to IPS and are blocked there. For comparison sake, I have the same rules enabled for snort (just keeping it apples-to-apples).

                                          I'm a believer in suricata, based on what I read, but probably not quite prime-time ready (at least in my setup, based on my limited testing). I have not uninstalled it, just disabled it at this point. I'll try again once 2.x.x comes out, hopefully soon.

                                          1 Reply Last reply Reply Quote 0
                                          • D
                                            Double K
                                            last edited by

                                            @BBcan177:

                                            …
                                            The High Level function of the script:

                                            Download Individual List
                                              Extract IPs
                                              Save copy to /orig Folder
                                              Check for Ranges that have 255 IPs and mark a single /24 Range
                                              Process /24 (Which looks for repeat Offenders in a /24 Range) (max variable) Individual Blocklist Only.
                                              Duplication Check

                                            Once all of the Downloads are completed that were scheduled to run:

                                            The Following is performed Globally on ALL Lists, except for the ones that were marked as "p24=no" on the Collect Line.

                                            p-Deduplication - Looks for Repeat Offenders that are over the pmax variable regardless of Country Code.

                                            d-DeDuplication - Looks for Repeat Offenders that are over the dmax variable but uses the Country Code Whitelist function.

                                            If the Sanity Checks passes, it will create the TIER (Group) lists and perform the "pfctl" commands to update the pfSense Alias Tables.

                                            If you decide to remove a list, you need to add "remove" after the collect line. When the script runs at its next scheduled run, it will remove the list from the database properly. Don't try to do this manually.

                                            If you follow the High level steps, when you use the p24 process in d-deduplicaton, it will look for a repeat range of malicious IPs and find all of the Blocklists that have this IP listed.

                                            The FIRST blocklists get a single x.x.x.0/24 Block and all of the other Lists that have the range are deleted.

                                            So if a List is removed, and it happens to be a list that had the p24 process and was the first list processed as above, then you have no Blocklists for that range. This will correct itself on when the Lists are re-downloaded but that could be 1-4hrs depending on when the Lists are scheduled to run.

                                            To get back into Sync, you can run this function:

                                            [  [b]./pfiprep killdb  ]

                                            Which will wipe the Database (Settings are not touched) and it will resync the database.

                                            Out of Curiosity, which Lists did you disable?

                                            Another Function is to use the "IR_Match" Alias in the Floating Rules as a "Match" Rule. This will show you activity for the IP Ranges that passed the Country Code Whitelist process. Because its a "Match" rule, it will not block, but just log the activity.

                                            Since I have been running the script, I have not found too many False Positives, but I always recommend not to disable a list but to create a "SAFE Alias" Rule that is defined above the "Block/Reject" Rules. And just add the IPs that you want to allow.

                                            The Patch for diag_dns.php will also work when looking at the Snort/Suricata Alert Logs.

                                            If you are running Snort/Suricata, when you click on the "!" ICON to Resolve an IP, you will find that most of the IPs are already listed in the BlockLists. You will also see over time that it will pickup an Alert for an IP but the Blocklists do not have the specific IP but there are several IPs within the same Range that are being Blocked.

                                            Also in diag_dns.php, there are several IP Reputation Links that can help you determine the Reputation of any Blocked IP before you remove a list, or Add an IP to the SAFE Alias list.

                                            Let me know if you need any clarification or any other help.

                                            Hi BBcan177, thanks for all your help setting up the scripts.  I managed to get everything setup, including the widgets & the DNS patch.

                                            Could you please shed some more light on the max, dmax, and pmax variables?  Not completely clear on the differences between them and how they operate.
                                            For example, upon first run (using max=5, dmax=5, pmax=50), I had 7 unique addresses in the 104.28.7.x range in the IR_Match alias file.  This also created a 104.28.7.0/24 entry as well.  I tried accessing a site that was not one of the unique addresses (ie. not blocked by the lists), but it was blocked by the /24 range.  When I changed max=10 and dmax=10, not only does the /24 range not appear (good) but the 7 unique blocked addresses don't appear either (bad).
                                            Thus, just need a better understanding of how max, dmax, and pmax work, and what happens when you change the values.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.