注册 登录
编程论坛 ASP技术论坛

图片防盗链问题。

lele2007 发布于 2011-04-10 21:33, 927 次点击
QQ空间的图片做了防盗链。。
在自己站点里链接QQ头像:<img src="http://qlogo1.store.会显示QQ防盗链的提示。。

<img src="http://www. 但是这个可以显示。。一些QQ空间相关的网站也能盗链图片。。

pic.asp  里面的是怎么实现解开防盗链的?
asp怎样解开防盗链呢?
5 回复
#2
gupiao1752011-04-11 02:44
估计要变相用二进制,请求方式用二进制,显示也用二进制,最后再返回图片!而不是简单的显示!

可以这样比如知道某个图片地址后,url="http://图片的URL",xmlhttp.open(url,"get",false),XMLHTTP请求图片地址。返回response.body这应该是二进制的。然后通过ado.stream转换二进制为图片,并进行编码处理!具体我也没有操作过,但是思路应该是这样,变同方式,越简单可行就越好!甚至可以直接通过response.binarywrite response.body ,然后头部用content-type:image/jpg,直接显示图片。
#3
lele20072011-04-11 10:06
程序代码:
<%

 response.ContentType
="image/jpeg"

 
dim xmlhttp,url

 url
= "http://qlogo1.store."                                       '获取速度慢
'
url = "http://www.'速度快。
set xmlhttp = server.CreateObject("Microsoft.XMLHTTP")

 xmlhttp.open
"get",url,false

 xmlhttp.send

 response.BinaryWrite xmlhttp.responseBody
%>
我用这段测试。。
执行到open里时,获取数据很慢。。
还有其它方法吗?^_^..
#4
dzt00012011-04-11 14:39
给你一个QQ防盗链破解代码吧

下面的代码保存成tu.asp,QQ的可以,其他像百度空间的不行,可能防盗链措施不一样吧

用的时候<img src="tu.asp?url=http://qlogo1.store.

 
程序代码:
<%
Dim url, body, myCache

url
= Request.QueryString("url")

Set myCache = new cache
myCache.name
= "picindex"&url
If myCache.valid Then
body
= myCache.value
Else
body
= GetWebData(url)
myCache.add body,
dateadd("d",1,now)
End If

If Err.Number = 0 Then
Response.CharSet
= "UTF-8"
Response.ContentType
= "application/octet-stream"
Response.BinaryWrite body
Response.Flush
Else
Wscript.Echo Err.Description
End if

'取得数据
Public Function GetWebData(ByVal strUrl)
Dim curlpath
curlpath
= Mid(strUrl,1,Instr(8,strUrl,"/"))
Dim Retri
Set Retri = Server.CreateObject("Microsoft.XMLHTTP")
With Retri
.Open
"Get", strUrl, False,"",""
.setRequestHeader
"Referer", curlpath
.Send
GetWebData
=.ResponseBody
End With
Set Retri = Nothing
End Function


'cache类

class Cache
private obj 'cache内容
private expireTime '过期时间
private expireTimeName '过期时间application名
private cacheName 'cache内容application名
private path 'url

private sub class_initialize()
path
=request.servervariables("url")
path
=left(path,instrRev(path,"/"))
end sub

private sub class_terminate()
end sub

public property get blEmpty
'是否为空
if isempty(obj) then
blEmpty
=true
else
blEmpty
=false
end if
end property

public property get valid
'是否可用(过期)
if isempty(obj) or not isDate(expireTime) then
valid
=false
elseif CDate(expireTime)<now then
valid
=false
else
valid
=true
end if
end property

public property let name(str)
'设置cache名
cacheName=str & path
obj
=application(cacheName)
expireTimeName
=str & "expires" & path
expireTime
=application(expireTimeName)
end property

public property let expires(tm)
'重设置过期时间
expireTime=tm
application.lock
application(expireTimeName)
=expireTime
application.unlock
end property

public sub add(var,expire)
'赋值
if isempty(var) or not isDate(expire) then
exit sub
end if
obj
=var
expireTime
=expire
application.lock
application(cacheName)
=obj
application(expireTimeName)
=expireTime
application.unlock
end sub

public property get value
'取值
if isempty(obj) or not isDate(expireTime) then
value
=null
elseif CDate(expireTime)<now then
value
=null
else
value
=obj
end if
end property

public sub makeEmpty()
'释放application
application.lock
application(cacheName)
=empty
application(expireTimeName)
=empty
application.unlock
obj
=empty
expireTime
=empty
end sub

public function equal(var2)
'比较
if typename(obj)<>typename(var2) then
equal
=false
elseif typename(obj)="Object" then
if obj is var2 then
equal
=true
else
equal
=false
end if
elseif typename(obj)="Variant()" then
if join(obj,"^")=join(var2,"^") then
equal
=true
else
equal
=false
end if
else
if obj=var2 then
equal
=true
else
equal
=false
end if
end if
end function
end class
%>
#5
lele20072011-04-11 15:48
呃。。可以了!

可是第一次没有缓存的时要好长时间下载图片。

<img src="http://www.  
它的效果比较好快。有方法加快速度吗?
#6
lrznet2011-04-11 19:41
我也想知道。。。
1