Taming the beasts… aka suricata blueprint
-
Resurrecting this beast once again.
This topic is certainly outdated with a lot of information spread throughout but it was probably the thread that ultimately got me to start using pfSense.
I read through this thread before ever having installed pfSense and responded to it with attachments of my summaries and interpretations before I had ever even seen an actual pfSense GUI (because I was in a situation where I couldn't currently use pfSense, but was very interested). I've removed my attachments of summaries and interpretations because while some of the summaries may have been useful, I think they were ultimately misleading and counter productive and for that I apologize.
Having actually used pfSense for awhile now, I think I might have a better grasp on this (but still don't take me for my word, I'm in no way an IT pro; if you follow me blindly it's the blind leading the blind). So all I'd like to do here is summarize what I interpret the three basics steps of this guide to be in 2017's terms and hopefully get some responses as to whether or not I'm correct, and if not then set me straight.
My hope is that this huge and extremely informative but fragmented and dated thread might guide a few forum lurkers and google searchers towards pfSense or the better utilization of it.–-----------------------------------------------------------------------
1.) Do not use "allow any any any" rules unless you know what you're doing and have a reason. Understand that pfSense by default blocks everything you do not explicitly allow and use that to your advantage, i.e. whitelist, don't blacklist. I personally don't use all of the originally stated firewall rules anymore but I did for a while and I still use and write firewall rules and aliases based on what I learned in this thread.
If you are new to firewalling in general, simply following page 1 of this thread for your firewall rules will serve you well, you'll learn a lot and be starting from a great place.2.) Use pfBlockerNG. I'm pretty sure this thread started before pfBlocker existed (but maybe not?) But now everything in step 2 can be done better and easier using the package pfBlockerNG. pfBNG is a whole subject on its own, and has its own section on this forum with a wealth of info. Additionally its creator is extremely active and probably the most helpful and informative member I've encountered on this or any other forum, seriously. This forum holds everything you need to get pfBNG up and running with a great set of lists. With pfBNG and DNSBL (a feature of pfBNG) you can do a LOT more than what is described in step 2 of this thread, you can even implement auto updated shallalist into it with minimal effort. Take the time to learn this.
3.) Suricata is by far the single most complex aspect of this guide. I tried it shortly after starting to use pfSense and quickly realized I wasn't yet capable of even attempting it. I recommend you stick with steps 1 & 2 until you are reasonably comfortable with pfsense in general. Once that happens though, definitely check suricata out. I'm just now coming back to try to learn suricata. From everything I've read, suricata is not a package you just install, configure and forget. How difficult it is to effectively implement is really dependent on the complexity of your use case and your competence (mine is low in this subject area). When you are knowledgeable enough to check it out, try using it WITHOUT blocking (IDS), use it this way for a while (days, weeks, months, depends on you) until you figure out which rules are giving you false positives and disable them. Once you turn suricata on to block (IPS), if it isn't configured & tuned properly, it will probably just unnecessarily break a bunch of useful things because it isn't tailored to your network. This really is a drawn out process that involves a LOT of googling and reading if you are new like me.
All that having been said, do circle back around to suricata. The Golden Rule(s) is what is highly emphasized in step 3 of this thread. In my mind at least, perth did an excellent job of breaking this rule down for total beginners like myself.
@perth:To put it (my understanding) more generically, intelligently, and far more succinctly: the Golden Rules detect traffic to ports
explicitly blocked(EDIT: not explicitly passed) by the firewall. Detecting traffic toexplicitly blocked(not explicitly passed) ports provides a high quality method of identifying bad actors so that you can drop all further traffic to/from that IP. Typically you don't explicitly block ports higher than 1024 as they can (and are) used for legitimate traffic without you taking any special action (like installing a web server daemon). (Though 8080 might be a good exception to that rule.)
Hope this all helps! :)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"Those two custom rules alone without any other rules at all will provide what perth is summarizing and the OP intended, if my understanding is correct.
Obviously those two rules alone are not even close to harnessing the full power of suricata but it should be an excellent starting point because as jflsakfja pointed out, there will be no false positives with these rules. Additionally if suricata's basic configuration is not correct then these won't do you any good. So basically my suggestion remains that if you are completely new to this as I was, circle back to suricata once you have a basic understanding of what's going on.
Now hopefully someone smart doesn't come along only to tell me that I've still got it all wrong. At least if they do, I'll learn something!
-
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.
-
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.
-
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;)
-
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?
-
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.
-
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) -
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.
-
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.
-
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;)
-
Those two rules keep ~20k+ IPs on my 28 day snort2c table.
-
I was running in-line which is why those rules seemed to have little purpose. Switched to legacy - I get it now.
-
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;)
-
@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 anyAnother 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.
-
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! -
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.
-
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.
-
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 !
-
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
-
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