Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions bozocrack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ def crack
private

def crack_single_hash(hash)
response = Net::HTTP.get URI("http://www.google.com/search?q=#{hash}")
if plaintext = crack_single_hash_with_website(hash, "http://www.google.com/search?q=#{hash}")
return plaintext
end
if plaintext = crack_single_hash_with_website(hash, "http://www.google.com/search?q=md5+#{hash}")
return plaintext
end
nil
end

def crack_single_hash_with_website(hash, url)
response = Net::HTTP.get URI(url)
wordlist = response.split(/\s+/)
if plaintext = dictionary_attack(hash, wordlist)
return plaintext
Expand All @@ -48,6 +58,12 @@ def dictionary_attack(hash, wordlist)
if Digest::MD5.hexdigest(word) == hash.downcase
return word
end
sub_wordlist = word.split(/[^a-zA-Z0-9]+/)
if (sub_wordlist.size > 1)
if plaintext = dictionary_attack(hash, sub_wordlist)
return plaintext
end
end
end
nil
end
Expand All @@ -74,4 +90,4 @@ def append_to_cache(hash, plaintext, filename = "cache")
BozoCrack.new(ARGV[0]).crack
else
puts "Usage example: ruby bozocrack.rb file_with_md5_hashes.txt"
end
end