Skip to content

Instantly share code, notes, and snippets.

@untra
Last active September 21, 2015 22:34
Show Gist options
  • Save untra/cd20433aeb62b4d71a6a to your computer and use it in GitHub Desktop.
Save untra/cd20433aeb62b4d71a6a to your computer and use it in GitHub Desktop.
require 'digest'
require 'set'
sayler = [ARGV[0].to_i, 1].max || 6
pause = [ARGV[1].to_i, 1].max || 100000
puts "MD5 SAYLER-#{sayler} COLLISION FINDER"
puts "WITH CUSHY UPDATES FROM SAM VOLIN EVERY #{pause} SEARCHES"
sleep(1)
puts "PUMP YOUR BREAKS KID IT'S ABOUT TO GET SPICY"
puts "IN 3..."
sleep(1)
puts "IN 2..."
sleep(1)
puts "IN 1..."
sleep(1)
puts '=================== GO!! ==================='
count = 0
string = ''
dict = {}
set = Set.new []
md5 = Digest::MD5.new
value = ''
digest = ''
loop do
md5.reset
md5 << string
digest = md5.hexdigest
value = digest[0..(sayler-1)] + digest[-(sayler)..-1]
break if set.include? value
set.add value
dict[value] = string
# append newline to account for echo linefeed
string = "#{digest}\n"
count += 1
if (count % pause) == 0
puts "#{value} | #{count}"
end
end
puts '=============================================='
puts "FOUND SOLUTION #{value} IN #{count} SEARCHES"
puts "#{string}"
puts ">> #{digest}"
puts "#{dict[value]}"
md5.reset
md5 << dict[value]
puts ">> #{md5.hexdigest}"
puts 'SAM VOLIN WOULD LIKE TO REMIND YOU:'
puts ' EAT YOUR VEGGIES AND DONT DO DRUGS'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment