1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/usr/local/bin/perl -w
use strict;
use OTP qw(authenticate);
require "/Daten/collin/Sources/projects/pronto-cvs/pronto/prontolib.pl";
&read_prefs();
my $conn = &open_db_conn;
print "Please enter the user id: ";
my $user_id = <STDIN>;
chomp $user_id;
print "Please enter the six words: ";
my $string = <STDIN>;
chomp $string;
print "Please enter the number of md5-runs it took to generate the above words: ";
my $runs = <STDIN>;
chomp $runs;
$runs--;
print "Please enter the seed: ";
my $seed = <STDIN>;
chomp $seed;
my $sth = $conn->prepare("SELECT * FROM web_otp WHERE user_id = '$user_id'") || die $conn->errstr;
$sth->execute() || die $conn->errstr;
my @row = $sth->fetchrow();
$sth->finish();
if (@row > 0) {
print "Updating $user_id\n";
$conn->do("UPDATE web_otp SET last_otp = '" . authenticate($string) . "', runs = $runs, seed = '$seed' " .
"WHERE user_id = '$user_id'");
}
else {
print "Inserting new user\n";
my $sql = "INSERT INTO web_otp (user_id, last_otp, seed, runs) VALUES ('$user_id', '" .
authenticate($string) . "', '$seed', $runs)";
$conn->do($sql) || die $conn->errstr;
}
END {
$conn->disconnect();
}
|