Class: WPScan::Finders::Finder::BreadthFirstDictionaryAttack::ProgressTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb

Overview

Tracks progress for password attack

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(progress_bar:, total_passwords:) ⇒ ProgressTracker

Returns a new instance of ProgressTracker.



12
13
14
15
16
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 12

def initialize(progress_bar:, total_passwords:)
  @progress_bar = progress_bar
  @total_passwords = total_passwords
  @user_requests_count = Hash.new(0)
end

Instance Attribute Details

#progress_barObject (readonly)

Returns the value of attribute progress_bar.



10
11
12
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 10

def progress_bar
  @progress_bar
end

Instance Method Details

#adjust_total_on_success(username) ⇒ Object



35
36
37
38
39
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 35

def adjust_total_on_success(username)
  @progress_bar.total -= @total_passwords - @user_requests_count[username]
rescue ProgressBar::InvalidProgressError
  # Due to Typhoeus threads, progress bar might be in invalid state
end

#incrementObject



31
32
33
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 31

def increment
  @progress_bar.increment unless @progress_bar.progress == @progress_bar.total
end

#log(message) ⇒ Object



41
42
43
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 41

def log(message)
  @progress_bar.log(message)
end

#record_request(username) ⇒ Object



18
19
20
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 18

def record_request(username)
  @user_requests_count[username] += 1
end

#requests_for_user(username) ⇒ Object



22
23
24
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 22

def requests_for_user(username)
  @user_requests_count[username]
end

#stopObject



45
46
47
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 45

def stop
  @progress_bar.stop
end

#update_title(username, password, retry_count, max_retries) ⇒ Object



26
27
28
29
# File 'lib/wpscan/finders/finder/breadth_first_dictionary_attack.rb', line 26

def update_title(username, password, retry_count, max_retries)
  retry_info = retry_count.positive? ? " (retry #{retry_count}/#{max_retries})" : ''
  @progress_bar.title = "Trying #{username} / #{password}#{retry_info}"
end