Created
June 23, 2014 21:08
-
-
Save njvack/0a3a339caf4ee370d2d8 to your computer and use it in GitHub Desktop.
A little Ruby Mechanize script to force logging in to Coins. The web standards, they have not been followed at all.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'mechanize' | |
require 'pp' | |
def coins_login(agent, username, password) | |
page = agent.get "https://chronus.mrn.org/cas/login.php?rp=https%3A%2F%2Fchronus.mrn.org%2Fmicis%2Findex.php%3Fsubsite%3Dasmt" | |
uname_match = page.body.match /name="([^"]+)" placeholder="Username/ | |
uname_field = uname_match[1] | |
pw_match = page.body.match /name="([^"]+)" placeholder="Pa\$\$w0rd/ | |
pw_field = pw_match[1] | |
f = Mechanize::Form.new(page) | |
f.method = "POST" | |
f.action = "/cas/login.php" | |
f.add_field! "ref", "https://chronus.mrn.org/micis/index.php" | |
f.add_field! uname_field, username | |
f.add_field! pw_field, password | |
page = agent.submit(f) | |
end | |
agent = Mechanize.new | |
page = coins_login(agent, ARGV[0], ARGV[1]) | |
pp page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment