Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'yaml'
- require 'dbi'
- require 'digest/sha1'
- dbconfig = YAML::load(File.open("/usr/share/redmine/config/database.yml"))["production"]
- dbname = dbconfig["database"]
- username = dbconfig["username"]
- dbpassword = dbconfig["password"]
- host = dbconfig["host"]
- connstr = "DBI:Mysql:" + dbname
- connstr += ":" + host if host != nil
- login = gets.strip
- password = gets.strip
- hashed_password,salt = DBI.connect(connstr, username, dbpassword) {|dbh|
- dbh.select_one("select hashed_password,salt from users where type='User' and login=?", login)
- }
- exit(2) if hashed_password == nil || salt == nil
- exit(1) if Digest::SHA1.hexdigest(salt+Digest::SHA1.hexdigest(password)) != hashed_password
Add Comment
Please, Sign In to add comment