Created
June 4, 2015 16:19
-
-
Save wisq/ed0fd831b65270352874 to your computer and use it in GitHub Desktop.
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/md5' | |
| def random_hex(length) | |
| bytes_needed = (length + 1) / 2 | |
| bytes = $urandom.read(bytes_needed) | |
| hex = ("%02x" * bytes_needed) % bytes.bytes | |
| return hex[0,length] | |
| end | |
| pids = [] | |
| (1..32).each do |size| | |
| pids << fork do | |
| $urandom = File.open("/dev/urandom") | |
| $0 = "md5self(#{size})" | |
| templates = nil | |
| if size == 32 | |
| templates = [ | |
| "the MD5 of this message is ", | |
| "the md5 of this message is ", | |
| "The MD5 of this message is ", | |
| "The md5 of this message is ", | |
| "this message's MD5 is ", | |
| "this message's md5 is ", | |
| "This message's MD5 is ", | |
| "This message's md5 is ", | |
| "this message has an MD5 of ", | |
| "this message has an md5 of ", | |
| "This message has an MD5 of ", | |
| "This message has an md5 of ", | |
| ] | |
| else | |
| templates = [ | |
| "the MD5 of this message starts with ", | |
| "the md5 of this message starts with ", | |
| "The MD5 of this message starts with ", | |
| "The md5 of this message starts with ", | |
| "this message's MD5 starts with ", | |
| "this message's md5 starts with ", | |
| "This message's MD5 starts with ", | |
| "This message's md5 starts with ", | |
| "the MD5 of this message begins with ", | |
| "the md5 of this message begins with ", | |
| "The MD5 of this message begins with ", | |
| "The md5 of this message begins with ", | |
| "this message's MD5 begins with ", | |
| "this message's md5 begins with ", | |
| "This message's MD5 begins with ", | |
| "This message's md5 begins with ", | |
| "this message has an MD5 starting with ", | |
| "this message has an md5 starting with ", | |
| "This message has an MD5 starting with ", | |
| "This message has an md5 starting with ", | |
| "this message has an MD5 beginning with ", | |
| "this message has an md5 beginning with ", | |
| "This message has an MD5 beginning with ", | |
| "This message has an md5 beginning with ", | |
| ] | |
| end | |
| loop do | |
| wanted = random_hex(size) | |
| templates.each do |templ| | |
| message = templ + wanted | |
| actual = Digest::MD5.hexdigest(message) | |
| if actual.start_with?(wanted) | |
| puts message | |
| exit(0) | |
| end | |
| end | |
| end | |
| end | |
| end | |
| until pids.empty? | |
| pids.delete(Process.wait) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment