列表 1. 用于查找身份验证错误的示例 Perl 脚本

#!/usr/bin/perl
open(IN, '/var/log/messages');
@buffer = <IN>;
close IN;

foreach $line (@buffer) {
    if ($line =~ /authentication failure/) {
        $line =~ /^([a-zA-Z]{3} [ 0-9]+
        [0-9:]*).*logname=([a-zA-Z0-9]*).*user=
        ([a-zA-Z0-9]*)$/;
    print "$2 attempted to log in as $3 on $1\n";
    }
}
© . All rights reserved.