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 302.1k 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.
    • W
      werkkrew
      last edited by

      @pfBasic:

      That interpreted to the proper syntax to create a suricata rule(as I understand it at least) translates to these two rules:

      drop tcp !$MY_NET any -> any !$MY_PORT (msg:"The Golden Rule, TCP"; classtype:network-scan; sid:9000; rev:1;)
      drop udp !$MY_NET any -> any !$MY_PORT (msg:"The Golden Rule, UDP"; classtype:network-scan; sid:9001; rev:1;)
      

      $MY_NET and $MY_PORT are variables you'll need to specify as necessary for your own network in /usr/local/pkg/suricata/suricata_yaml_template.inc under the "vars:" section. The "!" in front of the variables means "not", so it would read:
      drop tcp/udp traffic from "anywhere not on my network" on any port going to anywhere on "any port not specifically allowed on my network"

      I'm not sure these are right.  Looks as if they would not take into account established outbound connections and block incoming traffic regardless if its related to an established outbound connection.

      I am not sure exactly what the base set of "golden rules" should actually look like but I don't think these are quite right.

      1 Reply Last reply Reply Quote 0
      • P
        pfBasic Banned
        last edited by

        I'm certainly no guru and they could be wrong.

        Whether the connection is already established or not won't matter (as I understand it). In fact, in Legacy mode (which almost everyone uses) some packets will make it through inspection even if they should be dropped because the filter is not inline. When the traffic matched, remaining packets are dropped and the state is closed. The same would apply to these rules.

        All they say is:

        drop: TCP/UDP traffic with an address not on my network on any port that is going to any address on any port that I don't use.

        1 Reply Last reply Reply Quote 0
        • N
          n3by
          last edited by

          Me I suggest this approach that will save you to edit in Suricata variables:

          • first 2 lines will drop traffic that come to your external IP from/on low ports:
          • next line will drop all UDP traffic that come to your external IP on low ports ( use it if you don't have a server listening for that traffic )
          • next lines will drop all TCP traffic that come to your external IP on low ports except ports: 25, 443, 465, 993 ( adjust it as you need )
          drop tcp $EXTERNAL_NET [0:1023] -> $HOME_NET [0:1023](msg:"Golden Rule BAD TCP"; classtype:attempted-recon; sid:9900001; rev:1;)
          drop udp $EXTERNAL_NET [0:1023] -> $HOME_NET [0:1023] (msg:"Golden Rule BAD UDP"; classtype:attempted-recon; sid:9900002; rev:1;)
          drop udp $EXTERNAL_NET any -> $HOME_NET [0:1023] (msg:"Golden Rule NO SERVER UDP"; classtype:network-scan; sid:9900003; rev:1;)
          drop tcp $EXTERNAL_NET any -> $HOME_NET [0:1023,![25,443,465,993]] (msg:"Golden Rule NO SERVER TCP"; classtype:network-scan; sid:9900004; rev:2;)
          

          edit
          in case the last line rev:2 is not working for you replace with this:

          drop tcp $EXTERNAL_NET any -> $HOME_NET [0:24] (msg:"Golden Rule NO SERVER TCP"; classtype:network-scan; sid:9900004; rev:1;)
          drop tcp $EXTERNAL_NET any -> $HOME_NET [26:442] (msg:"Golden Rule NO SERVER TCP"; classtype:network-scan; sid:9900005; rev:1;)
          drop tcp $EXTERNAL_NET any -> $HOME_NET [444:464] (msg:"Golden Rule NO SERVER TCP"; classtype:network-scan; sid:9900006; rev:1;)
          drop tcp $EXTERNAL_NET any -> $HOME_NET [466:992] (msg:"Golden Rule NO SERVER TCP"; classtype:network-scan; sid:9900007; rev:1;)
          drop tcp $EXTERNAL_NET any -> $HOME_NET [994:1023] (msg:"Golden Rule NO SERVER TCP"; classtype:network-scan; sid:9900008; rev:1;)
          
          1 Reply Last reply Reply Quote 0
          • asv345hA
            asv345h
            last edited by

            I've been thru this thread in detail and I'm not sure I understand the purpose of these "golden rules". The default block rule on the WAN interface will catch them anyway. What am I not seeing?

            1 Reply Last reply Reply Quote 0
            • P
              pfBasic Banned
              last edited by

              the point is to add potential attackers to the snort2c list so that they are blocked even if they do make a legitimate connection attempt.

              firewall rules alone won't stop that.

              It's interesting in theory, I'm not sure that it's actually very useful in practice.

              1 Reply Last reply Reply Quote 0
              • N
                n3by
                last edited by

                Added that Golden rules on two hosts located in different country, and here are some numbers in ~12h, IPs that try to access inexistent servers on low ports :

                • first host blocked > 200 IPs
                • second host blocked >500 IPs

                When they try to access servers available on this hosts they are already blocked.

                If you think this rules are not required for you then it is best not to install Suricata/Snort, it will do almost nothing good to your network, will just overload the CPU and cause trouble when blocked legitimate hosts.

                ![2017-04-24 09.54.06.jpg](/public/imported_attachments/1/2017-04-24 09.54.06.jpg)
                ![2017-04-24 09.54.06.jpg_thumb](/public/imported_attachments/1/2017-04-24 09.54.06.jpg_thumb)

                1 Reply Last reply Reply Quote 0
                • P
                  pfBasic Banned
                  last edited by

                  These rules are by no stretch of the imagination the best rules for snort suricata. The proper implementation of the free snort and ET rules is easy more valuable.

                  1 Reply Last reply Reply Quote 0
                  • asv345hA
                    asv345h
                    last edited by

                    the point is to add potential attackers to the snort2c list so that they are blocked even if they do make a legitimate connection attempt.

                    That makes sense now. If you get port scans on non-used ports, say 23, then, when the same ip scans port 80, it will be auto blocked even if that port is forwarded to an internal server. I guess that assumes the auto generated block rules are placed after the web servers allow rule. I'm not sure how the auto-blocking works though.

                    1 Reply Last reply Reply Quote 0
                    • N
                      n3by
                      last edited by

                      In ~48h using rules to block non existent services on first 1000 ports (and few others) each Suricata from my 2 servers blocked ~1000 IPs without any false positive.

                      I can say this is a good start for anybody.

                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [3389] (msg:"Admin Rule NO SERVER RDP TCP"; classtype:network-scan; sid:990050; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [5500] (msg:"Admin Rule NO SERVER VNC TCP"; classtype:network-scan; sid:990052; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [5800] (msg:"Admin Rule NO SERVER VNC TCP"; classtype:network-scan; sid:990053; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [5900] (msg:"Admin Rule NO SERVER VNC TCP"; classtype:network-scan; sid:990054; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [4899] (msg:"Admin Rule NO SERVER RADMIN TCP"; classtype:network-scan; sid:990055; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [1433] (msg:"Admin Rule NO SERVER MSSQL TCP"; classtype:network-scan; sid:990057; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [5060] (msg:"Admin Rule NO SERVER SIP TCP"; classtype:network-scan; sid:990059; rev:1;)
                      drop udp $EXTERNAL_NET [1024:65535] -> $HOME_NET [5060] (msg:"Admin Rule NO SERVER SIP UDP"; classtype:attempted-recon; sid:9900060; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [8172] (msg:"Admin Rule NO SERVER IIS TCP"; classtype:network-scan; sid:990061; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [31337] (msg:"Admin Rule NO SERVER Back Orifice TCP"; classtype:network-scan; sid:990063; rev:1;)
                      drop tcp $EXTERNAL_NET [1024:65535] -> $HOME_NET [47001] (msg:"Admin Rule NO SERVER WinRM TCP"; classtype:network-scan; sid:990064; rev:1;)
                      
                      1 Reply Last reply Reply Quote 0
                      • P
                        pfBasic Banned
                        last edited by

                        Those two rules keep ~20k+ IPs on my 28 day snort2c table.

                        1 Reply Last reply Reply Quote 0
                        • asv345hA
                          asv345h
                          last edited by

                          I was running in-line which is why those rules seemed to have little purpose. Switched to legacy - I get it now.

                          1 Reply Last reply Reply Quote 0
                          • N
                            n3by
                            last edited by

                            Doublepulsar detection Snort/Suricata rules

                            https://github.com/countercept/doublepulsar-detection-script/blob/master/doublepulsar_snort_rules.rules

                            # Authors: Jayden Zheng (@fuseyjz) and Wei-Chea Ang (@77_6A)
                            # Company: Countercept
                            # Website: https://countercept.com
                            # Twitter: @countercept
                            
                            alert tcp any any -> $HOME_NET 445 (msg:"DOUBLEPULSAR SMB implant - Unimplemented Trans2 Session Setup Subcommand Request"; flow:to_server, established; content:"|FF|SMB|32|"; depth:5; offset:4; content:"|0E 00|"; distance:56; within:2; reference:url,https://twitter.com/countercept/status/853282053323935749; sid:1618009; classtype:attempted-user; rev:1;)
                            
                            alert tcp $HOME_NET 445 -> any any (msg:"DOUBLEPULSAR SMB implant - Unimplemented Trans2 Session Setup Subcommand - 81 Response"; flow:to_client, established; content:"|FF|SMB|32|"; depth:5; offset:4; content:"|51 00|"; distance:25; within:2; reference:url,https://twitter.com/countercept/status/853282053323935749; sid:1618008; classtype:attempted-user; rev:1;)
                            
                            alert tcp $HOME_NET 445 -> any any (msg:"DOUBLEPULSAR SMB implant - Unimplemented Trans2 Session Setup Subcommand - 82 Response"; flow:to_client, established; content:"|FF|SMB|32|"; depth:5; offset:4; content:"|52 00|"; distance:25; within:2; reference:url,https://twitter.com/countercept/status/853282053323935749; sid:1618010; classtype:attempted-user; rev:1;)
                            
                            1 Reply Last reply Reply Quote 0
                            • SLIMaxPowerS
                              SLIMaxPower
                              last edited by

                              @ecfx:

                              Be careful with chosen ports, not to be used by normal applications because you will cut access to this ports.

                              You will put restriction rule from LAN only if you want to have specifics designated computers that can access the admin ports.

                              Attached floating rule for WAN and rule for LAN.

                              p.s.
                              you can use as destination: "This firewall (self)" instead of any

                              Another newbie trying to get this sorted on a home net.  I followed the initial post and blocked all traffic.

                              When I enabled the wan floating rule and lan rule I get locked out of the gui and have to revert to a previous config and reboot to get access to the box again.

                              1 Reply Last reply Reply Quote 0
                              • S
                                sheen73
                                last edited by

                                Hi All,
                                Very new to Pfsense, just started to research snort and suricata. Came to this post  and have read through it but still stuck. I am using Pfsense 2.3.4 and open VPN client with PIA, I have NAT setup to direct lan / wan to the PIA interface. I have a firewall rule for lan on LANnet to use the PIA DHCP gateway.

                                As soon as I apply the below instructions, my internet access shuts down. Note only interfaces I have are LAN, WAN, PIA, OpenVPN (not used and does not exist, not sure why its on the list)

                                "Next up Floating tab:
                                Set up a rule but make these changes:
                                Action Block
                                Quick TICKED!!!
                                Interface Hold CTRL and click on all interfaces EXCEPT LAN(admin) and SYNC
                                Direction any
                                Source any
                                Destination any"

                                I think I am misunderstanding this portion

                                "Head over to an interface's tab and set up a an allow rule. Source should be the interface's subnet. The destination should be any, and for the ports use the outgoing_ports alias created above. Destination should be any. Otherwise identical to the webgui rule. Warning! This allows any host to access any other host on other interfaces using those ports. If this is not needed (and generally it shouldn't), finish the rule, and head over to the floating rules tab."

                                What am I supposed to do here? The floating rule takes precedent over all other rules 1st, any rule after this would still be blocked no? I added another LAN firewall rule and set source to LANNet and destination ports to the outbound port alias and no luck.

                                Any tips?
                                Thanks!

                                23.05.1-RELEASE (amd64) on 6100 MAX / Arris S33 Spectrum / Ubiquiti Networks 8-Port UniFi Switch, Managed PoE+ Gigabit Switch with SFP, 150W (US-8-150W) / Unifi U6LR

                                1 Reply Last reply Reply Quote 0
                                • R
                                  rdm_577
                                  last edited by

                                  Hello all,

                                  I signed up for this forum specifically to ask this question of this community / thread. Thanks in advance.

                                  I'm greatly interested in setting up a pfsense firewall in the manner described under this thread but I have basically one reservation about doing so and therefore I'd like an honest assessment from those that have gone before me.  I am NOT an IT professional but I am a reasonably intelligent and computer savvy novice with above average understanding of routed networks.  I don't mind doing my own research / problem solving and while I'm relatively new to Unix / Linux I'm a fairly quick learner.  I've read the entire thread, multiple times.

                                  Given those facts, if I correctly set up pfSense according to this guide, realistically what on-going time commitment am I making with respect to updating the rules, known threat list, etc.  Once I get the firewall up and running according to this guide, will it run without much tinkering, problem solving, and updating or will it turn into a time sucking black hole that takes away from my regular job, wife, children, and hobbies that I prefer to network administration?

                                  I have a simple home network with limited services and requirements.  I currently run dd-wrt using multiple lans / vlans for the various network segments that I have in house but am interested in upgrading my perimeter security as long as it can be done without becoming a full time network admin job on top of my other commitments.

                                  Thoughts and comments are appreciated.

                                  1 Reply Last reply Reply Quote 0
                                  • P
                                    pfBasic Banned
                                    last edited by

                                    I started on pfSense in the same boat less the understanding of routed networks.

                                    I've spent a lot of time messing around on pfSense but 95% of that time he been out of curiosity, not to make it work.

                                    I wouldn't recommend following this guide exactly, it's old and there are better ways to do much of this.

                                    Suricata can be a time sucker. You probably don't need it on a home network. Even if you only use the "Golden Rules" on WAN it can cause some issues with certain types of setups.

                                    You can get a stable filtered and secure home network up and running pretty quickly with just firewall rules, pfBlockerNG and DNSBL.

                                    Later on if you want to play around with it and have some time to deal with false positives check out suricata.

                                    Id recommend avoiding squid and it's related packages entirely on a home network. It sounds cool in theory but in practice is more of a pain than a help on small home networks.

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

                                      Hello all,

                                      I am not sure to be right her - so sorry in advance in case to be wrong.

                                      For some weeks I have some troubles with my pfSense on APU1D4 :-(
                                      The symptom is: I have no connection to internet - there is no public IP on my GW …
                                      If I restart the pfSense, it works again for some time …
                                      After some weeks I also tried to restart the suricata service and it helps, too.

                                      Does it mean there is something NOK wit suricata on my pfSense ?

                                      I did not change anything before the symptom occurred :-(
                                      pfSense and suricata is on the last level.

                                      if anybody know the direction to start investigation, please help :-)

                                      Thanks a lot in advance !

                                      APU1D4 | pfSense 2.3.4 (amd64) | LAGG (LACP) <-> HP-1820-24G | pfBlockerNG | Suricata | WAN DOWN/UP 100/10

                                      1 Reply Last reply Reply Quote 0
                                      • stephenw10S
                                        stephenw10 Netgate Administrator
                                        last edited by

                                        Suricata/Snort is often a good place to look if you find things spontaneously get blocked.

                                        Try running Suricata in non-blocking mode for a some time to test that.

                                        You should also be able to clear to blocked hosts lists if that is happening and restore connectivity that way. You'll then need to find out what is being blocked and by which rules and take steps to prevent it happening again.

                                        Steve

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

                                          Hello Steve,

                                          thank you for your reply.

                                          Suricata is running as default, pattern-match is AC, block and Barnyard2 is DISABLED.
                                          If I look to Interfaces/WAN-Rules than I see „Rule will alert on traffic if triggered“ under Action header.

                                          Any further ideas ?

                                          Dariusz

                                          APU1D4 | pfSense 2.3.4 (amd64) | LAGG (LACP) <-> HP-1820-24G | pfBlockerNG | Suricata | WAN DOWN/UP 100/10

                                          1 Reply Last reply Reply Quote 0
                                          • stephenw10S
                                            stephenw10 Netgate Administrator
                                            last edited by

                                            If blocking is disabled then it's not Suricata or at least not in the expected way. It might be using all the available resources for example. You should see something logged if so though.

                                            You have other packages installed?

                                            How exactly is this presenting? You say the gateway looses its IP? The WAN gateway? The interface address itself? What type of WAN is it?

                                            Steve

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