From 28308e5ab2680878222735baaf3ec318f5814f6b Mon Sep 17 00:00:00 2001 From: Abel `00z' Camarillo <00z@the00z.org> Date: Mon, 30 Jun 2008 23:41:38 -0500 Subject: [PATCH] Deleted content line tracking and badness tracking. And a very ugly typo (bug). --- blocksshd | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/blocksshd b/blocksshd index 884b3bb..03788f5 100755 --- a/blocksshd +++ b/blocksshd @@ -149,8 +149,8 @@ alarm( ($cfg->{unblock_timeout} /2) ); # sshd[] Failed password for from # last message repeated 2 times. # -# this var stores a hash ref to the previous line that contain the line -# content, a array ref to the IPs to block and its badness. +# this var stores a hash ref that contain an array ref to the IPs that the +# previous line blocked my $prev_line; while () @@ -160,14 +160,17 @@ while () next; } -# if the previous line was a bad line - if ($prev_line->{'bad'}) +# if the previous line was a bad line (it blocked some ips) + if ($prev_line->{'ip'}) { # `block' it again N times if (my ($times) = /last message repeated ([[:digit:]]+) times/i) { map { block($_) } @{$prev_line->{'ip'}} while ($times--); - } + } +# and this line is not bad. (you cannot nest repeated messages, that will be +# silly) + $prev_line = {ip => undef}; next; } @@ -204,16 +207,16 @@ while () block($rr->address); push @ips, $rr->address; } - $prev_line = {content => $_ , ip => \@ips, bad => 1}; + $prev_line = {ip => \@ips}; } } } else { block($IP); - $prev_line = {content => $_ , ip => [$IP], bad => 1}; + $prev_line = {ip => [$IP]}; } } } else { - $prev_line = {content => $_ , ip => undef, bad => 0}; + $prev_line = {ip => undef}; } } -- 2.11.4.GIT