WpUser#brute_force Browser.instance replaced by a local var

This commit is contained in:
erwanlr
2013-04-15 15:55:48 +02:00
parent 7c2c2305fb
commit 7143c7ffe9

View File

@@ -10,14 +10,15 @@ class WpUser < WpItem
# #
# @return [ void ] # @return [ void ]
def brute_force(wordlist, options = {}) def brute_force(wordlist, options = {})
hydra = Browser.instance.hydra browser = Browser.instance
hydra = browser.hydra
passwords = BruteForcable.passwords_from_wordlist(wordlist) passwords = BruteForcable.passwords_from_wordlist(wordlist)
login = self.login login = self.login
login_url = @uri.merge('wp-login.php').to_s login_url = @uri.merge('wp-login.php').to_s
queue_count = 0 queue_count = 0
found = false found = false
progress_bar = ProgressBar.create(format: '%t %a <%B> (%c / %C) %P%% %e', progress_bar = ProgressBar.create(format: '%t %a <%B> (%c / %C) %P%% %e',
title: " Brute Forcing user '#{login}'", title: " Brute Forcing '#{login}'",
length: 120, length: 120,
total: passwords.size) if options[:show_progression] total: passwords.size) if options[:show_progression]
@@ -29,10 +30,10 @@ class WpUser < WpItem
) )
request.on_complete do |response| request.on_complete do |response|
puts "\n Trying Username : #{login} Password : #{password}" if options[:verbose]
progress_bar.progress += 1 if options[:show_progression] && !found progress_bar.progress += 1 if options[:show_progression] && !found
puts "\n Trying Username : #{login} Password : #{password}" if options[:verbose]
if valid_password?(response, password, options) if valid_password?(response, password, options)
self.password = password self.password = password
found = true found = true
@@ -48,10 +49,10 @@ class WpUser < WpItem
# hydra.run only returns when it has recieved all of its, # hydra.run only returns when it has recieved all of its,
# responses. This means that while we are waiting for @threads, # responses. This means that while we are waiting for @threads,
# responses, we are waiting... # responses, we are waiting...
if queue_count >= Browser.instance.max_threads if queue_count >= browser.max_threads
hydra.run hydra.run
queue_count = 0 queue_count = 0
puts "Sent #{Browser.instance.max_threads} requests ..." if options[:verbose] puts "Sent #{browser.max_threads} requests ..." if options[:verbose]
end end
end end