...
Code Block | ||||
---|---|---|---|---|
| ||||
use DBI; my $dbfile = "users.db"; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","") or die "Couldn't connect to database: " . DBI->errstr; sub hash() { # hash the password } print "Enter your id: "; my $userid = <STDIN>; chomp $userid; print "Enter your password: "; my $password = <STDIN>; chomp $password; my $hashed_password = hash( password$password); my $sth = $dbh->prepare("SELECT * FROM Users WHERE userid = '$userid' AND password = '$hashed_password'") or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute($userid, $hashed_password) or die "Couldn't execute statement: " . $sth->errstr; if (my @data = $sth->fetchrow_array()) { my $username = $data[1]; my $id = $data[2]; print "Access granted to user: $username ($userid)\n"; } if ($sth->rows == 0) { print "Invalid username / password. Access denied\n"; } $sth->finish; $dbh->disconnect; |
...
Code Block | ||||
---|---|---|---|---|
| ||||
use DBI; my $dbfile = "users.db"; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","") or die "Couldn't connect to database: " . DBI->errstr; sub hash() { # hash the password } print "Enter your id: "; my $userid = <STDIN>; chomp $userid; print "Enter your password: "; my $password = <STDIN>; chomp $password; my $hashed_password = hash( password); my # ... beginning of code my $sth = $dbh->prepare("SELECT * FROM Users WHERE userid = ? AND password = ?") or die "Couldn't prepare statement: " . $dbh->errstr; $sth->execute($userid, $hashed_password) or die "Couldn't execute statement: " . $sth->errstr; if (my @data = $sth->fetchrow_array()) { my $username = $data[1]; my $id = $data[2]; print "Access granted to user: $username ($userid)\n"; } if ($sth->rows == 0) { print "Invalid username / password. Access denied\n"; } $sth->finish; $dbh->disconnect;# ... rest of code |
Risk Assessment
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
IDS33-PL | high | likely | high | P9 | L2 |
...