I'm trying to login into the web configuration panel of a device (for the test I'm using my router) and create backup. The module is WWW::Scripter. The page is using JavaScript. I think that I'm not passing the parameters properly because it returns error :
No such field 'userName' at /home/angel/perl5/lib/perl5/WWW/Mechanize.pm line 750.
JS function on the web page:
function CheckUserPswInvalid()
{
var userName = $("userName");
var pcPassword = $("pcPassword");
if(!CheckUserPswChars(userName.value))
{
userName.select();
userName.focus();
return false;
}
if(!CheckUserPswChars(pcPassword.value))
{
pcPassword.select();
pcPassword.focus();
return false;
}
return true;
}
My code:
use WWW::Scripter;
use HTTP::Cookies;
my $url = 'http://192.168.0.1/';
my $username = 'username';
my $pass = 'password';
my $agent = new WWW::Scripter;
$agent->use_plugin('JavaScript');
$agent->get('http://192.168.0.1/');
$agent->cookie_jar(HTTP::Cookies->new);
$agent->form_name("loginForm");
$agent->field('userName' => $username);
$agent->field("pcPassword" => $pass);
$agent->submit();
Aucun commentaire:
Enregistrer un commentaire