Let’s talk about the implementation method first:
inj.php:
Copy code The code is as follows:
set_time_limit(10);
$id=$_GET["id"];
$id=str_replace(" ","%20",$id);
$ id=str_replace("=","%3D",$id);
$url="http://www.xxx.com/index.php/library/more/id/$id.html";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"$url");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//The information obtained by curl_init() when enabled Return in the form of a file stream instead of direct output
curl_setopt($ch,CURLOPT_HEADER,0);//When enabled, the header file information will be output as a data stream
$output=curl_exec($ch);
curl_close($ch);
print_r($output);
?>
Build a server with wamp and put the above inj.php into wamp/www/ , and then run http://127.0.0.1/inj.php?id=1
========================== ====
PHP pseudo-static implementation method 1 (using the function of Apache server) 1. Check whether Apache supports mod_rewrite
2. Let Apache support .htaccess
3 , Create .htaccess file
4. Rules:
RewriteEngine on
RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$index .php?action=$1&id=$2
([a-zA-Z]{1,})-([0-9]{1,}) is what the URL looks like
$1 is ([a The
$2 matched by -zA-Z]{1,}) is the
matched by [0-9]{1,}. For example: www.xx.com/page-18.html
The real URL is as follows:
action = page
id = 18
==============================
PHP pseudo-static implementation method two (encoding implementation) $Php2Html_FileUrl = $_SERVER["REQUEST_URI"]
echo $Php2Html_FileUrl
Example: // localhost/php100/test.php ?id|1@action|2
Copy code The code is as follows:
$Php2Html_UrlString = str_replace("?"," ",str_replace("/","",strrchr(strrchr($Php2Html_FileUrl,"/"),"?")) ))
/*
The inner strrchr comes out: /test.php?id |1@action|2
The strrchr of the outer layer comes out: id|1@action|2
The str_replace of the inner layer comes out: remove the / sign. This example does not have it.
The str_replace of the outer layer comes out: remove? Remove the number, there is no one in this example
*/
$Php2Html_UrlQueryStrList = explode("@",$Php2Html_UrlString);
/*Convert str into an array divided by @: id|1 and action| 2*/
foreach($Php2Html_UrlQueryStrList as $Php2Html_UrlQueryStr)
{
$Php2Html_TmpArray = explode("|",$Php2Html_UrlQueryStr);
/* id => 1 and action => 2 */
$_GET[$Php2Html_TmpArray[0]] = $Php2Html_TmpArray[1];
}
================ ============
PHP pseudo-static implementation method three (encoding implementation) Example: localhost/php100/test.php/1/2
Copy code The code is as follows:
$filename = basename($_SERVER["SCRIPT_NAME"]);
echo $_SERVER[ "SCRIPT_NAME"];
echo $filename;
if(strtolower($filename) == 'test.php'){
if(!empty($_GET[id])){
$id=intval($_GET[id]);
echo $id;
$action = intval($_GET[action]);
echo $action;
}else{
$nav=$_SERVER["REQUEST_URI"];
$script=$_SERVER["SRCIPT_NAME"];
//This sentence should be to get rid of the previous paragraph of the URL. . That leaves something like "1/2". .
$nav=ereg_replace("$script","",urldecode($nav));
echo $nav;
$vars = explode("/",$nav);
print_r ($vars);
$id=intval($vars[1]);
$action=intval($vars[2]);
}
echo $id.'&'. $action;
}
============================
PHP pseudo-static implementation method four (coding implementation)
Copy code The code is as follows:
function mod_rewrite(){
global $_GET;
$nav = $_SERVER["REQUEST_URI"];
$script_name = $_SERVER["SCRIPT_NAME"]
$nav=substr(ereg_replace("$script_name"), "",urldecode($nav)),1);
$nav=preg_replace("/^.ht(m){1}(l){0,1}$/","",$nav) ;//Remove the trailing htm or html
$vars=explode("/",$nav);
print_r($vars);
for($i=0;$i{
$_GET[$vars[$i]] = $vars[$i+1];
}
return $_GET;
}
==============================
PHP pseudo-static implementation method five ( Coding implementation) Example: /1,100,8630.html
Copy code The code is as follows:
if (preg_match(“//(d+),(d+),(d+).html/si”,$path_info,$arr_path)){
$gid =intval($arr_path[1]); //Get the value 1
$sid =intval($arr_path[2]); //Get the value 100
$softid =intval($arr_path[3]); //Get the value 8630
}
else
echo "Path:Error!";
To summarize: (1) Pseudo-static technology is easier to break through, and you need to construct the transfer injection page yourself.
(2) The principle of pseudo-static technology is very simple, which is to replace the original URL in the form of index.php?id=1 with other forms.
http://www.bkjia.com/PHPjc/328045.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328045.htmlTechArticleLet’s talk about the implementation method first: inj.php: Copy the code as follows: ?php set_time_limit(10); $id= $_GET["id"]; $id=str_replace(" ","%20",$id); $id=str_replace("=","%3D",$id); $url="http:/ /www...