hacktricks/pentesting-web/xss-cross-site-scripting/some-same-origin-method-execution.md

84 lines
5.8 KiB
Markdown
Raw Normal View History

2022-06-23 12:12:25 +00:00
# SOME - Same Origin Method Execution
2024-07-18 20:49:07 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-06-23 12:12:25 +00:00
<details>
2024-07-18 20:49:07 +00:00
<summary>Support HackTricks</summary>
2022-06-23 12:12:25 +00:00
2024-07-18 20:49:07 +00:00
* 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.
2022-06-23 12:12:25 +00:00
</details>
2024-07-18 20:49:07 +00:00
{% endhint %}
2022-06-23 12:12:25 +00:00
2024-04-18 13:42:29 +00:00
### [WhiteIntel](https://whiteintel.io)
2024-05-05 17:56:05 +00:00
<figure><img src="../../.gitbook/assets/image (1227).png" alt=""><figcaption></figcaption></figure>
2024-04-18 13:42:29 +00:00
[**WhiteIntel**](https://whiteintel.io) is a **dark-web** fueled search engine that offers **free** functionalities to check if a company or its customers have been **compromised** by **stealer malwares**.
Their primary goal of WhiteIntel is to combat account takeovers and ransomware attacks resulting from information-stealing malware.
You can check their website and try their engine for **free** at:
{% embed url="https://whiteintel.io" %}
2024-05-05 17:56:05 +00:00
***
2024-04-18 13:42:29 +00:00
2022-06-23 12:12:25 +00:00
## Same Origin Method Execution
There will be occasions where you can execute some limited javascript in a page. For example, in the case where you can[ **control a callback value that will be executed**](./#javascript-function).
In those case, one of the best things that you could do is to **access the DOM to call whatever** sensitive action you can find in there (like clicking a button). However, usually you will find this vulnerability in **small endpoints without any interesting thing in the DOM**.
In those scenarios, this attack will be very useful, because its goal is to be able to **abuse the limited JS execution inside a DOM from a different page from the same domain** with much interesting actions.
2023-03-05 23:41:46 +00:00
Basically, the attack flow is the following:
2022-06-23 12:12:25 +00:00
* Find a **callback that you can abuse** (potentially limited to \[\w\\.\_]).
* If it's not limited and you can execute any JS, you could just abuse this as a regular XSS
* Make the **victim open a page** controlled by the **attacker**
* The **page will open itself** in a **different window** (the new window will have the object **`opener`** referencing the initial one)
* The **initial page** will load the **page** where the **interesting DOM** is located.
* The **second page** will load the **vulnerable page abusing the callback** and using the **`opener`** object to **access and execute some action in the initial page** (which now contains the interesting DOM).
{% hint style="danger" %}
Note that even if the initial page access to a new URL after having created the second page, the **`opener` object of the second page is still a valid reference to the first page in the new DOM**.
2022-06-23 12:52:13 +00:00
Moreover, in order for the second page to be able to use the opener object **both pages must be in the same origin**. This is the reason why, in order to abuse this vulnerability, you need to find some sort of **XSS in the same origin**.
2022-06-23 12:12:25 +00:00
{% endhint %}
### Exploitation
2022-06-23 12:52:13 +00:00
* You can use this form to **generate a PoC** to exploit this type of vulnerability: [https://www.someattack.com/Playground/SOMEGenerator](https://www.someattack.com/Playground/SOMEGenerator)
* In order to find a DOM path to a HTML element with a click you can use this browser extension: [https://www.someattack.com/Playground/targeting\_tool](https://www.someattack.com/Playground/targeting\_tool)
2022-06-23 12:12:25 +00:00
### Example
* You can find a vulnerable example in [https://www.someattack.com/Playground/](https://www.someattack.com/Playground/)
* Note that in this example the server is **generating javascript code** and **adding** it to the HTML based on the **content of the callback parameter:** `<script>opener.{callbacl_content}</script>` . Thats why in this example you don't need to indicate the use of `opener` explicitly.
2023-03-05 23:41:46 +00:00
* Also check this CTF writeup: [https://ctftime.org/writeup/36068](https://ctftime.org/writeup/36068)
2022-06-23 12:12:25 +00:00
## References
* [https://conference.hitb.org/hitbsecconf2017ams/sessions/everybody-wants-some-advance-same-origin-method-execution/](https://conference.hitb.org/hitbsecconf2017ams/sessions/everybody-wants-some-advance-same-origin-method-execution/)
2024-07-18 20:49:07 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-06-23 12:12:25 +00:00
<details>
2024-07-18 20:49:07 +00:00
<summary>Support HackTricks</summary>
2022-06-23 12:12:25 +00:00
2024-07-18 20:49:07 +00:00
* 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.
2022-06-23 12:12:25 +00:00
</details>
2024-07-18 20:49:07 +00:00
{% endhint %}