Précédent   Forum des professionnels en informatique > PHP > Langage > Fichiers
Fichiers Forum d'entraide sur les fichiers avec PHP. Avant de poster -> FAQ fichiers et Sources fichiers
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 29/02/2008, 15h11   #1
Membre du Club
 
Inscription : décembre 2005
Messages : 152
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 152
Points : 66
Points : 66
Par défaut Valider formulaire web avec fsockopen

Bonjour,

Je souhaite valider un formulaire web via la fonction fsockopen (pour faire passer le mot de passe avec la requete au lieu que ce soit l'utilisateur qui le fasse à chaque fois).

J'ai donc fait la manip "normalement" en tapant le mot de passe, pour récupérer la requete avec wireshark :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
POST /admin/npvr_schedule_recs.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, */*
Referer: http://10.0.1.100/admin/npvr_schedule_recs.php
Accept-Language: fr
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)
Host: 10.0.1.100
Content-Length: 343
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: PHPSESSID=6e2c3d719690cb07a296ef4b50e0daac
Authorization: Basic YWRtaW46cGFyaXM=
path_mode=list&disk_path=disk3&name=1_1_29022008_180000&multicast=1&dest_ip=225.7.90.23&dest_port=1234&start_year=2008&start_month=02&start_day=29&start_hour=18&start_minute=00&start_second=00&end_year=2008&end_month=02&end_day=29&end_hour=20&end_minute=00&end_second=00&each=&request=schedule&button_schedule_rec.x=11&button_schedule_rec.y=13
et je l'ai transformé en ça :
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
28
29
30
31
32
33
34
35
$data = "POST /admin/npvr_schedule_recs.php HTTP/1.1\r\n
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, */*\r\n
Referer: http://10.0.1.100/admin/npvr_schedule_recs.php\r\n
Accept-Language: fr\r\n
Content-Type: application/x-www-form-urlencoded\r\n
UA-CPU: x86\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)\r\n
Host: 10.0.1.100\r\n
Content-Length: 343\r\n
Connection: Keep-Alive\r\n
Cache-Control: no-cache\r\n
Cookie: PHPSESSID=6e2c3d719690cb07a296ef4b50e0daac\r\n
Authorization: Basic YWRtaW46cGFyaXM=\r\n
path_mode=list&disk_path=disk3&name=1_1_29022008_180000&multicast=1&dest_ip=225.7.90.23&dest_port=1234&start_year=2008&start_month=02&start_day=29&start_hour=18&start_minute=00&start_second=00&end_year=2008&end_month=02&end_day=29&end_hour=20&end_minute=00&end_second=00&each=&request=schedule&button_schedule_rec.x=11&button_schedule_rec.y=13\r\n
\r\n \r\n
";
 
$result = request("10.0.1.100", 80, $data);
print_r($result);
 
function request($ip, $port, $data){
	$result = "";
	$fp = fsockopen($ip, $port, $errno, $errstr, 30);
	if ($fp) {
		fwrite($fp, $data);
		stream_set_timeout($fp, 15);
		$result = fread($fp, 2000);
		$info = stream_get_meta_data($fp);
		fclose($fp);
		if ($info['timed_out']) $result = "Time Out";
		return $result;
	}
	else return "";
}
Il me renvoit une erreur 400 :
Code :
1
2
3
4
5
6
HTTP/1.1 400 Bad Request Date: Fri, 29 Feb 2008 15:04:08 GMT Server: Apache Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 143 
Bad Request
Your browser sent a request that this server could not understand.
client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /admin/npvr_schedule_recs.php
 
0

Quelqu'un voit où est l'erreur?
Quelqu'un a une autre méthode ? Je cherche a envoyer des variables post sur le serveur, sachant que je connais le mot de passe bien sur.

Merci d'avance
madislak est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/03/2008, 00h30   #2
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 835
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 835
Points : 3 468
Points : 3 468
Citation:
Envoyé par madislak Voir le message
Code :
1
2
3
4
5
$data = "POST /admin/npvr_schedule_recs.php HTTP/1.1\r\n
Accept: image/gif, image/x-xbitmap, ...\r\n
Referer: http://10.0.1.100/admin/npvr_schedule_recs.php\r\n
Accept-Language: fr\r\n
...
Donc là concrètement tu envoies ceci au serveur :

Code :
1
2
3
4
5
6
7
8
9
POST /admin/npvr_schedule_recs.php HTTP/1.1
 
Accept: image/gif, image/x-xbitmap, ...
 
Referer: http://10.0.1.100/admin/npvr_schedule_recs.php
 
Accept-Language: fr
 
...
La requête est mal formée.
Bref, construis ta requête de la sorte :

Code :
1
2
3
4
5
$post = "POST ...\r\n"
      . "Accept: image/gif, ...\r\n"
      . "Referer: http://10.0...\r\n"
      . "... \r\n"
      . "\r\n" ;
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h24.


 
 
 
 
Partenaires

Hébergement Web