Netgate SG-1000 microFirewall

Author Topic: Taming the beasts... aka suricata blueprint  (Read 93519 times)

0 Members and 1 Guest are viewing this topic.

Offline 2chemlud

  • Sr. Member
  • ****
  • Posts: 385
  • Karma: +20/-5
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #450 on: May 13, 2016, 01:53:13 am »
Not an expert, but I guess... yes

https://forum.pfsense.org/index.php?topic=88244.0


Offline TDJ211

  • Jr. Member
  • **
  • Posts: 36
  • Karma: +2/-0
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #451 on: May 13, 2016, 02:05:07 am »
Thats not it....They eventually gave him permission to use a disclaimer and from that point on, the project was under way. But then  jflsakfja got into a serious car accident and he's just had to put all of this on pause til he gets better.

Offline glint.bladesong

  • Jr. Member
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #452 on: May 13, 2016, 08:01:29 am »
If that is indeed that case then he has my deepest and genuine sympathies and I wish him a hearty, fast and total recovery.

Offline pfBasic

  • Hero Member
  • *****
  • Posts: 1021
  • Karma: +139/-22
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #453 on: July 06, 2016, 06:13:50 pm »
First off, great topic! I am completely new to all of this and I've spent hours reading through this topic and looking out over the internet to try to understand it.

The reason I made an account and posted is because I attempted to type up a How-To for the super-layman.
I attached it here and would love to get your feedback on it. There are certainly fundamental errors in it simply because I do not understand this stuff and my interpretations of what's going on are bound to be incorrect (hopefully not all the time).
If those of you who know what's going on would be so kind as to give me feedback and correct me, I'll revise and re-post the corrected copy. The intent is to have a document that I or someone like myself could pick up and use to setup pfSense in a secure way without any prior knowledge.


So I got on eBay and for $130 purchased a SFF HP with an i5-2400, 8GB RAM and 640GB HDD and an Intel PRO/1000 PT dual NIC. I know it's overkill, but it was cheap.
Going through MANY hours of youtube tutorials on pfSense and networking in general I learned that most of what I want to do on pfSense can be achieved by simply following instructions without very much understanding. However, it seemed to me that Firewall rules (what pfSense was actually made for) actually needed to be understood at least on a basic level since it is so specific to what you're using it for. Then I found this thread, I read through it, and didn't understand much. So I read through more, researched things online and started typing up a step-by-step document that I could use to accomplish each task and have some understanding of what I was doing. I didn't accomplish that completely, there are things that I know I don't fully understand, and I'm sure other things that I misunderstand.
It's worth noting that I haven't actually been able to attempt any of this on pfSense yet.

Anyways, thank you for what you've done and I'd appreciate any of your expertise and guidance!



Here we go!

Firewalling
Always whitelist, NEVER blacklist...

<<<<<Everything I tried to understand and included in my writeup thus far is contained between these two quotes from the OP.>>>>>> 

...Back to where we left. Nobody likes his internet being down (I grew tired of having to explain that the Internet was designed to survive a nuclear holocaust without it being down, if you can't beat them, join them). So hurry up with the other interfaces as well.
« Last Edit: February 17, 2017, 04:11:35 pm by pfBasic »

Offline pfBasic

  • Hero Member
  • *****
  • Posts: 1021
  • Karma: +139/-22
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #454 on: July 07, 2016, 05:47:56 pm »
I reformatted the tables in the word document so that I could publish what I'm trying to do directly here and no one has to download the word document. There are a lot of hyperlinks that are included on the word doc but not on this post, so if you see something that looks like it should be hyperlinked, it is on the .doc.

ANY help you guys can give me would be greatly appreciated!

I'm reading through tons of BBCan117's posts on pfBlockerNG trying to learn how to use it to accomplish this setup. I'll post that as soon as I'm done, but remember my done does not equal a finished product. I'll need correction from you guys to get this right.

-----------------------------------------

EDIT: Removed due to potentially misleading info.
« Last Edit: February 15, 2017, 12:54:11 am by pfBasic »

Offline BBcan177

  • Hero Member
  • *****
  • Posts: 2608
  • Karma: +821/-5
    • View Profile
    • Click for Support
Re: Taming the beasts... aka suricata blueprint
« Reply #455 on: July 07, 2016, 10:12:36 pm »
I'm reading through tons of BBCan117's posts on pfBlockerNG trying to learn how to use it to accomplish this setup. I'll post that as soon as I'm done, but remember my done does not equal a finished product. I'll need correction from you guys to get this right.

Thanks for all your efforts.. :)

Just to note, that my posts in relation to the script should be ignored, as its now superceded by the package pfBlockerNG...

https://forum.pfsense.org/index.php?topic=102470.0
https://forum.pfsense.org/index.php?topic=86212.0
"Experience is something you don't get until just after you need it."

 | http://pfblockerng.com | Twitter @BBcan177  | #pfBlockerNG |

Offline pfBasic

  • Hero Member
  • *****
  • Posts: 1021
  • Karma: +139/-22
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #456 on: July 08, 2016, 02:32:26 am »
I'm reading through tons of BBCan117's posts on pfBlockerNG trying to learn how to use it to accomplish this setup. I'll post that as soon as I'm done, but remember my done does not equal a finished product. I'll need correction from you guys to get this right.

Thanks for all your efforts.. :)

Just to note, that my posts in relation to the script should be ignored, as its now superceded by the package pfBlockerNG...

https://forum.pfsense.org/index.php?topic=102470.0
https://forum.pfsense.org/index.php?topic=86212.0


Yes sir, I am reading through your threads on pfBNG and trying to figure out how to use that to accomplish this threads intent without messing it up!

Offline kody

  • Newbie
  • *
  • Posts: 16
  • Karma: +1/-0
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #457 on: July 19, 2016, 12:39:20 pm »
pfBasic, did you just edit/reformat the content in the original post by “jflsakfja”?

Or, did you adapt the content in the original post to a later version of pfSense? If so, which version did you use for your document?

Thanks.

Offline neonmatt

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
  • 'A frog in a well does not know the great ocean'
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #458 on: July 25, 2016, 09:35:41 am »
PFBasic, the word doc looks nice.  I've come back to this after a long time working on other stuff, so thanks for condensing this very long thread.  I look forward to implementing Suricata soon  (getting ready to set aside some time to get into it without interruption).

I hope it's OP is well and doing great things (I'm sure that's a given).
"The art of war teaches us to rely not on the likelihood of the enemy's not coming, but on our own readiness to receive him; not on the chance of his not attacking, but rather on the fact that we have made our position unassailable."

Offline pfBasic

  • Hero Member
  • *****
  • Posts: 1021
  • Karma: +139/-22
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #459 on: August 19, 2016, 03:14:51 pm »
I'm glad the documents are helping out. I've finally started implementing all of this stuff on my own and there's a lot in the document that I need to change/add/update. So don't just use that document to set your system up, you'll have to do some of your own reading as well.

I simply copy/pasted and added explanations as best I could and tried to update some stuff based on new releases.

I too am nearing the point where I want to implement suricata as described here. Unfortunately I have absolutely NO idea what the "Golden Rules" are or how to add them to pfSense.

If anyone can help me out with the "Golden Rules" that please PM me, I'm lost.

EDIT: for anyone stumbling across this thread again, see quoted post, these are the "golden rules" as I understand them.

Code: [Select]
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"
« Last Edit: February 17, 2017, 04:16:48 pm by pfBasic »

Offline perth

  • Newbie
  • *
  • Posts: 18
  • Karma: +5/-0
  • Between A and B there's C.
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #460 on: September 17, 2016, 06:02:57 pm »
PFFEEEEEEEEWWWW, made it!!!

Let me start of by saying thank you jflsakfja, you're a real Frood & will be missed.
To BBcan177, Cino, bmeeks/Bill, and yes, The Eternal Noob Mr. Jingles/Hollander thank you too. This thread would not be what it is without your contributions.
PM me a way to send you $7 and you can have a "serious beer" ;) on me. (Provided I don't have to sign up for some overly shady or new startup run by 3 ppl...)

I've copy/pasted "all" instructional posts from this topic into a text document. I've included some troubleshooting posts as well. Excluding the first entry of BBcan117 informing everyone to use pfBlockerNG instead of his script, all posts are in chronological order; all posts include attribution & a direct link to the original post. I thought I'd make it available to others: https://bpaste.net/raw/0352fd6f5706 as it saves a lot of reading. But let me be clear: this document is intended to serve as my own starting point for understanding this setup before attempting to implement it. It's not some well formatted nor updated guide. Same data, with non-critical discussion posts removed.

@pfBasic: RE: Golden Rules
See:
...QUIZ: Who remembers why low (privileged ports) are useful?

Using the low ports we can detect port scans looking like legitimate traffic reaching "official" server ports.
...
In other words, packets from a source NOT our home network (or belonging to an external network) and a source port of any, reaching a port NOT in use on our home network, will alert us.
Congratulations young grasshopper, you have just created the world's top snort/suricata rule. It is internally referred to in The Company as "The Golden Standard for writing IDS/IPS rules" or, depending on the day "The two rules to rule them all". Why is it the golden standard? Those of you that failed to see that it is impossible to cause a false positive by this rule so far are dangerously close to failing the class. Unless you ignored a port in use (which shouldn't happen all that often) a packet that triggers this rule is a packet that will not route across pfsense. Simply put: a legitimate alert.
Be extremely careful with the knowledge. It can be used for good, or it can cause great harm. These two (a TCP and a UDP), the "The two rules to rule them all", rules accounts for 10K monthly banned hosts (hosts set up to be unbanned after 28 days, but trigger the rule before that).
...
(I'm going to try and rephrase this such than "anyone" can understand it, because this is visible to the world, not because I have an opinion on your mental capabilities pfBasic;)
IOW: The Golden Rules appear to be two custom Suricata rules you create that are tailored your your network. Tailored to look for traffic coming in from outside your network destined for unused privileged ports. Privileged ports are ports 1 though port 1024, they are ports reserved for services like http(s), ssh, ftp, etc. If there's something that should be reachable from outside your network on these ports it's because "you" are intentionally running a "server". So you know to expect traffic destined to a few specific ports in this range, right? Therefore traffic destined for those ports is expected and you exclude from these rules; because *drum roll* all unexpected traffic destined for privileged ports is basically guaranteed to be some form of malicious activity (probably a port scan). These rules allow you to detect that undesired traffic & begin dropping traffic to/from the offending source IPs. Dropping all further traffic to/from these IPs stops those IPs from being able to continue to attack your network.

To put it (my understanding) more generically, intelligently, and far more succinctly: the Golden Rules detect traffic to ports explicitly blocked by the firewall. Detecting traffic to explicitly blocked 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! :)
Between A and B there's C.

Offline Mr. Jingles

  • Hero Member
  • *****
  • Posts: 1136
  • Karma: +92/-724
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #461 on: September 18, 2016, 01:04:10 pm »
PFFEEEEEEEEWWWW, made it!!!

-snip-


I just hit the thank you button since your post is very friendly and informative, but I'm told I already thanked somebody in this thread in july 2014, and more thanks are forbidden, this appears the current state of things in the year of our evolution 2016 ( ;D ;D ;D ).

So I'll simply say it here: thank you for your post  ;D

I especially like it that you like to offer the package devs a beer, which is how I thank people too. Since I'm only the eternal noob, that offer can never be for me, but you indeed mentioned JFL, BB, Bill, Cino; great people on this board, true Open Source people.
6 and a half billion people know that they are stupid, agressive, lower life forms.

Offline molykule

  • Newbie
  • *
  • Posts: 16
  • Karma: +1/-0
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #462 on: November 30, 2016, 07:25:08 am »
ACTION:   BLOCK
DISABLED:   DO NOT ✓
QUICK:   ✓
INTERFACE:   Gnet24 (CTRL+Click all interfaces that you don’t want to access LAN)
DIRECTION:   ANY
TCP/IP VERSION:   IPv4 & IPv6 (I will use only IPv4)
PROTOCOL:   TCP
SOURCE:   ANY
DESTINATION:   ANY
DESTINATION PORT RANGE:   OUTGOING_PORTS


Hi,

I am confused on the last bit of rules here by pfBasic (pasted above). Doesnt this rule means to stop all the traffic on the other interfaces (Gnet24) on outgoing_ports. Shouldnt the destination be the LAN here or am i missing something,
thanks for your great tutorial in word. It helped me a lot,
molykule

Offline pfBasic

  • Hero Member
  • *****
  • Posts: 1021
  • Karma: +139/-22
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #463 on: February 15, 2017, 01:48:20 am »
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.
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 to explicitly 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:
Code: [Select]
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!
« Last Edit: April 19, 2017, 03:26:23 am by pfBasic »

Offline werkkrew

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Taming the beasts... aka suricata blueprint
« Reply #464 on: April 22, 2017, 09:57:15 pm »
That interpreted to the proper syntax to create a suricata rule(as I understand it at least) translates to these two rules:
Code: [Select]
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.