Online Book Reader

Home Category

Linux Firewalls - Michael Rash [111]

By Root 510 0
completed"; nocase; reference:

bugtraq,1806; classtype:bad-unknown; sid:494; rev:10;)

$IPTABLES -A FWSNORT_FORWARD_ESTAB -s 192.168.10.0/24 -p tcp --sport 80 -m string

--string "Command completed" --algo bm -m comment --comment "sid:494; msg: ATTACK-

RESPONSES

command completed; classtype: bad-unknown; reference: bugtraq,1806; rev: 10; FWS:1.0;"

-j LOG --log-ip-options --log-tcp-options

--log-prefix "[2] SID494 ESTAB "

$IPTABLES -A FWSNORT_OUTPUT_ESTAB -p tcp --sport 80 -m string --string "Command

completed" --algo bm -m comment --comment "sid:494; msg: ATTACK-RESPONSES command

completed;

classtype: bad-unknown; reference: bugtraq,1806; rev: 10; FWS:1.0;" -j LOG --log-ip-

options --log-tcp-options --log-prefix "[2] SID494 ESTAB "

Activating the fwsnort Chains with Jump Rules

The final section in fwsnort.sh makes the whole ruleset active within the kernel by directing iptables to send traffic through these rules. All of the iptables commands executed by fwsnort.sh up until this point simply load the fwsnort policy into the running kernel.

Because there are not yet any jump rules to send packets from the built-in iptables chains into the fwsnort chains, we have utilized only kernel memory so far; none of the rules can yet interact with packets as they flow within the kernel. This changes with the final six commands, which first delete any existing fwsnort jump rule[61] and then make the very first rule in each of the INPUT, OUTPUT, and FORWARD chains jump all packets to the respective fwsnort chain. (The jump rules are the only rules added by fwsnort to any of the built-in iptables chains.)

$IPTABLES -D FORWARD -i ! lo -j FWSNORT_FORWARD 2> /dev/null

$IPTABLES -I FORWARD 1 -i ! lo -j FWSNORT_FORWARD

$IPTABLES -D INPUT -i ! lo -j FWSNORT_INPUT 2> /dev/null

$IPTABLES -I INPUT 1 -i ! lo -j FWSNORT_INPUT

$IPTABLES -D OUTPUT -o ! lo -j FWSNORT_OUTPUT 2> /dev/null

$IPTABLES -I OUTPUT 1 -o ! lo -j FWSNORT_OUTPUT

Note

See Appendix B for an example fwsnort.sh script that translates the web-attacks Snort rules file into an equivalent iptables policy.

Command-Line Options for fwsnort

There are many command-line options for fwsnort that you can use to influence its execution, and we'll cover some of the more commonly used ones here. (You'll find an exhaustive treatment of all command-line arguments in the fwsnort(8) man page.)

--ipt-drop

This option instructs fwsnort to drop packets before they are forwarded to their intended target, in addition to logging them. (By default, fwsnort only logs malicious packets.) This grants fwsnort the authority to actively respond to network attacks.

--ipt-reject

This option instructs fwsnort to build an iptables policy that utilizes the REJECT target to tear down malicious TCP connections with TCP Reset packets, and to respond against malicious UDP traffic with an ICMP Port Unreachable message.

--snort-confpath

This option instructs fwsnort to read variables such as HOME_NET, EXTERNAL_NET, HTTP_SERVERS, and so on directly from an existing Snort configuration file (usually located at /etc/snort/snort.conf ). There is nothing to prevent Snort and fwsnort from running on the same system. This remains true even when Snort is running in inline mode, because fwsnort rules are sectioned off within their own chains; packets can be jumped to these chains before hitting a QUEUE rule within the iptables policy.

--snort-sidsids

This option allows the translation efforts of fwsnort to be restricted to a specific Snort ID or a list of Snort IDs. This is most useful when a new vulnerability is announced in a piece of software that is protected by an iptables firewall and a new signature is released by the Snort community to detect an attack that exploits this vulnerability. By using fwsnort with the --snort-sid option, we can quickly deploy a new policy to log and/or drop malicious packets that are associated with this new attack.

--include-typetype

This option instructs fwsnort to translate only Snort rules that are contained within a single rules file. For example,

Return Main Page Previous Page Next Page

®Online Book Reader