K_M_McMahon has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my ($attempt,$failed)=(0,0); my (%ip,%usr); opendir(TEMP,'.') or die "I can't open the current directory.\n"; my @files=grep(/^messages/,readdir(TEMP)); closedir(TEMP); foreach my $file (@files) { print "Found $file\n"; &check($file); } print "Found $attempt intrustion attempts.\n"; print "Found ($failed) failed matches.\n"; foreach my $key (keys(%ip)) { print "Found $ip{$key} attempts from $key\n"; } foreach my $key (keys(%usr)) { print "Found $usr{$key} attempts for $key.\n"; } sub check { my $file=shift; open(LOG,"<$file") or die "Can't open $file\n"; while (<LOG>) { next if $_!~m/Failed/; $attempt++; my ($username,$ip_no)=$_=~/Failed .* for (?:illegal user )?(\w ++-?\w*) from ::[a-f0-9]{4}:(\d+\.\d+\.\d+\.\d+)/; if ((defined($username))&&(defined($ip_no))) { $ip{$ip_no}++; $usr{$username}++; } else {$failed++; } } close(LOG); }
my $a='62696c6c77667269656e6440676d61696c2e636f6d'; while ($a=~m/(^.{2})/s) {print unpack('A',pack('H*',"$1"));$a=~s/^.{2}//s;}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting hash values
by davido (Cardinal) on May 23, 2005 at 05:34 UTC | |
|
Re: Sorting hash values
by Zaxo (Archbishop) on May 23, 2005 at 05:36 UTC | |
|
Re: Sorting hash values
by K_M_McMahon (Hermit) on May 23, 2005 at 05:42 UTC |