通用破解网上的图片防盗链源码

这是一个VBScript编写的服务器端脚本,用于防止图片盗链。脚本通过检查请求的URL,模拟XMLHTTP请求获取图片,并根据文件类型设置Content-Type响应头。当URL有效时,返回图片内容;否则返回错误信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936" ENABLESESSIONSTATE="FALSE"%>
<%Option Explicit%>
<%
'+---------------------------------------------------------+
'|        Aocool Studio Photo / Gallery Magic Show         |
'|      Copyright (c) 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
%> 

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值