The Brutus server is essentially any machine running Linux that has Portsentry installed. In the case of our reference diagram, let’s assume we’ve made the Web server the Brutus server, and the EMail server the Client. You could of course make Brutus run on its own dedicated host as well. It’s helpful to install postfix on this machine so that you can receive emailed status reports.
On Ubuntu you can install Portsentry with “apt get portsentry”.
The project home page is here at SourceForge: https://sourceforge.net/projects/sentrytools/
Once Portsentry has been installed, place this portsentry.conf file in /etc/portsentry . This is what shapes Portsentry’s behavior and determines what to run in the event a port “touch” is detected.
In the /etc/portsentry folder, you can place this instructrouter.sh script. The heart of Brutus, this is the script called by portsentry.conf above that instructs your firewall to null-route the offending external IP address (“null-route” means “the route to take to get to this IP is.. yourself.. there is no other route”, effectively dropping this IP in the trashcan.)
In order for the portsentry process to SSH into your firewall, you need to create a public-private keypair for the root account on your Brutus server. You can do it with the commands at right. You don’t need a key larger than 1024 bits as it’s being used in an internal control channel.
sudo su –
ssh-keygen -t rsa -b 1024
In the /root/.ssh folder, copy the contents of id-rsa.pub to the Firewall’s admin user public key field, per the “Firewall” article instructions.
This script is also called via root’s crontab as per the string at right.
45 23 * * * /etc/portsentry/instructrouter.sh r
For firewalls other than PFSense, the command to actually execute the block will vary based on the operating system but you only have to test and change a single line (about line #89 in the * section).
The fwreport.sh script can go in /etc/portsentry too. This is executed by hand whenever you want to:
a) confirm root’s key is working on the firewall, and
b) provide a current list of IP’s being blocked by Brutus.
blockreport.sh is also placed in /etc/portsentry, and it’s executed via crontab every day at about 11:55p (before midnight) so as to email you with a daily status report. It also performs some maintenance, purging records older than a few days.
Root’s crontab line looks like the command at right:
47 23 * * * /etc/portsentry/blockreport.sh
To test, google “online port scan”, you’ll see offerings by MXToolbox and others – use their services to scan your external IP address and watch your routing table (or run fwreport.sh) and you should see the source IP get dropped very quickly!
After all this is done, Portsentry is now able to instruct your firewall to drop inbound portscans automatically, resulting in a network that’s MUCH harder to map by attackers.
This is the heart of Brutus, you could be done if you have a home network with no servers or have a single server behind a firewall in your DMZ that provides service. If you have more than one server you need to protect, proceed to the next article for Brutus client configuration.