Class: Girbot::BruteForce

Inherits:
Step show all
Defined in:
lib/girbot/steps/brute_force.rb

Instance Attribute Summary

Attributes inherited from StepFoundation

#browser_holder

Instance Method Summary collapse

Methods included from WatirShortcuts

#append_to_textfield, #browser, #click, #close, #exec_js, #fire_event, #goto, #maximize, #screenshot, #select_value, #text_in_textfield

Methods inherited from StepFoundation

#initialize, read, run, #take_whole_action, #validate_auth, #validate_browser_presence, #validate_card, #wait_for_sms

Constructor Details

This class inherits a constructor from Girbot::StepFoundation

Instance Method Details

#action(options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/girbot/steps/brute_force.rb', line 3

def action options
  raise 'missing url option' if options[:url].nil?
  raise 'missing users option' if options[:users].nil?
  raise 'missing passwords option' if options[:passwords].nil?
  raise 'missing username_field option' if options[:username_field].nil?
  raise 'missing password_field option' if options[:password_field].nil?
  raise 'missing login_button option' if options[:login_button].nil?
  raise 'missing break_condition option' if options[:break_condition].nil?

  goto options[:url]

  users = read_file(options[:users])
  passwords = read_file(options[:passwords])

  users.each do |user|
    passwords.each do |password|
      puts "trying: #{user}:#{password}"
      text_in_textfield(user, options[:username_field])
      text_in_textfield(password, options[:password_field])
      click('button', options[:login_button])
      if eval options[:break_condition]
        puts "success: #{user}:#{password}"
        break
      end
    end
  end
end

#read_file(path) ⇒ Object



31
32
33
# File 'lib/girbot/steps/brute_force.rb', line 31

def read_file path
  File.read(path).lines.map(&:strip)
end