BFD is not blocking all the hack attempts

Bfd is set to block max of more then 10 attempts it should be adding the ip address to the iptables ban list but its not. I need this work for pop3, smtp and imap4, imap4-ssl. Please advise me why is not working please?

more conf.bfd
#!/bin/sh

BFD 1.5-2 [bfd@r-fx.org]

Copyright © 1999-2014, R-fx Networks <proj@r-fx.org>

Copyright © 2014, Ryan MacDonald <ryan@r-fx.org>

This program may be freely redistributed under the terms of the GNU GPL

NOTE: This file should be edited with word/line wrapping off,

if your using pico please start it with the -w switch.

(e.g: pico -w filename)

how many failure events must an address have before being blocked?

you can override this on a per rule basis in /usr/local/bfd/rules/

TRIG=“10”

send email alerts for all events [0 = off; 1 = on]

EMAIL_ALERTS=“0”

local user or email address alerts are sent to (separate multiple with comma)

EMAIL_ADDRESS=“root”

subject of email alerts

EMAIL_SUBJECT=“Brute Force Warning for $HOSTNAME”

executable command to block attacking hosts

BAN_COMMAND="/etc/apf/apf -d $ATTACK_HOST {bfd.$MOD}"

You should not need to edit any options below this line

installation path

INSTALL_PATH="/usr/local/bfd"

rule files path

RULES_PATH="$INSTALL_PATH/rules"

track log script path

TLOG_PATH="$INSTALL_PATH/tlog"

syslog kernel log path

KERNEL_LOG_PATH="/var/log/messages"

syslog auth log path

AUTH_LOG_PATH="/var/log/secure"

bfd application log path

BFD_LOG_PATH="/var/log/bfd_log"

log all events to syslog [0 = off; 1 = on]

OUTPUT_SYSLOG=“1”

log file path for syslog logging

OUTPUT_SYSLOG_FILE="$KERNEL_LOG_PATH"

template of the email message body

EMAIL_TEMPLATE="$INSTALL_PATH/alert.bfd"

contains list of files to search for addresses that are excluded from bans

IGNORE_HOST_FILES="$INSTALL_PATH/exclude.files"

grab the local time zone

TIME_ZONE=date +"%z"

grab the local unix time

TIME_UNIX=date +"%s"

lock file path

LOCK_FILE="$INSTALL_PATH/lock.utime"

lock file timeout

LOCK_FILE_TIMEOUT=“7200”

dir
asterisk_badauth courier exim_authfail openvpnas pure-ftpd sendmail vsftpd
asterisk_iax cpanel exim_nxuser postfix rh_imapd sshd vsftpd2
asterisk_nopeer dovecot modsec proftpd rh_ipop3d vpopmail

[root@fwh rules]# more postfix

failed logins from a single address before ban

uncomment to override conf.bfd trig value

TRIG=“10”

file must exist for rule to be active

REQ="/usr/sbin/postfix"

if [ -f “$REQ” ]; then
PORTS=“25,26”
LP="/var/log/mail.log"
TLOG_TF=“postfix”

## Postfix dictionary attacks
ARG_VAL=`$TLOG_PATH $LP $TLOG_TF | egrep -w "SASL LOGIN authentication failed:|SASL PLAIN authenticatio

n failed:" | grep -E ‘[0-9]+.[0-9]+.[0-9]+.[0-9]+’ | awk -F ‘[’ ‘{ print $3 }’ | tr -d ‘[a-z][A-Z][]:’`
fi
[root@fwh rules]#

more dovecot

failed logins from a single address before ban

uncomment to override conf.bfd trig value

TRIG=“30”

uncomment to disable alerting for this rule

SKIP_ALERT=“1”

file must exist for rule to be active

REQ="/usr/sbin/dovecot"

if [ -f “$REQ” ]; then
PORTS=“110,143,993,995”
LP="/var/log/maillog"
TLOG_TF=“dovecot”

## DOVECOT IMAP/POP3
ARG_VAL=`$TLOG_PATH $LP $TLOG_TF | egrep '(imap|pop3)-login.*(Authentication failure|auth failed|Aborte

d login|ried to use disabled)’ | egrep -v ‘no auth attempts’ | sed -n -e ‘/auth failed/s/.user=<(.)>.rip=
([^ ]
),./\2:\1/p’ | egrep '^[0-9]+.[0-9]+.[0-9]+.[0-9]+:.$’`
fi
[root@fwh rules]#

more courier

failed logins from a single address before ban

uncomment to override conf.bfd trig value

TRIG=“10”

uncomment to disable alerting for this rule

SKIP_ALERT=“1”

file must exist for rule to be active

REQ="/usr/lib/courier-imap/libexec/couriertcpd"

if [ -f “$REQ” ]; then
PORTS=“110,143,993,995”
LP="/var/log/maillog"
TLOG_TF=“courier”

courier imap|pop3

ARG_VAL=$TLOG_PATH $LP $TLOG_TF | sed -e 's/::ffff://' | egrep '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | tr '=' ' ' | sed -n -e '/LOGIN FAILED/s/.*user \([^ ]*\)\(.*\) \([^ ]*\).*/\3:\1/p' | tr -d '[],'
fi
[root@fwh rules]#

Hi ptaylor1984

Have you checked your logs, system, apf to see if it does add any ip or perhaps you could set email notification.

Many thanks

John

I checked iptables

[QUOTE=d2d4j;26057]Hi ptaylor1984

Have you checked your logs, system, apf to see if it does add any ip or perhaps you could set email notification.

Many thanks

John[/QUOTE]

I checked bfd logs and iptables and its not adding it. Why?

Hi ptaylor1984

What’s your distro, and IW cp version

Is it a default install or have you changed anything or modified anything, ie log positions etc

Is your server a vps or full server

Can you confirm if the cron job for bfd is running and at what schedule

Are correct user rights assigned

Have you tried reinstalling bfd

Lastly, please be aware bfd is nothing to do with IW

Many thanks

John

Download link

[QUOTE=d2d4j;26059]Hi ptaylor1984

What’s your distro, and IW cp version

Is it a default install or have you changed anything or modified anything, ie log positions etc

Is your server a vps or full server

Can you confirm if the cron job for bfd is running and at what schedule

Are correct user rights assigned

Have you tried reinstalling bfd

Lastly, please be aware bfd is nothing to do with IW

Many thanks

John[/QUOTE]

Do you have the link to download bfd. I checked everything and it seems to be set ok. What else can it be?

Can you please verify that the rules I posted are is using the correct format?

Hi ptaylor1984

I’m sorry, I’m not at work but if you google rfx networks, you’ll find the download site or look it up on the forums here.

I’m sorry, I can only guess as your not giving any details, so it would most likely be a user rights or permission issue. As a guess though.

If you want to test it, just make up an IP address and run the code shown in the bfd.conf to manually add it in and see if it works as expected.

I’ve certainly not had any issues installing onto all of our systems

Actually, I hate to ask, but is your firewall running

I hope that helps

Many thanks

John

Sorry, just one more question, have you started bfd running

If your not too sure how too, I’ll look it up and post

Many thanks

John

BFD Config

[QUOTE=d2d4j;26063]Sorry, just one more question, have you started bfd running

If your not too sure how too, I’ll look it up and post

Many thanks

John[/QUOTE]

Are you using it? Can you post your conf files here please?

Crontab is
[TABLE=“class: iw-table iw-table-payload iw-w-full”]
[TR=“class: row1 ruler”]
[TD=“class: td-minute”]/2[/TD]
[TD=“class: td-hour”]
[/TD]
[TD=“class: td-day”][/TD]
[TD=“class: td-month”]
[/TD]
[TD=“class: td-dayofweek”]*[/TD]
[TD=“class: td-script left”]/usr/local/sbin/bfd -q[/TD]
[/TR]
[/TABLE]

I am using the current version of CentOs 6.5 and the permission for bfd exec is 755

Take a look it this :

[root@fwh rules]# /usr/local/sbin/bfd -s
Brute Force Detection v1.5-2 <bfd@r-fx.org>
© 1999-2014, R-fx Networks <proj@r-fx.org>
© 2014, Ryan MacDonald <ryan@r-fx.org>
This program may be freely redistributed under the terms of the GNU GPL

Sep 13 15:57:07 fwh bfd(29988): processing rule file asterisk_badauth
Sep 13 15:57:07 fwh bfd(29988): processing rule file asterisk_iax
Sep 13 15:57:07 fwh bfd(29988): processing rule file asterisk_nopeer
Sep 13 15:57:07 fwh bfd(29988): processing rule file courier
Sep 13 15:57:07 fwh bfd(29988): processing rule file cpanel
Sep 13 15:57:07 fwh bfd(29988): processing rule file dovecot
Sep 13 15:57:07 fwh bfd(29988): processing rule file exim_authfail
Sep 13 15:57:07 fwh bfd(29988): processing rule file exim_nxuser
Sep 13 15:57:07 fwh bfd(29988): processing rule file modsec
Sep 13 15:57:07 fwh bfd(29988): processing rule file openvpnas
Sep 13 15:57:07 fwh bfd(29988): processing rule file orginal.zip
/usr/local/sbin/bfd: line 125: .: /usr/local/bfd/rules/orginal.zip: cannot execute binary file
Sep 13 15:57:07 fwh bfd(29988): processing rule file postfix
Sep 13 15:57:07 fwh bfd(29988): processing rule file proftpd
Sep 13 15:57:07 fwh bfd(29988): processing rule file pure-ftpd
Sep 13 15:57:07 fwh bfd(29988): processing rule file rh_imapd
Sep 13 15:57:08 fwh bfd(29988): processing rule file rh_ipop3d
Sep 13 15:57:08 fwh bfd(29988): processing rule file sendmail
Sep 13 15:57:08 fwh bfd(29988): processing rule file sshd
Sep 13 15:57:08 fwh bfd(29988): processing rule file vpopmail
Sep 13 15:57:08 fwh bfd(29988): processing rule file vsftpd
Sep 13 15:57:08 fwh bfd(29988): processing rule file vsftpd2

Hi ptaylor1984

You would be best advised to delete your zip file, but glancing at the rest of log, it appears to be processing now.

Bfd will only use rules if it finds service in location is correct, ie cpanel would not have service so rule not processed.

It looks like you did not start bfd then

Many thanks

John

Bfd

[QUOTE=d2d4j;26067]Hi ptaylor1984

You would be best advised to delete your zip file, but glancing at the rest of log, it appears to be processing now.

Bfd will only use rules if it finds service in location is correct, ie cpanel would not have service so rule not processed.

It looks like you did not start bfd then

Many thanks

John[/QUOTE]

I re-installed BFD but I need to know if the correct the correct ARG val is correct for postfix and for the other services.

Postfix

ARG_VAL=`$TLOG_PATH $LP $TLOG_TF | egrep -w "SASL LOGIN authentication failed:|SASL PLAIN authentication failed:" | grep -E

‘[0-9]+.[0-9]+.[0-9]+.[0-9]+’ | awk -F ‘[’ ‘{ print $3 }’ | tr -d ‘[a-z][A-Z][]:’`
fi

Including a plugin would make things a lot easer for the customer like some of the other control panels have already done like plesk.

Hi ptaylor1984

IW do not use postfix so this rule is ignored.

Please understand, bfd rules are only active if the service files are found. If not found, the rule for that service are not used.

Many thanks

John

Bfd

[QUOTE=d2d4j;26069]Hi ptaylor1984

IW do not use postfix so this rule is ignored.

Please understand, bfd rules are only active if the service files are found. If not found, the rule for that service are not used.

Many thanks

John[/QUOTE]

What is Interworx usse for smtp, pop3, pop3-ssl, Imap4 and Imap4-ssl?

This is the rules that is included with BFD is one missing???

asterisk_badauth courier exim_authfail openvpnas proftpd rh_ipop3d vpopmail
asterisk_iax cpanel exim_nxuser orginal.zip pure-ftpd sendmail vsftpd
asterisk_nopeer dovecot modsec postfix rh_imapd sshd vsftpd2

Can someone else please tell me

[QUOTE=ptaylor1984;26070]What is Interworx usse for smtp, pop3, pop3-ssl, Imap4 and Imap4-ssl?

This is the rules that is included with BFD is one missing???

asterisk_badauth courier exim_authfail openvpnas proftpd rh_ipop3d vpopmail
asterisk_iax cpanel exim_nxuser orginal.zip pure-ftpd sendmail vsftpd
asterisk_nopeer dovecot modsec postfix rh_imapd sshd vsftpd2[/QUOTE]

What services does InterWorx use for the smtp pop3, imap4, imap4-ssl-ssl and pop3-ssl? Can you please give me some working examples of bfd rules that work?

Thanks

Hi ptaylor1984

I’m not at work sorry, but the default rules are fine, you just need to change the hit value etc on bfd.conf to values you want to use

If you check nodeworx, server settings I think from memory, it tells you what services are used ie qmail, proftp etc and if you check rules for vpop, you’ll see it checks qmail.

Hence, if the service is listed in the folders, bfd will activate the rule, if it’s not listed in folders, bfd does not activate it.

Is bfd still not working for you, if not, what messages are shown in logs.

Many thanks

John