防盗链
1.Apache开启Rewrite模块
2..htacess文件,把所有图片都转了
RewriteEngine On RewriteCond %{REQUEST_FILENAME} .*\.(jpg|jpeg|gif|png) [NC] RewriteRule .* http://www.zixue.it/static/image/common/zixuelogo.png
3.把来自非localhost的转了
RewriteEngine On RewriteCond %{REQUEST_FILENAME} .*\.(jpg|jpeg|gif|png) [NC] RewriteCond %{HTTP_REFERER} !localhost [NC] RewriteRule .* http://www.zixue.it/static/image/common/zixuelogo.png
如果只是在0618目录下
Rewrite Base /0618
4.伪造Refer就可以拿到防盗链的图片
http://www.zixue.it/static/image/common/zixuelogo.png(自学网logo)
<?php require('./http.class.php'); $http = new Http('http://localhost/http/turn_5.jpg'); $http->setHeader('Referer: http://localhost'); $res = $http->get(); file_put_contents('./ab.jpg',substr(strstr($res,"\r\n\r\n"),4)); ?>
浙公网安备 33010602011771号