Folks, I need help with WWW::Mechanize to automate a login to a page that uses Duo-Authentication.
I am able to load the credentials and login but I need to silently pass the second check using the information that is saved in the cookies by the browser (Chrome or any other browser if necessary).
Once this is achieved I should be able to things I was able to do before the implementation of the Duo-Authentication.
This call
$cookie_jar->load($cookie_file);
returns this warning: "Decrypted cookies is not set up at..."
Here is what I have so far.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use WWW::Mechanize;
use HTTP::Cookies::Chrome;
my $username = '**********';
my $passwd = '*********';
my $cookie_file = 'C:/Users/username/AppData/Local/Google/Chrome/User
+Data/Default/Cookies'; #chrome cookies path on windows
my $cookie_jar = HTTP::Cookies::Chrome->new(
# chrome_safe_storage_password => '***", # I don't know what t
+o do here
file => $cookie_file,
# autosave => 1,
# ignore_discard => 0,
);
$cookie_jar->load($cookie_file);
my $mech = WWW::Mechanize->new(
cookie_jar => $cookie_jar,
);
#$mech->cookie_jar->scan(sub { print Dumper \@_ });
#print $cookie_jar->as_string;
my $uri = URI->new( "https://www.*****.com" );
$mech->get( $uri );
unless ($mech->success)
{
my $mesg = $mech->response->status_line;
print $mesg;
goto END;
}
$mech->set_fields(
username => $username,
password => $passwd,
);
$mech -> submit();
sleep(2);
$mech->success() or die "Can't fetch the Requested page";
my @form = ( "formname" );
$mech->form_with_fields( @form );
my $value ='******';
eval {$mech->select('fieldName', $value)};
if ($@ and $@ =~ /Illegal value/)
{
print "This page has not been loaded...";
goto END;
}
END :
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|