Last active
September 6, 2017 19:33
-
-
Save bion/f97a50890136ea6c9500ba7b1d28384e to your computer and use it in GitHub Desktop.
password game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://crackstation.net/buy-crackstation-wordlist-password-cracking-dictionary.htm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'io/console' | |
| require 'zlib' | |
| puts "give me a password to test then press enter. (it won't be displayed as you type):" | |
| candidate = STDIN.noecho(&:gets) | |
| io = File.open "crackstation.txt.gz" | |
| gz = Zlib::GzipReader.new io | |
| count = 0 | |
| total_size = 1212356293.0 | |
| percent = 0 | |
| pretty_count = nil | |
| puts | |
| def found(pw) | |
| puts | |
| puts "found your password! it's \"#{pw}\"" | |
| exit 0 | |
| end | |
| gz.each do |line| | |
| count += 1 | |
| if line == candidate | |
| found(line) | |
| break | |
| end | |
| if count % 1_000_000 == 0 | |
| percent = (count / total_size) * 100 | |
| pretty_count = count.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse | |
| line = line.ascii_only? ? line[0...20].gsub(/\s/, ' ') : "" | |
| line += " " * (20 - line.size) | |
| print " tried #{pretty_count} of 1,212,356,293 passwords (#{percent.round(2)}%) ==> #{line}\r" | |
| end | |
| end | |
| puts "password not found ;-)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment