Ready to Start Your Career?

Testing Your Linux Firewall Configuration

Falko 's profile image

By: Falko

September 23, 2015

Testing Your Linux Firewall Configuration - Cybrary

At Cybrary.it, it's all about security and penetrating. I've decided to write this little guide for testing your own firewall configuration.

We're going to use Firewall Tester (FTester) tool. Important: this tool is now outdated. However, I find it still useful and nice to use for beginners.

The Firewall Tester (FTester) is a tool designed for testing firewall filtering policies and Intrusion Detection System (IDS) capabilities.

The tool consists of two perl scripts, a packet injector (ftest) and a listening sniffer (ftestd). The first script injects custom packets, defined in ftest.conf, with a signature in the data part while the sniffer listens for such marked packets. The scripts both write a log file which is in the same form for both scripts. A comparison of the two produced log files (ftest.log and ftestd.log) outlines the packets that were unable to reach the sniffer due to filtering rules if these two scripts are ran on hosts placed on two different sides of a firewall. Stateful inspection firewalls are handled with the 'connection spoofing' option. A script called freport is also available to automatically parse the log files.

Using the tool is not a completely automated process, ftest.conf must be crafted for every different situation. Examples and rules are included in the attached configuration file.

The IDS (Intrusion Detection System) testing feature can be used either with ftest only or with the additional support of ftestd for handling stateful inspection IDS, ftest can also use common IDS evasion techniques. The script can also process snort rule definition files.

Features:

  • firewall testing
  • IDS testing
  • simulation of real tcp connections for stateful inspection firewalls and IDS
  • TCP connection spoofing
  • IP fragmentation / TCP segmentation
  • IDS evasion techniques

Requirements:

The following perl modules are required: Net::RawIP, Net::PcapUtils, NetPacket

# perl -MCPAN -e "install Net::RawIP"# perl -MCPAN -e "install Net::Pcap"# perl -MCPAN -e "install Net::PcapUtils"# perl -MCPAN -e "install NetPacket"

Download:

Luckily, FTester is still available for download, so ..

# wget http://dev.inversepath.com/ftester/ftester-latest.tar.gz

After extracting the tool, we can focus on using it. This is the difficult part, as the tool has to be configured before one can use it. The basic syntax of configuration file is:

TCP and UDP packets: Source Address:Source Port:Destination Address:Destination Port:Flags:Protocol:Type of Service

ICMP packets: Source Address:Source Port:Destination Address:Destination Port:Flags:ICMP:icmp_type:icmp_pre

For example:

# SYN packet to 10.1.7.1 port 80

192.168.0.10:1024:10.1.7.1:80:S:TCP:0

# UDP packet

192.168.0.10:53:10.1.7.1:53::UDP:0

Stop signal is needed for the service to be stopped after test is complete:

stop_signal=192.168.0.1:666:10.1.7.1:666:S:TCP:

Everything has to be written in “ftest.conf” file. As the file already contains some examples, comment out those you won’t need.

We can use for our test following configuration:

# checking privileged ports (<1025)

192.168.0.10:1025:10.1.7.1:1-1025:S:TCP:0

# checking proxy port

192.168.0.10:1025:10.1.7.1:3128:S:TCP:0

stop_signal=192.168.0.10:80:10.1.7.1:1025:AP:TCP:0

After saving our configuration file, first of all we have to start a daemon:# ./ftestd -i eth0

Then we can run the test:# ./ftest -f ftest.conf

After the completion of test, we use the ftest binary to compare logs:# ./freport ftest.log ftestd.log

The result is something like:

Authorized packets:

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

21 - 192.168.0.10:1025 > 10.1.7.1:21 S TCP 0

22 - 192.168.0.10:1025 > 10.1.7.1:22 S TCP 0

23 - 192.168.0.10:1025 > 10.1.7.1:23 S TCP 0

25 - 192.168.0.10:1025 > 10.1.7.1:25 S TCP 0

80 - 192.168.0.10:1025 > 10.1.7.1:80 S TCP 0

110 - 192.168.0.10:1025 > 10.1.7.1:110 S TCP 0

113 - 192.168.0.10:1025 > 10.1.7.1:113 S TCP 0

1027 - 192.168.0.10:80 > 10.1.7.1:1025 PA TCP 0

Modified packets (probably NAT):

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

443 - 192.168.0.10:1025 > 10.1.7.1:443 S TCP 0

443 - 192.168.0.10:1025 > 10.1.7.5:443 S TCP 0

Filtered or dropped packets:

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

1 - 192.168.0.10:1025 > 10.1.7.1:1 S TCP 0

2 - 192.168.0.10:1025 > 10.1.7.1:2 S TCP 0

3 - 192.168.0.10:1025 > 10.1.7.1:3 S TCP 0

...

...

...

1026 - 192.168.0.10:1025 > 10.1.7.1:3128 S TCP 0

Thanks for reading this!

Schedule Demo