Finch has asked for the wisdom of the Perl Monks concerning the following question:
<form action="/admin/index.php?action=login" method="post" name="actio +n"> <input type="hidden" name="ADMIN" value="f23af307ea00b284fb9e74c4cb +abfbdf" /> <input type="text" name="username" size="12" value=""> <input type="password" name="password" size="12"> <input type="submit" name="login" value="Login"> </form>
01: use WWW::Mechanize; 02: use LWP::Debug qw(+); 03: 04: $username = "xxx"; 05: $password = "xxx"; 06: 07: my $mech = WWW::Mechanize->new(); 08: 09: $mech->cookie_jar(HTTP::Cookies->new()); 10: $mech->get( "https://mySite.de/admin" ); 11: 12: #Get ADMIN-ID 13: $mech->content() =~ /name=\"ADMIN\" value=\"([^\"]+)/g; 14: $hiddenField = $1; 15: 16: #Fill form 17: $mech->submit_form( 18: form_name => "action", 19: fields => { 20: ADMIN => $hiddenField, 21: username => $username, 22: password => $password}, 23: button => 'login'); 24: 25: #Print site 26: print $mech->content(); 27:
LWP::UserAgent::new: () LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking <<URL>> for cookies LWP::UserAgent::send_request: GET https://mySite/admin LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 242 bytes LWP::UserAgent::request: Simple response: Moved Permanently LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking <<URL>> for cookies LWP::UserAgent::send_request: GET https://mySite/admin LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 4096 bytes LWP::Protocol::collect: read 965 bytes HTTP::Cookies::extract_cookies: Set cookie ADMIN => 829052f0173388362a +649d8fe980081b LWP::UserAgent::request: Simple response: OK LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking <<URL>> for cookies HTTP::Cookies::add_cookie_header: - checking cookie path=/ HTTP::Cookies::add_cookie_header: - checking cookie ADMIN=829052f0173 +388362a649d8fe980081b HTTP::Cookies::add_cookie_header: it's a match HTTP::Cookies::add_cookie_header: Checking <<URL>> for cookies LWP::UserAgent::send_request: POST https://mySite/admin/index.php?acti +on=login LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 238 bytes LWP::Protocol::collect: read 540 bytes LWP::Protocol::collect: read 2348 bytes LWP::Protocol::collect: read 219 bytes LWP::Protocol::collect: read 419 bytes LWP::Protocol::collect: read 160 bytes LWP::Protocol::collect: read 1122 bytes LWP::UserAgent::request: Simple response: OK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Secure login (https + Certificate) using Perl
by Krambambuli (Curate) on Oct 13, 2007 at 15:15 UTC | |
|
Re: Secure login (https + Certificate) using Perl
by Cody Pendant (Prior) on Oct 14, 2007 at 07:21 UTC | |
by Finch (Initiate) on Oct 14, 2007 at 10:35 UTC | |
by Cody Pendant (Prior) on Oct 14, 2007 at 20:27 UTC | |
|
Re: Secure login (https + Certificate) using Perl
by Finch (Initiate) on Oct 13, 2007 at 21:48 UTC |