tencent-模拟请求头

1 篇文章 0 订阅
1 篇文章 0 订阅

最近...不多说,说多了都是泪,直接上问题和答案:

不使用 CURL 函数分别写出 client.php server.php 两个文件内容 .
client.php模拟浏览器客户端向 server.php 发送如下 HTTP数据包 .
server.php向 client.php 输出 md5(username+password) 后的结果
POST http://localhost/server.php HTTP/1.1
Accept: image/jpeg, image/gif, image/pjpeg, */*
User-Agent: Mozilla/4.0
Content-Type: application/x-www-form-urlencoded
Host: localhost
Content-Length: 34
Connection: Keep-Alive
Cookie: HOSUPPORT=1; UBI=fi_Pnc;
username=a&password=c&action=login

//假设host:localhost
//Client.php文件内容为:
$url = "http://localhost/server.php";
$fp = fsockopen ( "localhost", 80, $errno, $errstr, 3 );
$head = "POST /server.php HTTP/1.0\r\n";
$head .= "Accept: image/jpeg, image/gif, image/pjpeg, */*\r\n";
$head .= "User-Agent: Mozilla/4.0\r\n";
$head .= "Content-type: application/x-www-form-urlencoded\r\n";
$head .= "Host: localhost\r\n";
$head .= "Content-Length: 34\r\n";
$head .= "Connection: Keep-Alive\r\n";
$head .= "Cookie: HOSUPPORT=1; UBI=fi_Pnc;\r\n";
$head .= "\r\n";
 
$head .= trim ( "username=a&password=c&action=login" );
$write = fputs ( $fp, $head );
fgets ( $fp );
while ( ! feof ( $fp ) ) {
$line = fgets ( $fp );
echo $line . "<br>";
}
 
//Server.php内容为:
echo md5($_POST['username'].$_POST['password']);












 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值