Skip to content

Instantly share code, notes, and snippets.

@Zapotek
Created October 30, 2014 07:00
Show Gist options
  • Save Zapotek/1f6eda3422f461c4fc17 to your computer and use it in GitHub Desktop.
Save Zapotek/1f6eda3422f461c4fc17 to your computer and use it in GitHub Desktop.
Custom login plugin using a login sequence.
# Automated login plugin using a custom login sequence.
#
# @author Tasos "Zapotek" Laskos <[email protected]>
class Arachni::Plugins::MyLogin < Arachni::Plugin::Base
# Login operation using Watir.
#
# @param [Watir] watir
#
# @see http://watirwebdriver.com/
def login_sequence( watir )
watir.goto 'http://testfire.net/bank/login.aspx'
form = watir.form( id: 'login' )
form.text_field( name: 'uid' ).set 'jsmith'
form.text_field( name: 'passw' ).set 'Demo1234'
form.submit
end
def prepare
framework_pause
print_info 'System paused.'
end
def run
session.record_login_sequence do |browser|
print_info 'Running sequence.'
login_sequence browser.watir
print_info 'Sequence completed.'
browser.to_page
end
session.login
# You'll need to have configured the session login check via the usual
# system options.
if !session.logged_in?
print_error 'Login failed.'
@failed = true
return
end
print_ok 'Login was successful'
print_info 'Cookies set to:'
http.cookies.inject({}){ |h, c| h.merge!( c.simple ) }.each do |name, val|
print_info " * #{name.inspect} = #{val.inspect}"
end
rescue => e
print_exception e
@failed = true
end
def clean_up
if @failed
print_info 'Aborting the scan.'
framework_abort
return
end
framework_resume
end
def self.info
{
name: 'MyLogin',
description: %q{},
author: 'Tasos "Zapotek" Laskos <[email protected]>',
version: '0.1',
priority: 0 # run before any other plugin
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment