Created
August 4, 2014 21:08
-
-
Save danielnegri/dfbe3ef41bfea01845b7 to your computer and use it in GitHub Desktop.
Brute Force Decrypter
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 'digest/sha1' | |
| class UnAuth | |
| LIMIT = 10 | |
| SALT = '' | |
| def initialize(encrypted_password) | |
| @digits = [*('0'..'9'), *('a'..'z'), *('A'..'Z')] | |
| @encrypted_password = encrypted_password | |
| end | |
| def crack(password) | |
| return password if @encrypted_password == encrypt(password) | |
| map_digits(password).each do |text| | |
| if password.size < LIMIT | |
| password = "#{text}" | |
| crack(password) | |
| puts password | |
| end | |
| end | |
| password | |
| end | |
| def map_digits(sufix) | |
| @digits.map do |d| | |
| "#{d}#{sufix}" | |
| end | |
| end | |
| def encrypt(text, salt = '') | |
| Digest::SHA1::hexdigest("#{salt}--#{text}--") | |
| end | |
| end | |
| if ARGV.size == 1 | |
| app = UnAuth.new(ARGV[0]) | |
| app.crack('') | |
| else | |
| puts "Usage example: ruby unauth.rb encrypted_password" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment