ASP破解图片防盗链系统

将代码保存为pic.asp文件,然后上传到空间之后用浏览器打开“http://……/pic.asp?http://www.baidu.com/img/baidu_sylogo1.gif” 即可看到效果。
程序代码 程序代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936" ENABLESESSIONSTATE="FALSE"%>  
<%Option Explicit%>  
<%  
'+---------------------------------------------------------+  
'| Aocool Studio Photo / Gallery Magic Show |  
'| Copyright © 2005 - 2006 Aocool Studio Ltd. |  
'+---------------------------------------------------------+  
Server.ScriptTimeout = 300  
Response.Buffer = True  

On Error Resume Next  

Function IsNullOrEmpty(ByVal String)  
IsNullOrEmpty = IsNull(String) or String = ""  
End Function  

Function GetImage(ByVal URL)  
Dim oXmlHttp  
Set oXmlHttp = Server.CreateObject("Msxml2.XMLHTTP")  

If Err.Number <> 0 Then  
Response.Write("XMLHTTP Object not installed on this server, please go to Microsoft website download and install it.")  
Response.End()  
End If  

oXmlHttp.Open "GET", URL, False  
oXmlHttp.setRequestHeader "Referer", URL  
oXmlHttp.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"  
oXmlHttp.Send()  
  
If oXmlHttp.readyState <> 4 Then  
GetImage = ""  
Else  
GetImage = oXmlHttp.responseBody  
End If  

Set oXmlHttp = Nothing  
End Function  

Function GetContentType(ByVal FileName)  
Dim FileExtension, ContentType  
FileExtension = Mid(FileName, InStrRev(FileName, ".") + 1)  
  
Select Case FileExtension  
Case "jpe"  
ContentType = "image/jpeg"  
Case "jpg"  
ContentType = "image/jpeg"  
Case "jpeg"  
ContentType = "image/jpeg"  
Case "gif"  
ContentType = "image/gif"  
Case "bmp"  
ContentType = "image/bmp"  
Case "png"  
ContentType = "image/png"  
Case "pnz"  
ContentType = "image/png"  
Case Else  
ContentType = "text/html"  
End Select  

GetContentType = ContentType  
End Function  

Dim URL, Bin  
URL = Request.ServerVariables("QUERY_STRING")  
Bin = GetImage(URL)  

If IsNullOrEmpty(URL) = False Then  
If Bin <> "" Then  
Response.ContentType = GetContentType(URL)  
Response.BinaryWrite Bin  
Response.Flush  
Else  
Response.ContentType = "text/html"  
Response.Write("Remote Server Error.")  
End If  
Else  
Response.ContentType = "text/html"  
Response.Status = "400 Bad Request"  
Response.Write("400 Bad Request")  
End If  
%>  



[本日志由 刚子 于 2011-04-13 04:55 AM 编辑]
文章来自:
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
t