Home  >  Article  >  php教程  >  php破解apache,nginx,iis防盗链图片

php破解apache,nginx,iis防盗链图片

WBOY
WBOYOriginal
2016-05-25 16:47:411613browse

现在多数网站都有防盗链一些简单设置了最常用的就是apache,nginx,iis设置了,那么这种设置是不是不可破的呢,答案是否写了,下面我们一起来看破解方法。

有自己的主机一般都会设计"防盗链", 其实包括图片防盗链,和下载防盗链等,如:

使用.htaccess设置防盗链

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?xuexb.com/.*$ [NC]
RewriteRule .(gif|jpg)$ http://www.phprm.com /image.gif [R,L]

nginx设置防盗链

location ~* .(gif|jpg|png|swf|flv)$ {
    valid_referers none blocked phprm.com;
    if ($invalid_referer) {
        rewrite ^/ http://phprm.com /234_s.gif;
        #return 404;
    }
}

但怎么破解防盗链呢? 一般的防盗链是判断来路是否为自己的域名, 我们可以使用 php 内置的 file_get_contents 方法来请求这个图片(当然别的后端语言也有类似的方法), 如: 

//getImg.php?url=目标图片连接

<?php
header(&#39;Content-type: image/jpeg&#39;);
echo file_get_contents(isset($_GET["url"])?$_GET["url"]:&#39;http://xxxx域名 /images/v1/loading-16-16.gif&#39;);
?>

php代码片段看例子:

1, 直接加载防盗链图片: 

破解防盗链图片

 

2, 通过php读取图片:

破解防盗链图片


本文地址:

转载随意,但请附上文章地址:-)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn