wer auch das Problem hat, das mann auf dem Server keine iptables hat so wie ich kann das ganze auch mit hostsdeny machen....
erstellt euch eine Datei auf dem server Namens blacklist.php mit folgendem inhalt! Kopiert die ins /root/scripts ( wenn nicht vorhanden erstellen)
Code: Alles auswählen
<?php
# blacklisten einlesen
#DSHIELD blacklist
$blacklist_source[0] = file("http://dshield.org/feeds/suspiciousdomains_Low.txt");
# Infiltrated.net Blacklist
$blacklist_source[1] = file("http://www.infiltrated.net/blacklisted");
# blocklist.de Blacklist
$blacklist_source[3] = file("http://lists.blocklist.de/lists/all.txt");
# Lokale Blacklist
$blacklist_source[2] = file("/usr/local/etc/blacklist.txt");
$hosts = 0;
system("rm /tmp/blacklist");
foreach ($blacklist_source as $bl)
{
echo "Lese Blacklist $bl...";
foreach ($bl as $line)
{
$line = trim($line);
if (substr($line,0,1) == "#") continue;
if (substr($line,0,1) == "-") continue;
if (substr($line,0,1) == "A") continue;
if (substr($line,0,1) == "\r\n") continue;
if (substr($line,0,1) == " ") continue;
if (substr($line,0,1) == "\t") continue;
if (substr($line,0,1) == "\n") continue;
if (strlen($line) < 5) continue;
echo "Gefunden -> " . $line;
echo "\n";
system("echo \"ALL: $line\" >> /tmp/blacklist");
$hosts++;
}
}
echo "$hosts Adressen gefunden.";
system ("rm /etc/hosts.deny");
system ("cp /tmp/blacklist /etc/hosts.deny");
die Listen werden dann in die hosts.deny eingetragen..... zb: ALL: <ip>
jetzt noch ein Cron drauf legen fertig wie
zB:
/usr/bin/php /root/scripts/blacklist.php
(Täglich zu mitternacht)
zu fail2ban
unter /etc/fail2ban/action.d muÃÂÃÂ die datei hostsdeny.conf erstellt werden (falls nicht vorhanden) mit folgendem inhalt
Code: Alles auswählen
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
#
# $Revision: 660 $
#
[Definition]
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart =
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
actionstop =
# Option: actioncheck
# Notes.: command executed once before each actionban command
# Values: CMD
#
actioncheck =
# Option: actionban
# Notes.: command executed when banning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: <ip> IP address
# <failures> number of failures
# <time> unix timestamp of the ban time
# Values: CMD
#
actionban = IP=<ip> &&
printf %%b "ALL: $IP\n" >> <file>
# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: <ip> IP address
# <failures> number of failures
# <time> unix timestamp of the ban time
# Values: CMD
#
actionunban = IP=<ip> && sed -i.old /ALL:\ $IP/d <file>
[Init]
# Option: file
# Notes.: hosts.deny file path.
# Values: STR Default: /etc/hosts.deny
#
file = /etc/hosts.deny
ich fail2ban die jail.conf anpassen
einfÃÂügen action = hostsdeny
wie hier zum beispiel
Code: Alles auswählen
[ssh]
enabled = true
port = ssh
filter = sshd
action = hostsdeny
logpath = /var/log/auth.log
maxretry = 2
ich weiÃÂÃÂ jetzt nur nicht wie und ob er das an blocklist Reportiert
wer mal eine Iddee hat kann sich ja melden
LG
Thomas Martin