php fsockopen伪造post与get方法的详解

yipeiwu_com6年前PHP代码库
fsockopen 伪造 post和get方法哦,如果你正在找 伪造 post和get方法的php处理代码这款不错哦。
复制代码 代码如下:

<?php
//fsocket模拟post提交
$purl = "http://localhost/netphp/test2.php?uu=rrrrrrrrrrrr";
print_r(parse_url($url));
sock_post($purl,"uu=55555555555555555");
//fsocket模拟get提交
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.0rn";
   $head .= "Host: ".$info['host']."rn";
   $head .= "rn";
   $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.0rn";
   $head .= "Host: ".$info['host']."rn";
   $head .= "Referer: http://".$info['host'].$info['path']."rn";
   $head .= "Content-type: application/x-www-form-urlencodedrn";
   $head .= "Content-Length: ".strlen(trim($query))."rn";
   $head .= "rn";
   $head .= trim($query);
   $write = fputs($fp, $head);
   while (!feof($fp))
   {
    $line = fread($fp,4096);
    echo $line;
   }
}
?>

相关文章

php基于curl重写file_get_contents函数实例

本文实例讲述了php基于curl重写file_get_contents函数。分享给大家供大家参考,具体如下: file_get_contents在连接不上的时候会提示Connection...

$_GET['goods_id']+0 的使用详解

目的: 为了防止sql注入,tid,goods_id都是正整数类型,防止人为了在后面追加 ?tid=1 or 1 这样的语句.原理: 不管你的参数多么险恶,+0后都老老实实变成数值类型...

PHP实现一维数组转二维数组的方法

本文实例讲述了PHP实现一维数组转二维数组的方法。分享给大家供大家参考。具体实现方法如下: <?php $asr[1] = array("a","b","c","d"...

PHP使用pdo实现事务处理操作示例

本文实例讲述了PHP使用pdo实现事务处理操作。分享给大家供大家参考,具体如下: 使用事务的好处: 举个例子:银行用户A向用户B转账100元,这个操作被分为两个步骤: (1)A的账户余额...

php 生成短网址原理及代码

php 生成短网址 原理: 1.将原网址做crc32校验,得到校验码。 2.使用sprintf('%u') 将校验码转为无符号数字。 3.对无符号数字进行求余62操作(大小写字母+数字等...