vasanthgk91 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to login website using mechanize perl module

That particular website using csrf token.

I am fetching that token and passing parameter to form_token variable.

There is no success. In previous same scenario working ,In that csrf token list websites i can't able to login.

Please help to my code.Last two days i am trying

Below my code is shown

use WWW::Mechanize::GZip; my $mech = WWW::Mechanize::GZip->new( ssl_opts => { SSL_verify_mode => + 'SSL_VERIFY_NONE',verify_hostname => 0 } ); $url = 'https://test.com/signin'; $mech->get($url); my ($csr_input) = $mech->find_all_inputs(name => 'form_token'); my $token = $csr_input->value(); $mech->form_number(1); $mech->field('email',$username); $mech->field('password',$password); $mech->field('signin',''); $mech->field('form_id','signin'); $mech->field('form_token',$token); $mech->field('button_clicked',''); $mech->submit();

Replies are listed 'Best First'.
Re: Auto login using mechanize module in perl ?
by Anonymous Monk on Jun 07, 2018 at 10:31 UTC
    If the form token is already part of the form... Why are you fetching it? Its already part of the form. There is nothing you should be doing about a csrf form token
      Yes i got your point, that token also part of the form. I removed that fetching condition, i added few things ,now working
      $mech->cookie_jar(HTTP::Cookies->new());
      Now logged in properly .. Thank you