![]() Now, to learn how to implement it for your case, head over to its quickstart guide. sudo apt-get install phantomjsĪfter this you write javascript script and run it using phantomjs: phantomjs script.js On Ubuntu based systems, you can install it using the package manager or you could build it from source from their home page. Solution using phantomjsįirst you will need to install phantomjs. Two popular headless browsers are phantomjs (javascript) and Ghost.py (python). They provide automated control of a web page in an environment similar to popular web browsers, but are executed via a command line interface or using network communication. Why are you playing around with wget? Better use some headless browser to automate this task.Ī headless browser is a web browser without a graphical user interface. Note that wget follows redirection all by himself, which helps us quite a bit in this case. Wget -load-cookies sso.cki -save-cookies auth.cki -keep-session-cookies -post-data='j_username=usr&j_password=pwd' '' Wget -load-cookies phpsid.cki -save-cookies sso.cki -keep-session-cookies -header="Referer: $origin" '' Wget -save-cookies phpsid.cki -keep-session-cookies "$origin" The first four steps can be done with wget like this : origin='' You enter your credentials and send the post data j_username and j_password along with the cookie from the SSO response.The SSO response sets a new cookie named _idp_authn_lc_key and redirects you to the page which redirects you again to (the real login page).Clicking the login button sends a request to which takes the PHPSESSID cookie (not sure if it uses it) and redirects you to the SSO engine with a specially crafted url just for you which looks like this :.The page sets a PHPSESSID cookie and present you with login options.That being said, here is what's happening : That being said, I cannot make sure that it works because, well, I don't have (nor do I want) valid credentials. With the page of origin, I was able to understand a little more of what is happening. Try -post-data='j_username=yourusername&j_password=yourpassword option to wget. It seems that you indeed need the POST method with the j_username and j_password set. ![]() For a POST request you can use wget's -post-data=the_needed_info option to use the post method on the needed login info.The url would probably look something like For a GET request, you can add the GET parameters directly in the address wget must fetch (make sure you properly quote the &, = and other special characters).If the -password and -username option doesn't work, you must find out the info sent to the server by the login page and mimic it : Use wget's -load-cookies mycookies.txt option on the subsequent pages you are trying to retrieve. ![]()
0 Comments
Leave a Reply. |