Tr0n_

Untitled

May 14th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. require 'pbkdf2.rb'
  2.  
  3. args = ARGV # arguments in the following order: salt hash iterations samples.txt transformations.txt -v
  4.  
  5. if !args.empty?
  6. salt = args[0]
  7. hash = args[1]
  8. iterations = Integer(args[2])
  9. samplesTxt = args[3]
  10. transformsTxt = args[4]
  11. else
  12. puts "Error: Following order required: \"salt hash iterations samples.txt transformations.txt [-v]\""
  13. end
  14.  
  15. # puts PBKDF2.new(:password=>"1337", :salt=>"kikugalanet", :iterations=>10000).hex_string
  16.  
  17.  
  18. if ARGV.include? "-v"
  19. debug = true
  20. end
  21.  
  22. # Guess by file approach
  23.  
  24. if debug
  25. puts "Testing words from #{samplesTxt}"
  26. end
  27.  
  28. samplesFile = File.new(samplesTxt, "r")
  29.  
  30. IO.foreach(samplesFile){|sampleLine|
  31. temp_password = PBKDF2.new(:password=>sampleLine, :salt=>salt, :iterations=>iterations)
  32. if hash == temp_password.hex_string
  33. puts "PASSWORD FOUND: #{sampleLine}"
  34. samplesFile.close
  35. exit
  36. else
  37. if debug
  38. puts "Failed: #{sampleLine}"
  39. end
  40. end
  41. }
  42.  
  43. # Tranformations approach
  44.  
  45. if debug
  46. puts "Testing permutations using #{transformsTxt}"
  47. end
  48.  
  49. samplesFile = File.new(samplesTxt, "r")
  50. transformsFile = File.new(transformsTxt, "r")
  51.  
  52. IO.foreach(samplesFile){|sampleLine|
  53. temp = sampleLine
  54. IO.foreach(transformsFile){|transformLine|
  55. split = transformLine.split
  56. temp = temp.gsub(split[0].match(/(?<=\/)(.*?)(?=\/)/).to_s, split[1].match(/(?<=\')(.*?)(?=\')/).to_s)
  57. }
  58.  
  59. temp_password = PBKDF2.new(:password=>temp, :salt=>salt, :iterations=>iterations)
  60.  
  61. if hash == temp_password.hex_string
  62. puts "PASSWORD FOUND: #{temp}"
  63. samplesFile.close
  64. transformsFile.close
  65. exit
  66. else
  67. if debug
  68. puts "Failed: #{temp}"
  69. end
  70. end
  71. }
  72.  
  73. samplesFile.close
  74. transformsFile.close
  75.  
  76. # Brute Force approach
  77.  
  78. if debug
  79. puts "Last Method: \"Brute Force\" initialized"
  80. end
Advertisement
Add Comment
Please, Sign In to add comment