Skip to main content

Snort -h doesn't do what you think it does.

I've seen a lot of traffic recently of people trying to use "-h" on the Snort command line to specify the variable $HOME_NET, and it's generated a lot of confusion as of late, so I thought I better write about it.

If you look in the manual, every time -h is used, it's used with a network range, or an individual IP, and it's also used with -l, also only used with -vde (otherwise sniffer mode). It's not ever made clear exactly what -h actually does. Similarly if you type:

snort --help

on the command line the -h tag says:
-h Home network =

So, one might think that by doing a -h on the command line, it specifies the HOME_NET variable found in the snort.conf on the command line. Well, as you probably have guessed by now, this is not the case.

So here's the truth: -h actually has nothing to do with the HOME_NET as specified in the snort.conf file.

As we know,
var HOME_NET any

Will specify which direction traffic should be examined in terms of the rules within the detection engine.
var HOME_NET 192.168.0.0/16

In the snort.conf file is then filled in in all the rules that call $HOME_NET. This is not -h.

So, for example, the following rule:

alert tcp $HOME_NET any -> $EXTERNAL_NET any (msg:"Alert!"; content:"/content"; sid:10000001;)

In my Snort.conf

  • var HOME_NET any

  • var EXTERNAL_NET any



    I get the following alert:

    [**] [1:10000001:0] Alert! [**]

    [Priority: 0]

    03/29-16:57:47.361016 192.168.1.120:51968 -> 72.14.204.147:80

    TCP TTL:64 TOS:0x0 ID:13360 IpLen:20 DgmLen:993 DF

    ***AP*** Seq: 0xC03BC58E Ack: 0x8B9BF8F5 Win: 0x822B TcpLen: 32

    TCP Options (3) => NOP NOP TS: 63957188 2272801581

    If I define HOME_NET in the snort.conf



    • var HOME_NET 192.168.0.0/16

    • var EXTERNAL_NET any



    I still get the alert, okay.



    [**] [1:10000001:0] Alert! [**]

    [Priority: 0]

    03/29-16:57:47.361016 192.168.1.120:51968 -> 72.14.204.147:80

    TCP TTL:64 TOS:0x0 ID:13360 IpLen:20 DgmLen:993 DF

    ***AP*** Seq: 0xC03BC58E Ack: 0x8B9BF8F5 Win: 0x822B TcpLen: 32

    TCP Options (3) => NOP NOP TS: 63957188 2272801581

    If I define HOME_NET in the snort.conf as such:




    • var HOME_NET 72.14.0.0/16

    • var EXTERNAL_NET any



    I don't get an alert, exactly as planned, now... I conduct the same test. Same rule.



    • var HOME_NET any

    • var EXTERNAL_NET any



    In my snort.conf, but this time I am going to specify 192.168.0.0/16 in the -h command line tag.



    [**] [1:10000001:0] Alert! [**]

    [Priority: 0]

    03/29-16:57:47.361016 192.168.1.120:51968 -> 72.14.204.147:80

    TCP TTL:64 TOS:0x0 ID:13360 IpLen:20 DgmLen:993 DF

    ***AP*** Seq: 0xC03BC58E Ack: 0x8B9BF8F5 Win: 0x822B TcpLen: 32

    TCP Options (3) => NOP NOP TS: 63957188 2272801581

    Exactly as before.


    Now if I run -h with 72.14.0.0/16 at the command line I get the following alert



    [**] [1:10000001:0] Alert! [**]

    [Priority: 0]

    03/29-16:57:47.361016 192.168.1.120:51968 -> 72.14.204.147:80

    TCP TTL:64 TOS:0x0 ID:13360 IpLen:20 DgmLen:993 DF

    ***AP*** Seq: 0xC03BC58E Ack: 0x8B9BF8F5 Win: 0x822B TcpLen: 32

    TCP Options (3) => NOP NOP TS: 63957188 2272801581

    Where I should not have. So, no, it doesn't actually specify HOME_NET.


    So if you are trying to specify HOME_NET, you need to do it in the snort.conf file.


    -h, in fact, and after checking with development team and reading the code myself, -h corresponds to how packets are logged. (When using the old "log per directory" mode) However, this isn't very clear in the documentation, or in the --help file. So I've asked the developers to make this a bit more clear what -h does in the documentation as well as the code. It's pretty much only useful for Sniffer mode, not much for IDS mode.

    Comments

    You could probably mention the -S option, which is what you would use if you wanted to specify a variable on the command line..

    -S HOME_NET=[192.168.0.0/16]


    -S variable=value

    Set variable name "variable" to value "value". This is useful for setting the value of a defined variable name in a Snort rules file to a command line specified value. For instance, if you define a HOME_NET variable name inside of a Snort rules file, you can set this value from it’s predefined value at the command line.

    ./ebf0
    Joel said…
    Yes, I left it out intentionally for a future post and to not confuse people. I find it more productive to explain things separately then together. Better results that way and less confusion.
    You could probably mention the -S option, which is what you would use if you wanted to specify a variable on the command line..

    -S HOME_NET=[192.168.0.0/16]


    -S variable=value

    Set variable name "variable" to value "value". This is useful for setting the value of a defined variable name in a Snort rules file to a command line specified value. For instance, if you define a HOME_NET variable name inside of a Snort rules file, you can set this value from it’s predefined value at the command line.

    ./ebf0
    You could probably mention the -S option, which is what you would use if you wanted to specify a variable on the command line..

    -S HOME_NET=[192.168.0.0/16]


    -S variable=value

    Set variable name "variable" to value "value". This is useful for setting the value of a defined variable name in a Snort rules file to a command line specified value. For instance, if you define a HOME_NET variable name inside of a Snort rules file, you can set this value from it’s predefined value at the command line.

    ./ebf0
    Joel said…
    Yes, I left it out intentionally for a future post and to not confuse people. I find it more productive to explain things separately then together. Better results that way and less confusion.
    Joel said…
    Yes, I left it out intentionally for a future post and to not confuse people. I find it more productive to explain things separately then together. Better results that way and less confusion.

    Popular posts from this blog

    Offset, Depth, Distance, and Within

    Without going off the deep-end here and discussing every single Snort rule keyword, I just wanted to touch on a few modifiers that people sometimes misunderstand.  They aren't difficult, and hopefully after this explanation and a few examples, I can clear some of the air around these five modifiers.

    The five modifiers that I am talking about are
    OffsetDepthDistanceWithinnocaseThese five modifiers are not keywords of themselves, but rather they apply as modifiers to another keyword.  That keyword is "content". The content keyword is one of the easiest pieces of the Snort rules language as all it does is look for a particular string.  So for instance if I wanted to look for the word "joel" within a packet.  A simple:
    content:"joel";Would allow me to do that.  The interesting part comes into play when you want to specify where inside of a particular packet you want the string "joel" to be looked for.  If you are running just a plain content ma…

    Writing Snort Rules Correctly

    Let me start off by saying I'm not bashing the writer of this article, and I'm trying not to be super critical.  I don't want to discourage this person from writing articles about Snort rules.  It's great when people in the Snort community step up and explain some simple things out there.  There are mistakes, it comes with the territory.  If you choose to be one of the people that tries to write Snort rules, you also choose to be someone who wants to learn how to do it better.  That's why I write this blog post, not to bash the writer, but to teach.

    I noticed this post today over at the "Tao of Signature Writing" blog, and to be honest I glanced over most of it figuring it was a rehash of things I've already read or things that have already been written from countless people about "Here's how you write Snort rules!".  I scrolled down quickly skimming, not reading at all really, and noticed this part:
    Now, let us look at the second questio…

    Safari 5.1.4 now available

    Safari 5.1.4 now available, fixes issues and improves performance | TUAW - The Unofficial Apple Weblog:


    Improve JavaScript performanceImprove responsiveness when typing into the search field after changing network configurations or with an intermittent network connectionAddress an issue that could cause webpages to flash white when switching between Safari windowsAddress issues that prevented printing U.S. Postal Service shipping labels and embedded PDFsPreserve links in PDFs saved from webpagesFix an issue that could make Flash content appear incomplete after using gesture zoomingFix an issue that could cause the screen to dim while watching HTML5 videoImprove stability, compatibility and startup time when using extensionsAllow cookies set during regular browsing to be available after using Private BrowsingFix an issue that could cause some data to be left behind after pressing the "Remove All Website Data" button