text stringlengths 0 152 |
|---|
Authentication Weaknesses |
The first section of this chapter discussed scanning for usernames. Even if you have |
usernames that are difficult to guess, it is critical that you have strong passwords as |
well. If an attacker is able to obtain a valid username, they will likely attempt to brute- |
force the password. Strong passwords make this much more difficult. |
The default authentication scheme of the SIP protocol is weak. Authentication is done |
using an MD5 challenge-and-response mechanism. If an attacker is able to capture |
any call traffic, such as a SIP call made from a laptop on an open wireless network, it |
will be much easier to work on brute-forcing the password, since it will not require |
authentication requests to the server. |
Use strong passwords. There are countless resources available on |
the internet that help define what constitutes a strong password. |
There are also many strong password generators available. Use |
them! |
Fail2ban |
The previous two sections discussed attacks involving scanning for valid usernames |
and brute-forcing passwords. Fail2ban is an application that can watch your Asterisk |
logs and update firewall rules to block the source of an attack in response to too many |
failed authentication attempts. |
368 |
| |
Chapter 22: Security |
Use Fail2ban when exposing Voice over IP services on untrusted |
networks. It will automatically update the firewall rules to block the |
sources of attacks. |
Installation |
Fail2ban is available as a package in many distributions. Alternatively, you can install |
it from source by downloading it from the Fail2ban website. To install Fail2ban on |
RHEL, you must have the EPEL repository enabled (which was handled during |
Chapter 3). You can install Fail2ban by running the following command: |
$ sudo yum install fail2ban |
The installation of Fail2ban from a package will include a startup |
script to ensure that it runs when the machine boots up. If you |
install from source, make sure that you take the necessary steps to |
ensure that Fail2ban is always running. |
Configuration |
First up, we’ll want to configure the security log in Asterisk, which Fail2ban is able to |
make use of. |
$ sudo vim /etc/asterisk/logger.conf |
Uncomment the (or add a) line that reads security => security, and edit the date |
format so Fail2ban understands the logfile. |
[general] |
exec_after_rotate=gzip -9 ${filename}.2; |
dateformat = %F %T |
[logfiles] |
;debug => debug |
security => security |
;console => notice,warning,error,verbose |
console => notice,warning,error,debug |
messages => notice,warning,error |
full => notice,warning,error,debug,verbose,dtmf,fax |
Then reload the Asterisk logger: |
$ sudo asterisk -rx 'logger reload' |
Since current versions of Fail2ban already come with an Asterisk jail definition, all we |
need to do is enable it: |
The current best practice is to create a file /etc/fail2ban/jail.local for this purpose |
(technically you can put it in /etc/fail2ban/jail.conf, but this is more likely to be |
overwritten): |
Fail2ban |
| |
369 |
$ sudo vim /etc/fail2ban/jail.local |
[asterisk] |
enabled = true |
filter = asterisk |
action = iptables-allports[name=ASTERISK, protocol=all] |
sendmail[name=ASTERISK, dest=me@shifteight.org, sender=fail2ban@shifteight.org] |
logpath = /var/log/asterisk/messages |
/var/log/asterisk/security |
maxretry = 5 |
findtime = 21600 |
bantime = 86400 |
We’ve set up the ban for 24 hours, but you can do longer or shorter times as well if |
you prefer (the bantime is defined in seconds, so calculate accordingly). Since most |
attacking hosts move on after a few hours, there’s no harm in unblocking an IP after |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.