[one.php]
<?php
$post_data = array (
"user" => "admin",
"pwd" => "123456"
);
$header_ip = array(
'CLIENT-IP:8.8.8.8',
'X-FORWARDED-FOR:8.8.8.8',
);
$referer='http://www.liangshao.com';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://localhost/curl/two.PHP');
//伪造来源referer
curl_setopt ($ch,CURLOPT_REFERER,$referer);
//伪造来源ip
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_ip);
//提交post传参
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//加上这个表示执行curl_exec是把输出做为返回值,不会输出到浏览器
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$out_put=curl_exec ($ch);
curl_close ($ch);
echo $out_put;
[two.php]
<?php
//请求来源referer
echo '[HTTP_REFERER]<br>';
echo $_SERVER['HTTP_REFERER'];
//请求来源ip
//[注]此处的IP打印顺序是目前很多开源系统的IP获取顺序
echo '<hr>[IP]<br>';
echo $_SERVER['HTTP_CLIENT_IP'];
echo '<br>';
echo $_SERVER['HTTP_X_FORWARDED_FOR'];
echo '<br>';
echo $_SERVER['REMOTE_ADDR'];
//POST数据
echo '<hr>[POST]<br><pre>';
var_dump($_POST);
echo '</pre>';
热门评论
跑起来页面一直加载。。。