# Blocking main page to steal postmessage {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** ๐Ÿ’ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐Ÿฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %} ## Winning RCs with Iframes ์ด [**Terjanq writeup**](https://gist.github.com/terjanq/7c1a71b83db5e02253c218765f96a710)์— ๋”ฐ๋ฅด๋ฉด, null origin์—์„œ ์ƒ์„ฑ๋œ blob ๋ฌธ์„œ๋Š” ๋ณด์•ˆ์ƒ์˜ ์ด์ ์œผ๋กœ ๊ฒฉ๋ฆฌ๋˜์–ด ์žˆ์œผ๋ฉฐ, ์ด๋Š” ๋ฉ”์ธ ํŽ˜์ด์ง€๊ฐ€ ๋ฐ”์˜๋ฉด iframe ํŽ˜์ด์ง€๊ฐ€ ์‹คํ–‰๋œ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ์ด ๋„์ „์—์„œ **๊ฒฉ๋ฆฌ๋œ iframe์ด ์‹คํ–‰**๋˜๊ณ  ๋ฐ”๋กœ **๋กœ๋“œ๋œ ํ›„** **๋ถ€๋ชจ** ํŽ˜์ด์ง€๊ฐ€ **ํ”Œ๋ž˜๊ทธ**์™€ ํ•จ๊ป˜ **post** ๋ฉ”์‹œ์ง€๋ฅผ **๋ณด๋ƒ…๋‹ˆ๋‹ค**.\ ๊ทธ๋Ÿฌ๋‚˜ ๊ทธ postmessage ํ†ต์‹ ์€ **XSS์— ์ทจ์•ฝ**ํ•ฉ๋‹ˆ๋‹ค( **iframe**์ด JS ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค). ๋”ฐ๋ผ์„œ ๊ณต๊ฒฉ์ž์˜ ๋ชฉํ‘œ๋Š” **๋ถ€๋ชจ๊ฐ€ iframe์„ ์ƒ์„ฑํ•˜๊ฒŒ** ํ•˜๋˜, **๋ถ€๋ชจ** ํŽ˜์ด์ง€๊ฐ€ **๋ฏผ๊ฐํ•œ ๋ฐ์ดํ„ฐ(ํ”Œ๋ž˜๊ทธ)**๋ฅผ **๋ณด๋‚ด๊ธฐ ์ „์—** **๋ฐ”์˜๊ฒŒ ์œ ์ง€**ํ•˜๊ณ  **payload๋ฅผ iframe์œผ๋กœ ๋ณด๋‚ด๋Š”** ๊ฒƒ์ž…๋‹ˆ๋‹ค. **๋ถ€๋ชจ๊ฐ€ ๋ฐ”์  ๋•Œ** **iframe์€ payload๋ฅผ ์‹คํ–‰**ํ•˜๋ฉฐ, ์ด๋Š” **๋ถ€๋ชจ postmessage ๋ฉ”์‹œ์ง€๋ฅผ ๋“ฃ๊ณ  ํ”Œ๋ž˜๊ทธ๋ฅผ ์œ ์ถœํ•˜๋Š”** JS๊ฐ€ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.\ ๋งˆ์ง€๋ง‰์œผ๋กœ, iframe์ด payload๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๋ถ€๋ชจ ํŽ˜์ด์ง€๊ฐ€ ๋ฐ”์˜์ง€ ์•Š๊ฒŒ ๋˜๋ฉด, ํ”Œ๋ž˜๊ทธ๋ฅผ ๋ณด๋‚ด๊ณ  payload๊ฐ€ ์ด๋ฅผ ์œ ์ถœํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ๋ถ€๋ชจ๊ฐ€ **iframe์„ ์ƒ์„ฑํ•œ ์งํ›„์— ๋ฐ”์˜๊ฒŒ ๋งŒ๋“ค๊ณ , ๋ฏผ๊ฐํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด iframe์ด ์ค€๋น„๋˜๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๋Š” ๋™์•ˆ ์–ด๋–ป๊ฒŒ ํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”?** ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ถ€๋ชจ๊ฐ€ **์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋Š”** **๋น„๋™๊ธฐ** **์ž‘์—…**์„ ์ฐพ์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์ด ๋„์ „์—์„œ ๋ถ€๋ชจ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด **postmessages**๋ฅผ **๋“ฃ๊ณ ** ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค: ```javascript window.addEventListener('message', (e) => { if (e.data == 'blob loaded') { $("#previewModal").modal(); } }); ``` ๊ทธ๋ž˜์„œ **postmessage**์—์„œ **ํฐ ์ •์ˆ˜๋ฅผ ๋ณด๋‚ด๋Š”** ๊ฒƒ์ด ๊ฐ€๋Šฅํ–ˆ์œผ๋ฉฐ, ์ด๋Š” ๊ทธ ๋น„๊ต์—์„œ **๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜๋ ** ๊ฒƒ์ด๊ณ , ์‹œ๊ฐ„์ด ์ข€ ๊ฑธ๋ฆด ๊ฒƒ์ž…๋‹ˆ๋‹ค: ```bash const buffer = new Uint8Array(1e7); win?.postMessage(buffer, '*', [buffer.buffer]); ``` ์ •ํ™•ํ•˜๊ฒŒ **postmessage**๋ฅผ **iframe**์ด ์ƒ์„ฑ๋œ **ํ›„**์—, ๊ทธ๋Ÿฌ๋‚˜ ๋ถ€๋ชจ๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์„ ์ค€๋น„๊ฐ€ **๋˜๊ธฐ ์ „์—** **setTimeout**์˜ ๋ฐ€๋ฆฌ์ดˆ๋ฅผ **์กฐ์ •**ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. {% hint style="success" %} Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks * Check the [**subscription plans**](https://github.com/sponsors/carlospolop)! * **Join the** ๐Ÿ’ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐Ÿฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}