2013-11-08 10:32:12 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use IO::Socket::INET;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my %otps = (
|
|
|
|
'idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgku' => 'OK counter=0001 low=8d40 high=0f use=00',
|
|
|
|
'idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgkv' => 'ERR Corrupt OTP',
|
|
|
|
);
|
|
|
|
|
|
|
|
my $socket = new IO::Socket::INET (
|
|
|
|
LocalHost => '127.0.0.1',
|
2015-08-12 10:50:08 +02:00
|
|
|
LocalPort => '8002',
|
2013-11-08 10:32:12 +01:00
|
|
|
Proto => 'tcp',
|
|
|
|
Listen => 10,
|
|
|
|
Reuse => 1
|
|
|
|
) or die "Oops: $! \n";
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
my $clientsocket = $socket->accept();
|
|
|
|
my $clientdata = <$clientsocket>;
|
|
|
|
my $ret = "ERR Unknown yubikey";
|
|
|
|
if($clientdata =~ m/otp=([cbdefghijklnrtuv]+)/) {
|
|
|
|
my $otp = $1;
|
|
|
|
if($otps{$otp}) {
|
|
|
|
$ret = $otps{$otp};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print $clientsocket "\n$ret\n";
|
|
|
|
close $clientsocket;
|
|
|
|
}
|