ASP,PHP与.NET伪造HTTP-REFERER方法及防止伪造REFERER的方法
来源:asp之家 时间:2010-03-12 12:40:00
HTTP-REFERER这个变量已经越来越不可靠了,完全就是可以伪造出来的东东。
以下是伪造方法:
ASP/Visual Basic代码
dim http
set http=server.createobject("MSXML2.XMLHTTP") '//MSXML2.serverXMLHTTP也可以
Http.open "GET",url,false
Http.setRequestHeader "Referer","https://www.aspxhome.com/"
Http.send()
PHP(前提是装了curl):
PHP代码
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "https://www.aspxhome.com/xxx.asp");
curl_setopt ($ch, CURLOPT_REFERER, "https://www.aspxhome.com/");
curl_exec ($ch);
curl_close ($ch);
PHP(不装curl用sock)
PHP代码
$server = 'www.aspxhome.com';
$host = 'www.aspxhome.com';
$target = '/xxx.asp';
$referer = 'https://www.aspxhome.com/'; // Referer
$port = 80;
$fp = fsockopen($server, $port, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br />\n";
}
else
{
$out = "GET $target HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Cookie: ASPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n";
$out .= "Referer: $referer\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp))
{
echo fgets($fp, 128);
}
fclose($fp);
}
VB.NET/C#.NET
C#代码
Dim oXMLHttp As MSXML2.XMLHTTP30 = New MSXML2.XMLHTTP30()
或者
MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30();
oXMLHttp.open(....
oXMLHttp.setRequestHeader(...
oXMLHttp.send(..
原理都是sock构造http头来senddata。其他语言什么的比如perl也可以, 目前比较简单的防御伪造referer的方法是用验证码(Session)。
现在有一些能防盗链软件的商业公司比如UUDOG,linkgate,VirtualWall什么的,都是开发的应用于IIS上面的dll。
有的是采用cookies验证、线程控制,有的是能随机生成文件名然后做URL重写。有的方法能的确达到不错的效果. 不过道高一尺,魔高一丈,这些雕虫小技终归是有破解方法的。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用Gitee自动化部署python脚本的详细过程
![](https://img.aspxhome.com/file/2023/1/86321_0s.jpg)
微信小程序开发之实现心情记事本
![](https://img.aspxhome.com/file/2023/0/136280_0s.jpg)
Ceph分布式存储集群Pool资源池简介及使用小结
python计算auc指标实例
Python中的sys.stdout.write实现打印刷新功能
![](https://img.aspxhome.com/file/2023/6/133866_0s.gif)
Oracle数据库快照的使用
小议javascript设计模式
ExtJS判断IE浏览器类型的方法
vue 图片裁剪上传组件的实现
![](https://img.aspxhome.com/file/2023/4/126544_0s.gif)
python中使用iterrows()对dataframe进行遍历的实例
![](https://img.aspxhome.com/file/2023/0/77790_0s.jpg)
python实现图片文件批量重命名
![](https://img.aspxhome.com/file/2023/5/62265_0s.jpg)
python实现决策树
distinct 多列问题结合group by的解决方法
Python实现http接口自动化测试的示例代码
![](https://img.aspxhome.com/file/2023/6/110586_0s.png)
Python实现的拟合二元一次函数功能示例【基于scipy模块】
![](https://img.aspxhome.com/file/2023/3/128323_0s.png)
Python字符串类型及格式化问题
看看如何用Python绘制小米新版天价logo
![](https://img.aspxhome.com/file/2023/8/133238_0s.jpg)