Tr0n_

Untitled

May 14th, 2018
2,140
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.65 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]) rescue Integer(0)
  9.   if iterations <= 0
  10.     puts "Iterations \" #{args[2]} \" has to be a number > 0"
  11.     puts "Exiting..."
  12.     exit
  13.   end
  14.   samplesTxt = args[3]
  15.   transformsTxt = args[4]
  16. else
  17.   puts "Run this program with the following command line arguments"
  18.   puts "Following order required: \"salt hash iterations samples.txt transformations.txt -v\" -v is optional."
  19.   puts "Example usage: kikugalanet 7d69838932ccb599fe218f896e23dc8934b297736cf9be1ac3a5d4cc7a223beb 10000 bullshit.txt transformations.txt -v"
  20. end
  21.  
  22. if ARGV.include? "-v"
  23.   debug = true
  24. end
  25.  
  26. # Guess by file approach
  27.  
  28. if debug
  29.   puts "Testing words from #{samplesTxt}"
  30.   sleep(3)
  31. end
  32.  
  33. if File.exist?(samplesTxt)
  34.   samplesFile = File.new(samplesTxt, "r")
  35. else
  36.   puts "File #{samplesTxt} doesn't exist. Exiting now..."
  37.   exit
  38. end
  39.  
  40. IO.foreach(samplesFile){|sampleLine|
  41.   temp_password = PBKDF2.new(:password=>sampleLine.chomp, :salt=>salt, :iterations=>iterations)
  42.   if hash == temp_password.hex_string
  43.     puts "PASSWORD FOUND: #{sampleLine}"
  44.     exit
  45.   else
  46.     if debug
  47.       puts "Failed: #{sampleLine}"
  48.     end
  49.   end
  50. }
  51.  
  52. # Tranformations approach
  53.  
  54. if debug
  55.   puts "Testing permutations using #{transformsTxt}"
  56.   sleep(3)
  57. end
  58.  
  59. if File.exist?(transformsTxt)
  60. transformsFile = File.new(transformsTxt, "r")
  61. else
  62.   puts "File #{transformsTxt} doesn't exist. Exiting now..."
  63.   exit
  64. end
  65.  
  66. IO.foreach(samplesFile){|sampleLine|
  67.   temp = sampleLine.chomp
  68.   IO.foreach(transformsFile){|transformLine|
  69.     split = transformLine.chomp.split
  70.     temp = temp.gsub(split[0].match(/(?<=\/)(.*?)(?=\/)/).to_s, split[1].match(/(?<=\')(.*?)(?=\')/).to_s)
  71.  }
  72.  
  73.  temp_password = PBKDF2.new(:password=>temp, :salt=>salt, :iterations=>iterations)
  74.  
  75.  if hash == temp_password.hex_string
  76.    puts "PASSWORD FOUND: #{temp}"
  77.    exit
  78.  else
  79.    if debug
  80.      puts "Failed: #{temp}"
  81.    end
  82.  end
  83. }
  84.  
  85. # Brute Force approach
  86.  
  87. if debug
  88.  puts "Last Method: \"Brute Force\" initialized"
  89.  sleep(3)
  90. end
  91.  
  92. chars = (0000..9999).to_a + ("aaaa".."zzzz").to_a
  93. ctr = 0
  94.  
  95. chars.each {|elem|
  96.  ctr = ctr + 1
  97.  temp_password = PBKDF2.new(:password=>elem.to_s, :salt=>salt, :iterations=>iterations)
  98.  
  99.  if hash == temp_password.hex_string
  100.    puts "PASSWORD FOUND: #{temp_password.password}"
  101.    exit
  102.  else
  103.    if debug
  104.     puts "Try No.: #{ctr} of #{chars.length} Failed: #{temp_password.password}"
  105.    end
  106.  end
  107. }
  108.  
  109. puts "Passwort couldn't be found. Try again later."
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment