Home > Backend Development > PHP Tutorial > A simple method to use PHP to crack anti-hotlink images_PHP Tutorial

A simple method to use PHP to crack anti-hotlink images_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:28:51
Original
938 people have browsed it

Having your own host will generally design "anti-hotlinking", which actually includes anti-hotlinking for pictures, anti-hotlinking for downloads, etc., such as:
1. Use .htaccess to set anti-hotlinking

Copy code The code is as follows:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.) ?jb51.net/.*$ [NC]
RewriteRule .(gif|jpg)$ http://www.jb51.net/image.gif [R,L]

2.nginx settings Anti-hotlink
Copy code The code is as follows:
location ~* .(gif|jpg|png|swf|flv)$ {
valid_referers none blocked jb51.net;
if ($invalid_referer) {
rewrite ^/ http://jb51.net/234_s.gif;
#return 404;
}
}

But how to crack anti-hotlinking? Generally, anti-hotlinking is to determine whether the source is your own domain name. We can use PHP’s built-in file_get_contents method to request this image (of course other back-end languages ​​also have similar methods) ), such as:
Copy code The code is as follows:
//getImg.php?url=Target image connection
header('Content-type: image/jpeg');
echo file_get_contents(isset($_GET["url"])?$_GET["url"]:'http://static.jb51 .net/images/v1/loading-16-16.gif');
?>

See example:

1, Directly load anti-hotlinking pictures: (Unauthorized pictures on this site are displayed blank)
A simple method to use PHP to crack anti-hotlink images_PHP Tutorial

2, read pictures through php:
A simple method to use PHP to crack anti-hotlink images_PHP Tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/780483.htmlTechArticleHaving your own host will generally design "anti-hotlinking", which actually includes anti-hotlinking for pictures, anti-hotlinking for downloads, etc. For example: 1. Use .htaccess to set up anti-hotlink copy code. The code is as follows: RewriteEngine on...
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template