RASPBIAN Jessie
Edit: It is working from some clients
From another Rasberry Pi the log is working and now picking the proper entry in the log
Jul 22 04:02:21 dropbear[2462]: Bad password attempt for
'user' from 192.168.1.154:39594
But when I try from my mac i get this
Jul 22 04:29:27 dropbear[3026]: Bad password attempt for 'user' from fe80::109b:c195:be5d:6e5e%eth0:63395
It is trying to use a IPV6 address... for some reason.
У меня была похожая тема, которую можно найти здесь Fail2Ban не ловит сбои аутентификации dropbear
Мне удалось заставить это работать, но пришлось восстанавливаться из резервной копии (не связанной с этим), однако, эта резервная копия не включала мое исправление. После восстановления я заново установил drop bear и заново настроил fail2ban, однако, похоже, что регулярные выражения снова изменились. В прошлый раз виновником была заглавная и строчная буква B, но не в этот раз, как вы можете видеть ниже, это, похоже, было устранено в версии fail2ban, которую я запускаю сейчас. Но он все еще не улавливает автоматические сбои.
Auth log error
dropbear[740]: Bad password attempt for 'username' from 192.168.1.171:62556
Current filter
# Fail2Ban filter for dropbear
#
# NOTE: The regex below is ONLY intended to work with a patched
# version of Dropbear as described here:
# http://www.unchartedbackwaters.co.uk/pyblosxom/static/patches
# ^%(__prefix_line)sexit before auth from .*\s*$
#
# The standard Dropbear output doesn't provide enough information to
# ban all types of attack. The Dropbear patch adds IP address
# information to the 'exit before auth' message which is always
# produced for any form of non-successful login. It is that message
# which this file matches.
#
# More information: http://bugs.debian.org/546913
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
[Definition]
_daemon = dropbear
failregex = ^%(__prefix_line)s[Ll]ogin attempt for nonexistent user ('.*' )?from :\d+$
^%(__prefix_line)s[Bb]ad (PAM )?password attempt for .+ from (:\d+)?$
^%(__prefix_line)s[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '.+' from :\d+\s*$
ignoreregex =
# DEV Notes:
#
# The first two regexs here match the unmodified dropbear messages. It isn't
# possible to match the source of the 'exit before auth' messages from dropbear
# as they don't include the "from " bit.
#
# The second last failregex line we need to match with the modified dropbear.
#
# For the second regex the following apply:
#
# http://www.netmite.com/android/mydroid/external/dropbear/svr-authpam.c
# http://svn.dd-wrt.com/changeset/16642#file64
Fail2ban jail.conf
# [SECTION_NAME]
# enabled = true
#
# in /etc/fail2ban/jail.local.
#
# Optionally you may override any other parameter (e.g. banaction,
# action, port, logpath, etc) in that section within jail.local
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6
[dropbear]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6
# Generic filter for pam. Has to be used with action which bans all ports
# such as iptables-allports, shorewall
[pam-generic]
Fail2Ban jail.local
#local ssh rule set
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
bantime = 900
banaction = iptables-allports
findtime = 900
maxretry = 3
#dropbear ssh config
[dropbear]
enabled = true
port = ssh
filter = dropbear
logpath = /var/log/auth.log
bantime = 900
banaction = iptables-allports
findtime = 900
maxretry = 3
IPTABLEs -L output
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-dropbear tcp -- anywhere anywhere
fail2ban-ssh tcp -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-dropbear (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
When I run the regex
fail2ban-regex "Nov 15 09:09:16 gw dropbear[16806]: Bad password attempt for 'root' from 104.223.180.34:3703" config/filter.d/dropbear.conf
Running tests
=============
Use failregex line : config/filter.d/dropbear.conf
Traceback (most recent call last):
File "/usr/bin/fail2ban-regex", line 430, in
fail2banRegex.readRegex(cmd_regex, 'fail') or sys.exit(-1)
File "/usr/bin/fail2ban-regex", line 227, in readRegex
'add%sRegex' % regextype.title())(regex.getFailRegex())
File "/usr/share/fail2ban/server/filter.py", line 95, in addFailRegex
raise e
server.failregex.RegexException: No 'host' group in 'config/filter.d/dropbear.conf'
Хорошо, чтобы запретить Mac использовать IPV6, я должен отключить его в командной строке. Несмотря на то, что в графическом интерфейсе он отображается как «ненастроенный», он все еще получает адрес IPV6 с моего DHCP-сервера. Вот шаги, которые я предпринял.
1 )Отключить IPV6 на Mac
networksetup -setv6off Wi-Fi $$ networksetup -setv6off Ethernet (-usesetv6automatic to enable)
2 )Убедился, что мой DHCP-сервер (в данном случае это ящик, на котором я устанавливал fail2ban и dropbear )не является службой IPV6
3 )Если вам нужно отключить IPV6 на машине lixun (либо цель, либо хост)
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
=0 will enable
4 )Я вернулся к стандартному фильтру медведя fail2ban. Кажется, он был обновлен с момента моего последнего сообщения, чтобы зафиксировать разницу в случае потенциального сообщения об ошибке.
# Fail2Ban filter for dropbear
#
# NOTE: The regex below is ONLY intended to work with a patched
# version of Dropbear as described here:
# http://www.unchartedbackwaters.co.uk/pyblosxom/static/patches
# ^%(__prefix_line)sexit before auth from <HOST>.*\s*$
#
# The standard Dropbear output doesn't provide enough information to
# ban all types of attack. The Dropbear patch adds IP address
# information to the 'exit before auth' message which is always
# produced for any form of non-successful login. It is that message
# which this file matches.
#
# More information: http://bugs.debian.org/546913
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf
[Definition]
_daemon = dropbear
failregex = ^%(__prefix_line)s[Ll]ogin attempt for nonexistent user ('.*' )?from <HOST>:\d+$
^%(__prefix_line)s[Bb]ad (PAM )?password attempt for.+ from <HOST>(:\d+)?$
^%(__prefix_line)s[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '.+' from <HOST>:\d+\s*$
ignoreregex =
# DEV Notes:
#
# The first two regexs here match the unmodified dropbear messages. It isn't
# possible to match the source of the 'exit before auth' messages from dropbear
# as they don't include the "from <HOST>" bit.
#
# The second last failregex line we need to match with the modified dropbear.
#
# For the second regex the following apply:
#
# http://www.netmite.com/android/mydroid/external/dropbear/svr-authpam.c
# http://svn.dd-wrt.com/changeset/16642#file64
5 )Убедитесь, что IP-таблицы -работают с ожидаемой скоростью, используя таблицы -Команда L должна показать результат, аналогичный моему (, если у вас нет других правил ). Мне пришлось обновить ядро с помощью обновления rpi -.
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-dropbear tcp -- anywhere anywhere
fail2ban-ssh tcp -- anywhere anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-dropbear (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere