Home  >  Article  >  Backend Development  >  The wonderful use of instantiationexception php include to achieve path encryption

The wonderful use of instantiationexception php include to achieve path encryption

WBOY
WBOYOriginal
2016-07-29 08:38:30908browse

1. Transfer program include.inc

Copy code The code is as follows:


include_once 'include/Base.php';
$path = '';
$url = isBase::decrypt( urlDecode($_SERVER['QUERY_STRING']));
parse_str($url); //Get the variable passed through url address GET
if(!empty($_POST['path'])){ //Get POST The passed variable
$path = $_POST['path'];
$path = isBase::decrypt(urlDecode($path));
}
//Resolve the real path
if(empty($path)){
//header("Location: login.php");
exit;
}
if(!preg_match("/(^http://)|([?|&|=])/",$path)) {
//Jump to the path of the actual executed file
chdir(dirname($path));
include_once basename($path);
exit;
}
?>


index.php is the same as include.inc Directory

Copy code The code is as follows:


include include.inc;
?>


2. Modify the link in the program ()

Copy the code The code is as follows :


"index.php?".encrypt("path=/test/test.php&test=123&test2=4321")


3. Modify the POST form
Form in the program and submit it to index.php
Middle Add a hidden form
4. Modify the path of the front-end Html page
baseref=/test
5. Encryption and decryption functions, friends, write it yourself.
Summary:
Using this method is more cumbersome. It can only hide the path of the background script. The front-end script path can still be seen in the source file (baseref). The addresses seen on the address bar are index.php?xxxxxxxx

The above has introduced the wonderful use of instantiationexception php include to implement path encryption, including the content of instantiationexception. I hope it will be helpful to friends who are interested in PHP tutorials.

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