如何使用cURL& PHP欺骗referrer? [英] How do I use cURL & PHP to spoof the referrer?

查看:656
本文介绍了如何使用cURL& PHP欺骗referrer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用PHP学习cURL来欺骗网站的引荐来源。



使用以下脚本我希望完成这个...但似乎



任何想法/建议我在哪里出错?





杰西卡


$ b b

 <?php 
$ host =http://mysite.com;
$ ch = curl_init();
curl_setopt($ ch,CURLOPT_URL,$ host);
curl_setopt($ ch,CURLOPT_VERBOSE,1);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ ch,CURLOPT_AUTOREFERER,false);
curl_setopt($ ch,CURLOPT_REFERER,http://google.com);
curl_setopt($ ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
curl_setopt($ ch,CURLOPT_HEADER,0);
$ result = curl_exec($ ch);
curl_close($ ch);
?>


解决方案

您不能在webserver的分析中看到结果因为它可能使用javascript来获取分析和curl不运行/执行javascript。所有Curl将做的是获取页面的内容,因为它喜欢它是一个文本文件。它不运行任何脚本或任何东西。



要更清楚如果您有一个html标签,例如

  < img src =path / to / image / image.jpg/> 

curl将其视为一行文本。它不会从服务器加载image.jpg。如果它们是一个

 < script type =text / javascriptsrc =analytics.js >< / script> 

通常浏览器会加载analytics.js并运行它,但curl wont。


I'm trying to learn cURL with PHP to spoof the referrer to a website.

With the following script I expected to accomplish this...but it seems to not work.

Any ideas/suggestion where I am going wrong??

Or do you know of any tutorials that could help me figure this out?

Thanks!

Jessica

<?php
$host = "http://mysite.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, false);
curl_setopt($ch, CURLOPT_REFERER, "http://google.com");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
?>

解决方案

You wont be able to see the result in webserver's analytics because it might probably using a javascript to get the analytics and curl wont run/execute the javascript. All Curl will do is get the content of the page as it like it is a text file. It wont run any of the scripts or anything.

To be more clear if you have an html tag like

<img src="path/to/image/image.jpg" />

The curl will treat it as a line of text. it wont load the image.jpg from the server. The same goes with the js if their is a

<script type="text/javascript" src="analytics.js"></script>

Normally the browser will load that analytics.js and run it, but the curl wont.

这篇关于如何使用cURL&amp; PHP欺骗referrer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆