php fsockopen 伪造 post和get方法 |
时间:2015-01-23 来源:西部数据 作者:西部数据 |
|
- <?php
-
- $purl = "http://localhost/netphp/test2.php?uu=rrrrrrrrrrrr";
- print_r(parse_url($url));
- sock_post($purl,"uu=55555555555555555");
-
-
- function sock_get($url, $query)
- {
- $info = parse_url($url);
- $fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
- $head = "GET ".$info['path']."?".$info["query"]." HTTP/1.0 ";
- $head .= "Host: ".$info['host']." ";
- $head .= " ";
- $write = fputs($fp, $head);
- while (!feof($fp))
- {
- $line = fread($fp,4096);
- echo $line;
- }
- }
- sock_post($purl,"uu=rrrrrrrrrrrrrrrr");
-
- function sock_post($url, $query)
- {
- $info = parse_url($url);
- $fp = fsockopen($info["host"], 80, $errno, $errstr, 3);
- $head = "POST ".$info['path']."?".$info["query"]." HTTP/1.0 ";
- $head .= "Host: ".$info['host']." ";
- $head .= "Referer: http://".$info['host'].$info['path']." ";
- $head .= "Content-type: application/x-www-form-urlencoded ";
- $head .= "Content-Length: ".strlen(trim($query))." ";
- $head .= " ";
- $head .= trim($query);
- $write = fputs($fp, $head);
- while (!feof($fp))
- {
- $line = fread($fp,4096);
- echo $line;
- }
- }
-
- ?>
|
|
|
|