Permalink
Commits on Jul 17, 2011
  1. Minor man page wording update for NFQUEUE mode

    mrash committed Jul 17, 2011
    Minor man page wording update for NFQUEUE mode to make sure to convey to the
    reader the need to disable the stream preprocessor for the userspace
    snort_inline instance.
  2. Added iptables capabilities test for NFQUEUE modes

    mrash committed Jul 17, 2011
    Added a test to see whether iptables supports either the QUEUE or NFQUEUE
    targets in --QUEUE and --NFQUEUE modes respectively.
  3. Bugfix to support --NFQUEUE mode

    mrash committed Jul 17, 2011
    With the recent code refactoring for the Snort 'fast_pattern' keyword, the
    --QUEUE and --NFQUEUE modes were broken in the process.  This changes restores
    these modes:
    
    ./fwsnort --no-ipt-sync --NFQUEUE |grep Generated
    [+] Generated iptables rules for 12916 out of 13131 signatures: 98.36%
  4. Ignore http_uri, http_method, and urilen

    mrash committed Jul 17, 2011
    iptables has no good way to support the http_uri, http_method, and urilen Snort
    keywords, so this change ignores them.  The tradeoff is that certain signatures
    may have a higher rate of false positives, but detection may outweigh this for
    rules like this one:
    
    alert tcp $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS (msg:"ET TROJAN Unknown Generic Trojan Checkin"; flow:established,to_server; content:"unit_id="; http_uri; content:"&uv_id="; http_uri; content:"&uv_new="; http_uri; content:"&url="; http_uri; content:"&charset="; http_uri; content:"&hashval="; http_uri; content:"&app="; http_uri; content:"&lg="; http_uri; classtype:trojan-activity; sid:2013204; rev:1;)
    
    It is possible to force fwsnort to not ignore the http_* keywords with the
    --strict command line argument.
    
    The number of signatures that this change picks up is trivial though for the
    bundled signature set in the deps/snort_rules/ directory:
    
    Before:
    
    ./fwsnort --no-ipt-sync |grep Generated
    [+] Generated iptables rules for 9341 out of 13131 signatures: 71.14%
    
    After:
    
    ./fwsnort --no-ipt-sync |grep Generated
    [+] Generated iptables rules for 9343 out of 13131 signatures: 71.15%
  5. Updated to allow non-root users to execute fwsnort.

    mrash committed Jul 17, 2011
    This update allows non-root users to run fwsnort, but a modified fwsnort.conf
    file must be supplied that changes various paths.  Running as a non-root user
    is mostly only useful to see how fwsnort translates certain Snort rules.  Here
    is an example of running fwsnort as a non-root user:
    
    $ ./fwsnort -c fwsnort.conf.nonroot --snort-sid 1234 |less
    [+] Parsing Snort rules files...
    [+] Found sid: 1234 in web-misc.rules
        Successful translation.
    
    [+] Logfile: /home/mbr/git/fwsnort.git/fwsnort.log
    [+] iptables script (individual commands): /home/mbr/git/fwsnort.git/fwsnort_iptcmds.sh
    [*] Could not write to: /home/mbr/git/fwsnort.git/fwsnort.sh at ./fwsnort line 4418.
    [mbr@minastirith ~/git/fwsnort.git]$ ./fwsnort -c fwsnort.conf.nonroot --snort-sid 1234 |less
    [+] Parsing Snort rules files...
    [+] Found sid: 1234 in web-misc.rules
        Successful translation.
    
    [+] Logfile: /home/mbr/git/fwsnort.git/fwsnort.log
    [+] iptables script (individual commands): /home/mbr/git/fwsnort.git/fwsnort_iptcmds.sh
    
        Main fwsnort iptables-save file: /home/mbr/git/fwsnort.git/fwsnort.save
    
        It does not appear as though you are running as root, so it is NOT
        recommended that you become root and execute the fwsnort.sh script. The
        reason is that non-root users cannot execute iptables, and therefore
        fwsnort had no way to check for iptables capabilities or to parse any
        existing iptables policy for proper splicing of the fwsnort rules.
    
        Exiting.
Commits on Jul 15, 2011
  1. Minor change to not write args in --help mode.

    mrash committed Jul 15, 2011
    Minor update to exclude 'fwsnort --help' from the saved command line arguments
    copy.  This ensures that 'fwsnort --Last' does not just re-execute
    'fwsnort --help'.
Commits on Jul 10, 2011
  1. Added support for the Snort 'nocase' keyword

    mrash committed Jul 10, 2011
    The iptables string match extension supports case insensitive matches with
    the --icase option.  This commit updates fwsnort to leverage --icase whenever
    the 'nocase' modifier it applied to a pattern match in a Snort rule.
  2. Updated to the latest Emerging Threats Snort rules

    mrash committed Jul 10, 2011
    Updated to the latest Emerging Threats Snort rules - this file contains over
    10,000 rules now.  Here is some sample translation output stats with fwsnort:
    
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        Snort Rules File          Success   Fail      Total
    
    [+] emerging-all.rules        7440      2582      10022
                                  =============================
                                  7440      2582      10022
    
    [+] Generated iptables rules for 7440 out of 10022 signatures: 74.24%
  3. Added iptables 'multiport' match support

    mrash committed Jul 10, 2011
    The iptables 'multiport' match is now supported, and this enables fwsnort to
    properly translate a few Snort rules from the emerging threats rule set like
    this one:
    
    alert tcp $HOME_NET [0:20,22:24,26:138,140:444,446:464,466:586,588:901,903:1432,1434:65535] -> any any (msg:"ET MALWARE Suspicious FTP 220 Banner on Local Port (spaced)"; flow:from_server,established; content:"220 "; depth:4; content:!"VMware Authentication Daemon"; depth:32; classtype:non-standard-protocol; reference:url,doc.emergingthreats.net/2011124; reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/MALWARE/MALWARE_Off_Port_FTP; sid:2011124; rev:12;)
    
    The translated version is now:
    
    $IPTABLES -A FWSNORT_FORWARD_ESTAB -p tcp -m tcp -m multiport --sports 0:20,22:24,26:138,140:444,446:464,466:586,588:901 -m string ! --string "VMware Authentication Daemon" --algo bm --to 96 -m string --string "220 " --algo bm --to 68 -m comment --comment "sid:2011124; msg:ET MALWARE Suspicious FTP 220 Banner on Local Port (spaced); classtype:non-standard-protocol; reference:url,doc.emergingthreats.net/2011124; rev:12; FWS:1.5;" -j LOG --log-ip-options --log-tcp-options --log-prefix "SID2011124 ESTAB "
Commits on Jul 9, 2011
  1. Added --no-fast-pattern-order to --help output

    mrash committed Jul 9, 2011
    Added --no-fast-pattern-order to --help output and also added the
    'fast_pattern' hash key to the 'ignore' bucket if --no-fast-pattern-order is
    given on the command line.
  2. Implemented tighter 'within' criteria

    mrash committed Jul 9, 2011
    This commit fixes a problem where fwsnort was in some cases too lax with how it
    calculated relative pattern matching depths that are defined via the Snort 'within'
    keyword.  This should result in fewer fwsnort log messages for certain signatures.
    An example signature that this change improves is:
    
    alert tcp $HOME_NET any -> $AIM_SERVERS any (msg:"CHAT AIM login"; flow:to_server,established; content:"*|02|"; depth:2; content:"|00 17 00 06|"; distance:4; within:8; classtype:policy-violation; sid:1631; rev:7;)
    
    fwsnort previous to this change translated this as a set of signatures including
    the following (allowing for the multiple IP's in the $AIM_SERVERS variable):
    
    $IPTABLES -A FWSNORT_FORWARD_ESTAB -d 64.12.24.0/24 -p tcp -m tcp -m string --hex-string "*|02|" --algo bm --to 66 -m string --hex-string "|00170006|" --algo bm --from 70 --to 76 -m comment --comment "sid:1631; msg:CHAT AIM login; classtype:policy-violation; rev:7; FWS:1.5;" -j LOG --log-ip-options --log-tcp-options --log-prefix "SID1631 ESTAB "
    
    After this change the signature becomes:
    
    $IPTABLES -A FWSNORT_FORWARD_ESTAB -d 64.12.24.0/24 -p tcp -m tcp -m string --hex-string "*|02|" --algo bm --to 66 -m string --hex-string "|00170006|" --algo bm --from 70 --to 74 -m comment --comment "sid:1631; msg:CHAT AIM login; classtype:policy-violation; rev:7; FWS:1.5;" -j LOG --log-ip-options --log-tcp-options --log-prefix "SID1631 ESTAB "
    
    Note that in the second pattern match the --to criteria has been reduced from
    76 to 74.  (The second rule was generated with --no-fast-pattern-ordering to
    make the diff make sense more easily.)
  3. Added the --no-fast-pattern-ordering argument

    mrash committed Jul 9, 2011
    Added --no-fast-pattern-ordering to have fwsnort not try to reorder pattern
    matches to process the longest pattern first.  This option also instructs
    fwsnort to ignore the Snort 'fast_pattern' keyword in any Snort rule.
  4. Moved GetOpt() call to handle_cmd_line()

    mrash committed Jul 9, 2011
    Minor updated to move the GetOpt() function call for parsing command line args
    to the handle_cmd_line() function (where it should have been for a while).
  5. minor man page wording update

    mrash committed Jul 9, 2011
  6. Fixed fast_pattern support for relative matches

    mrash committed Jul 9, 2011
    This is a significant code refactoring in order to support the fast_pattern
    keyword when relative matches are involved.  Previous to this change, the
    initial fast_pattern implementation would not take into account how the
    iptables --from and --to keywords should be set under the 'distance' and
    'within' keywords.
Commits on Jul 6, 2011
  1. Added 'detection_filter' to not supported list

    mrash committed Jul 6, 2011
    The newer 'detection_filter' Snort keyword (a replacement for the older
    'threshold' keyword) is not supported yet.  The iptables limit match should
    be able to help here eventually.
  2. Added content match ordering based on length

    mrash committed Jul 5, 2011
    In cases where the 'fast_pattern' option is not used, Snort generally tries to
    pick the longest pattern to match first since this should usually result in
    better performance.  That is, longer there is a higher chance for a longer
    string to be more unique, and this would result in shorter strings from not
    being searched for.  This works in the context of iptables because 'matches'
    are AND'd togther, so if the first string match fails, no subsequent string
    matches will be executed.  Hence, the search for "shortstr" below would not
    happen if the search for "thisisalongstring" failed:
    
    -m string --string 'thisisalongstring' --algo bm -m string --string 'shortstr' --algo bm
    
    One thing to note is that iptables does not support relative string matches
    in the same way that Snort does.  The iptables string match can specify an
    offset and depth into the packet via --from and --to.  The end result is that
    the fwsnort way of maximizing performance is to find the longest string, do
    the match, and apply an approximation for --from and --to whenever they are
    required for any pattern.  That is, it doesn't have to worry about relative
    matches and finding the end of a pattern in order to know where to start the
    next search.  Now, this will result in signature matching in fwsnort not
    being as accurate as Snort (remember that fwsnort emulates Snort behavior as
    closely as possible given functionality implemented in iptables), but it
    should be faster.
Commits on Jul 5, 2011
  1. Added 'fast_pattern' support + no patterns bug fix

    mrash committed Jul 5, 2011
    Added support for the Snort 'fast_pattern' keyword which is used to force a
    particular payload match to be done first.  This allows the signature author
    to optimize the performance of certain signatures based on a knowledge of
    how likely certain strings are to match within application layer protocols.
    A gooo write up of the 'fast_pattern' keyword was posted to the VRT blog
    here:
    
    http://vrt-blog.snort.org/2010/04/using-snort-fast-patterns-wisely-for.html
    
    Also fixed a bug that would exclude all signatures that do not have at least
    one content match.  A good example of such a signature is this one:
    
    alert tcp $EXTERNAL_NET 6112 -> $HOME_NET any (msg:"ET GAMES Battle.net
    connection reset (possible IP-Ban)"; flags:R,12; classtype: policy-violation;
    reference:url,doc.emergingthreats.net/bin/view/Main/2002117;
    reference:url,www.emergingthreats.net/cgi-bin/cvsweb.cgi/sigs/GAMES/GAMES_Battlenet;
    sid:2002117; rev:6;)
    
    Between this bug fix and the 'fast_pattern' support, fwsnort is able to
    translated nearly 300 additional signatures beyond the fwsnort-1.5 release:
    
    [+] Generated iptables rules for 8529 out of 12224 signatures: 69.77%
    
    [+] Generated iptables rules for 8812 out of 12224 signatures: 72.09%
  2. Added support for Snort keyword 'fast_pattern'

    mrash committed Jul 5, 2011
    Added support for the Snort 'fast_pattern' keyword which is used to force a
    particular payload match to be done first.  This allows the signature author
    to optimize the performance of certain signatures based on a knowledge of
    how likely certain strings are to match within application layer protocols.
    A gooo write up of the 'fast_pattern' keyword was posted to the VRT blog
    here:
    
    http://vrt-blog.snort.org/2010/04/using-snort-fast-patterns-wisely-for.html
Commits on Jul 1, 2011
  1. minor man page wording update

    mrash committed Jul 1, 2011
  2. Added three Snort signature keywords

    mrash committed Jul 1, 2011
    Added the 'detection_filter', 'threshold', and 'urilen' Snort rule keywords.
    Also included a minor update to calculate max keyword length on the fly.
Commits on Jun 30, 2011
  1. Added newer Snort keywords to snort_opts.pl

    mrash committed Jun 30, 2011
    Added Snort keywords fast_pattern, http_header, http_uri, and http_method
    to the snort_opts.pl script.
Commits on Jun 28, 2011
  1. minor ChangeLog update

    mrash committed Jun 28, 2011
  2. Bugfix for --ipt-apply to exec fwsnort.sh

    mrash committed Jun 28, 2011
    Fixed the --ipt-apply functionality - the variable that held the fwsnort.sh
    path was not initialized properly prior to this change.
Commits on Jun 23, 2011
  1. Added the --Conntrack-state argument

    mrash committed Jun 21, 2011
    Added the --Conntrack-state argument to specify a conntrack state in place of
    the "established" state that commonly accompanies the Snort "flow" keyword.
    By default, fwsnort uses the conntrack state of "ESTABLISHED" for this.  In
    certain corner cases, it might be useful to use "ESTABLISHED,RELATED" instead
    to apply application layer inspection to things like ICMP port unreachable
    messages that are responses to real attempted communications.  (Need to add
    UDP tracking for the _ESTAB chains for this too - coming soon.)
Commits on Jun 21, 2011
  1. Added test for conntrack --ctstate

    mrash committed Jun 21, 2011
    Recent releases of iptables and the Linux kernel support matching
    on connection state via the conntrack modules and the --ctstate
    switch.  Added a capabilities test for this, and will fall back to
    using the state match if the conntrack module is not available.
Commits on Jun 19, 2011
  1. Bugfix for --ipt-list and --ipt-flush

    mrash committed Jun 19, 2011
    Fixed a problem with --ipt-list and --ipt-flush to ensure that the proper
    iptables binary path is chosen.  These args failed without this because the
    iptables binary was not set.
  2. Bugfix for --log-prefix maximum lengths

    mrash committed Jun 19, 2011
    Bugfix to ensure the iptables log prefixes built by fwsnort are not
    longer than those allowed by the running iptables firewall.  This is
    usually a total of 29 characters, but fwsnort now dynamically figures out
    this value.
    
    This bug was originally reported by Yves Pagani to the fwsnort mailing
    list.
  3. Removed old reference to $rev_num

    mrash committed Jun 19, 2011
    In keeping with svn, fwsnort used to store the $Id$ file ID into $rev_num. This
    has been removed.
  4. Removed legacy $Id$ tags (for old svn repos)

    mrash committed Jun 19, 2011
    $Id$ tags don't really mean anything to git so they have been removed from all
    source files.
Commits on Jan 9, 2011
  1. wording fix for the fwsnort-1.5 ChangeLog

    mrash committed Jan 9, 2011
    git-svn-id: file:///home/mbr/svn/fwsnort_repos/fwsnort/trunk@561 af5c991a-1414-0410-86ad-c3437102cd4a
  2. bumped software version to 1.5

    mrash committed Jan 9, 2011
    git-svn-id: file:///home/mbr/svn/fwsnort_repos/fwsnort/trunk@556 af5c991a-1414-0410-86ad-c3437102cd4a
Commits on Jan 3, 2011
  1. minor date update

    mrash committed Jan 3, 2011
    git-svn-id: file:///home/mbr/svn/fwsnort_repos/fwsnort/trunk@554 af5c991a-1414-0410-86ad-c3437102cd4a