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 :
et je l'ai transformé en ça :
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 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
Il me renvoit une erreur 400 :
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 $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 ""; }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Partager