Bonjours je voudrais a partir d'un programme perl enregistrer un utilisateur j'utilise donc une socket avec la méthode POST mais cela ne marche pas :s:s.
voila mon code perl :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!usr/bin/perl
use IO::socket;
use strict;
use warnings;
print q(
<><><><><><><><><><><><><><><><><><><><><><><><><>
 
  --> Prog perl , pour enregistrer facilement admin et user
  
<><><><><><><><><><><><><><><><><><><><><><><><><>
);
print"\nSite sans http://";
chomp(my $host=<STDIN>);
print"Chemin (ex:/):";
chomp(my $path=<STDIN>);
print"Login:";
chomp(my $login=<STDIN>);
print"Password:";
chomp(my $pass=<STDIN>);
chomp(my $pass2= $pass);
print"Nom:";
chomp(my $nom=<STDIN>);
print"Prenom:";
chomp(my $prenom=<STDIN>);
chomp(my $privilege="admin");
if($host ne "" and $path ne "" and $login ne "" and  $pass ne "" and $nom ne "" and $prenom ne "")
{
print "[+]Connection en cours...\n";sleep(1);
my $sock = new IO::Socket::INET ( 
                                 PeerAddr => "$host", 
                                 PeerPort => "80", 
 
                                 Proto => "tcp", 
                                ) or die"[+]Connection impossible...\n";
print "[+]Connecter au server\n";
print "[+]Ajout de l'admin...\n";sleep(1);
my $data   = "login=$login&pass=$pass&pass2=$pass2&nom=$nom&prenom=prenom&privilege=$privilege";
my $length = length $data;
my $url="$path"."enregistre.php";
print $sock "POST $url HTTP/1.1
Host: $host
Content-Type: application/x-www-form-urlencoded
Content-Length: $length
$data";
print"[+]Login : $login\n[+]Password : $pass\n";
 
}
voila le formulaire html :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
28
29
30
31
32
33
34
35
36
37
38
<form action="enregistre.php" method="post" name="add">
            </p>
  <p align="center"><strong><u>Cr&eacute;er un utilisateur</u></strong></p>
 
  <table width="350" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#eeeeee" class="tableaux">
    <tr>
      <td width="40">Login</td>
      <td width="144"><input name="login" type="text" id="login"></td>
    </tr>
    <tr>
      <td>Mot de passe </td>
      <td><input name="pass" type="password" id="pass"></td>
 
    </tr>
    <tr>
      <td>R&eacute;p&eacute;ter mot de passe </td>
      <td><input name="pass2" type="password" id="pass2"></td>
    </tr>
    <tr>
      <td>NOM</td>
 
      <td><input name="nom" type="text" id="nom"></td>
    </tr>
    <tr>
      <td>Pr&eacute;nom</td>
      <td><input name="prenom" type="text" id="prenom"></td>
    </tr>
    <tr>
      <td>Privil&egrave;ge</td>
 
      <td><select name="privilege" id="privilege">
          <option value="user">Utilisateur</option>
          <option value="admin">Administrateur</option>
        </select></td>
    </tr>
    <tr>
      <td height="50" colspan="2"><div align="center">
          <input type="submit" name="Submit" value="Cr&eacute;er cet utilisateur">