PHP break-through based on HTTP

Source: Internet
Author: User
Tags array copy php script
Then if you consider the measures to break the chain of anti-theft, you need to consider the http_referer above the tamper. The corresponding variable in the PHP script is $_server[' Http_referer ', which stores the Http_referer value.

Because the direct access target URL resource has been blocked by the above anti-theft chain measures, so we need a similar gateway to get the thing. The plain thing is to write a PHP script that has been wrapped in HTTP headers.

Here's a simple function implementation:
Copy CodeThe code is as follows:
function Getremotefile ($url, $refer = ' ") {
$option = Array (
' http ' => array (
' Header ' => "Referer: $refer")
);
$context = Stream_context_create ($option);
Return file_get_contents ($url, False, $context);
}

This is a simpler function, which is to forge Referer (using the Stream_context_create function) and then get the data from each other (using file_get_contents, you need to turn on allow_url_fopen).

If you want to be "complex", you can use the sockets extension, which is not within the scope of this discussion.

In addition, provide a regular function to get the host name
Copy Code code as follows:
function GetHost ($url) {
$result = Preg_match ('/^http:\/\/[\d\w\.] +) \//', $url, $matches);
if (sizeof ($matches) >= 2) {
return $matches [1];
} else {
return null;
}
}

Further extensions can be encapsulated into scripts and then, for example, call

Http://127.0.0.1/proxy.php?url=http://i.am/img will be able to access the links that unlock the chain of action (and then use Javascript to replace all of the picture links).



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.