Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'pbkdf2.rb'
- args = ARGV # arguments in the following order: salt hash iterations samples.txt transformations.txt -v
- if !args.empty?
- salt = args[0]
- hash = args[1]
- iterations = Integer(args[2])
- samplesTxt = args[3]
- transformsTxt = args[4]
- else
- puts "Error: Following order required: \"salt hash iterations samples.txt transformations.txt [-v]\""
- end
- # puts PBKDF2.new(:password=>"1337", :salt=>"kikugalanet", :iterations=>10000).hex_string
- if ARGV.include? "-v"
- debug = true
- end
- # Guess by file approach
- if debug
- puts "Testing words from #{samplesTxt}"
- end
- samplesFile = File.new(samplesTxt, "r")
- IO.foreach(samplesFile){|sampleLine|
- temp_password = PBKDF2.new(:password=>sampleLine, :salt=>salt, :iterations=>iterations)
- if hash == temp_password.hex_string
- puts "PASSWORD FOUND: #{sampleLine}"
- samplesFile.close
- exit
- else
- if debug
- puts "Failed: #{sampleLine}"
- end
- end
- }
- # Tranformations approach
- if debug
- puts "Testing permutations using #{transformsTxt}"
- end
- samplesFile = File.new(samplesTxt, "r")
- transformsFile = File.new(transformsTxt, "r")
- IO.foreach(samplesFile){|sampleLine|
- temp = sampleLine
- IO.foreach(transformsFile){|transformLine|
- split = transformLine.split
- temp = temp.gsub(split[0].match(/(?<=\/)(.*?)(?=\/)/).to_s, split[1].match(/(?<=\')(.*?)(?=\')/).to_s)
- }
- temp_password = PBKDF2.new(:password=>temp, :salt=>salt, :iterations=>iterations)
- if hash == temp_password.hex_string
- puts "PASSWORD FOUND: #{temp}"
- samplesFile.close
- transformsFile.close
- exit
- else
- if debug
- puts "Failed: #{temp}"
- end
- end
- }
- samplesFile.close
- transformsFile.close
- # Brute Force approach
- if debug
- puts "Last Method: \"Brute Force\" initialized"
- end
Advertisement
Add Comment
Please, Sign In to add comment