防盗链接ASP函数
来源:asp之家 时间:2011-03-07 11:02:00
简单介绍下功能吧:使用了ASP的一个对象ServerVariables(服务器环境变量),通过这个环境变量可以获取到真正的下载地址再通过一些简单的VBS内置函数破坏其真正地址的完整性。达到欺骗下载软件的功能。现附上源码提供大家学习。
代码如下:
<% FunctIon DownloadFIle(StrFIle)
StrFIlename=StrFIle
Response.Buffer=True
Response.Clear
Set S=Server.CreateObJect("ADODB.Stream")
S.Open
S.Type=1
on Error Resume Next
Set Fso=Server.CreateObJect("ScrIptIng.FIleSystemObJect")
If Not Fso.FIleExists(StrFIleName) Then
From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER"))
Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME"))
If MId(From_Url,8,len(Serv_Url)) <> Serv_Url Then
Response.WrIte "该文件不存在或者已经删除."
Response.End
End If
Response.RedIrect Request.ServerVarIables("HTTP_REFERER")
Response.End
End If
FileExt=MId(StrFIlename,InStrRev(StrFIleName, ".")+1)
Select Case UCase(FIleExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB", "PHP", "JSP", "SHTML", "HTML", "HTM", "TV", "DATA"
From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER"))
Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME"))
If MId(From_Url,8,len(Serv_Url)) <> Serv_Url Then
Response.WrIte "该文件不存在或者已经删除."
Response.End
End If
Response.RedIrect Request.ServerVarIables("HTTP_REFERER")
Response.End
End Select
Set F=Fso.GetFIle(StrFIlename)
IntFIlelength=F.SIze
s.LoadFromFIle(StrFIlename)
If Err Then
From_Url=Cstr(Request.ServerVarIables("HTTP_REFERER"))
Serv_Url=Cstr(Request.ServerVarIables("SERVER_NAME"))
If MId(From_Url,8,len(Serv_Url)) <> Serv_Url Then
Response.WrIte "该文件数据不完整或许已损坏."
Response.End
End If
Response.RedIrect Request.ServerVarIables("HTTP_REFERER")
Response.End
End If
Set Upload=Server.CreateObJect("PersIts.Upload")
If Upload Is Nothing Then
Response.AddHeader "Content-DIsposItIon","attachment; FIlename="&F.Name
Response.AddHeader "Content-Length",IntFilelength
Response.CharSet="UTF-8"
Response.ContentType="application/x-download"
Response.BinaryWrite S.Read
Response.Flush
S.Close
Set s=NothIng
Else
Upload.SendBinary StrFIlename,True,"application/x-download",False
End If
End FunctIon
%>
使用:
<%Call DownloadFIle("DownloadFIle")%>
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
OverFlow – 一个秘密武器
![](https://img.aspxhome.com/file/UploadPic/20109/25/rss1-42s.png)
Asp无组件生成缩略图
SQL Server 2000数据库FOR XML查询概述
MySQL 数值类型概述int smallint tinyint
使用ASP调用C#写的COM组件
思考如何提高交互设计水平?
ASP在线生成电话图片程序
![](https://img.aspxhome.com/file/UploadPic/200710/6/200710623165632s.gif)
什么是Semantics?
设计输入了些什么?
ASP实例:幻灯片新闻代码
让JavaScript拯救HTML5的离线存储[译]
![](https://img.aspxhome.com/file/UploadPic/20095/15/01-33s.jpg)
在SQL Server计算机上运行病毒扫描软件
mysql 主从服务器的简单配置
asp #include file 与 #include virtual 的区别小结第1/2页
asp读取数据库中数据到数组的类
Oracle 数据库操作类
验证码-挑战你的智慧
![](https://img.aspxhome.com/file/UploadPic/20089/10/2008910131428605s.jpg)