Created
January 7, 2016 01:58
-
-
Save sohara/fee905e411df101b6dba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mechanize' | |
LOGIN_PAGE = "https://remote.advancepubs.com/dana-na/auth/url_30/welcome.cgi" | |
@dsid = '' | |
@agent = Mechanize.new | |
@agent.get(LOGIN_PAGE) do |page| | |
login_result = page.form_with(:name => 'frmLogin') do |login| | |
login.username = 'USERNAME' | |
login.password = 'PASSWORD' | |
login.realm = 'Conde Nast' | |
end.submit | |
final_page = login_result.form_with(:name => 'frmLogin') do |login_2| | |
login_2 | |
login_2["user#2"] = 'SOHARA' | |
login_2["password#2"] = 'SECONDARY_PASSWORD' | |
end.submit | |
pp final_page | |
pp final_page.uri | |
pp @agent.page.uri | |
pp final_page.body | |
if @agent.page.uri.to_s.include?('welcome.cgi') | |
confirmation_result = final_page.form_with(:name => 'frmConfirmation') do |confirmation| | |
confirmation.checkboxes_with.each do |checkbox| | |
checkbox_name = checkbox.name | |
checkbox_value = checkbox.value | |
confirmation.add_field(checkbox_name, checkbox_value) | |
end | |
end.submit | |
end | |
pp @agent.cookie_jar.jar | |
pp "Cookies method" | |
pp @agent.cookies | |
@dsid = @agent.cookies.detect{|c| c.name == 'DSID'}.value | |
pp @dsid | |
end | |
connect_command = 'sudo openconnect --juniper -C "DSID=' + @dsid + '" remote.advancepubs.com' | |
exec connect_command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment