时间:2021-07-01 10:21:17 帮助过:23人阅读
[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>';
相关阅读;
php CURL获取cookies模拟登录的方法代码实例
php curl错误排查的方法详解
PHP curl模拟登录带验证码的网站
以上就是PHP之curl伪装来源信息的详细内容,更多请关注Gxl网其它相关文章!