authentification web https
Salut et merci d'avance pour vos reponses
je desirerais automatiser mes connexions sur le site "genybet".
j'ai recupe le formulaire de login suivant:
Code:
1 2 3 4 5 6
| <!-- panel de connexion -->
<form id="formLogin" name="formLogin" method="post" action="/faces/index.html;jsessionid=8ead2248e378619a8d5d740e59bb" enctype="application/x-www-form-urlencoded" onkeypress="submitFormLogin(event);"><input type="hidden" name="formLogin" value="formLogin" /> <!-- entete --><table id="login-hdr"><tbody><tr><td>Espace client</td><td>>> <script type="text/javascript" language="Javascript">//<![CDATA[
function dpf(f) {var adp = f.adp;if (adp != null) {for (var i = 0;i < adp.length;i++) {f.removeChild(adp[i]);}}};function apf(f, pvp) {var adp = new Array();f.adp = adp;var i = 0;for (k in pvp) {var p = document.createElement("input");p.type = "hidden";p.name = k;p.value = pvp[k];f.appendChild(p);adp[i++] = p;}};function jsfcljs(f, pvp, t) {apf(f, pvp);var ft = f.target;if (t) {f.target = t;}f.submit();f.target = ft;dpf(f);};
//]]>
</script> <a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('formLogin'),{'j_id19':'j_id19'},'');}return false">Mot de passe oublié ?</a></td></tr></tbody></table><!-- messages d'erreur -->
<!-- formulaire de connexion --><table id="login-pnl"><tbody><tr><td>Email :</td><td><input id="j_username" type="text" name="j_username" size="23" style="width:133px;" tabindex="1" /></td></tr><tr><td>Mot de passe :</td><td><input id="j_password" type="password" name="j_password" value="" size="23" style="width:133px;" tabindex="2" /></td></tr><tr><td>Date de naissance :</td><td><input id="j_day" type="text" name="j_day" maxlength="2" onkeyup="autoFocus('formLogin',this,3)" size="2" tabindex="3" /><input id="j_month" type="text" name="j_month" maxlength="2" onkeyup="autoFocus('formLogin',this,4)" size="2" tabindex="4" /><input id="j_year" type="text" name="j_year" maxlength="4" size="4" tabindex="5" /></td></tr></tbody></table><!-- footer --><table id="login-footer"><tbody><tr><td><a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('formLogin'),{'j_id33':'j_id33'},'');}return false"><img id="newCompte" src="/img/login/ouvrir.png;jsessionid=8ead2248e378619a8d5d740e59bb" /></a></td><td><a id="submitLogin" href="#" type="submit" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('formLogin'),{'submitLogin':'submitLogin'},'');}return false"><img src="/img/login/ok.png;jsessionid=8ead2248e378619a8d5d740e59bb" /></a></td></tr></tbody></table><!-- captcha --><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id1" autocomplete="off" /></form></div> <span id="j_id44"><div id="nextRacesContainer"></div></span></div><div id="menu"><script type="text/javascript"> |
Pour utiliser perl et le https j'ai lu qu'il etait necessaire d'installer Crypt-SSLeay.
Pour me connecte je me suis servit du code suivant mais ma connexion ne s'effectue pas.
Pouvez vous me dire ce qu'il manque?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| use strict;
use warnings;
use DateTime;
use LWP::Simple;
use WWW::Mechanize;
$bot = WWW::Mechanize->new(
#agent => 'Mozilla/4.73 [en] (X11; I; Linux 2.2.16 i686; Nav)',
autocheck => 1,
cookie_jar => HTTP::Cookies->new(
# file => "$ENV{HOME}/.mailmanrc",
autosave => 1,
ignore_discard => 1, # le cookie devrait être effacé à la fin
)
);
$bot->get($base) or die $bot->res->status_line if not $bot->success;
if ( $bot->current_form->find_input('j_username') ) {
warn "Rechargement d'identification utilisateur\n";
print "### Authentification necessaire ###\n";
$bot->set_fields( j_username => $compte); #
$bot->set_fields( j_password => $pass );
$bot->set_fields( j_day => 'XX' ); #
$bot->set_fields( j_month => 'XX' );
$bot->set_fields( j_year => 'XXXX' );
$bot->submit();
} |