Skip to content

Instantly share code, notes, and snippets.

@danielnegri
Created August 4, 2014 21:08
Show Gist options
  • Select an option

  • Save danielnegri/dfbe3ef41bfea01845b7 to your computer and use it in GitHub Desktop.

Select an option

Save danielnegri/dfbe3ef41bfea01845b7 to your computer and use it in GitHub Desktop.
Brute Force Decrypter
#!/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