# SMB Enumeration

## What is SMB?

SMB (Server Message Block) is a file sharing protocol which helps users and devices access files, resources remotely on a server. Authorized clients can use SMB client requests and carry out CRUD operations on a remote server.&#x20;

## SMB Shares

SMB share is nothing but a folder that a server makes available on the network for other clients to access. Shares are password protected and users are supposed to enter the correct ones to access the shares. Both public and user-specific shares can be found.

## Samba

This service is a common finding on ports 139,445. Samba enables Linux devices to share files, printers, and other resources with Windows systems via the SMB protocol. We can even say that it's a bridge between Linux/Unix and Windows machines.

## Enumeration

### SMBMap

SMBMap gives a lot of functionality for enumeration including listing of shares, updating/writing to shares, execute remote commands etc.

\
Example:\\

<figure><img src="https://697415701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOxHHc65JQOToz8nkPKh%2Fuploads%2FnSUEMxUmBLTXMebI5w6a%2Fimage.png?alt=media&#x26;token=30210c13-a0d2-45ad-a194-1b1f2c7331f2" alt=""><figcaption></figcaption></figure>

## smbclient

It's a common tool for samba to list shares on a network and carry out basic file operations on SMB servers.

* Listing shares:\
  `smbclient -L 10.201.97.23`\\

<figure><img src="https://697415701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOxHHc65JQOToz8nkPKh%2Fuploads%2FyGGkDb7zLRbMaaHQfMfb%2Fimage.png?alt=media&#x26;token=333ebff1-39f3-4c1a-8ed1-cb792723a806" alt=""><figcaption></figcaption></figure>

* Enumerate the public share and connect to it to see it's contents\
  `smbclient //10.201.97.23/websvr`

<figure><img src="https://697415701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGOxHHc65JQOToz8nkPKh%2Fuploads%2FYn1hALhyXjzFIsr3qrWw%2Fimage.png?alt=media&#x26;token=512ebeb4-28f8-46fe-80f9-bb16fef40bf1" alt=""><figcaption></figcaption></figure>

I actually prepared these notes for my own reference because I tend to forget things while solving CTFs or enumerating SMB on targets. We can also do user-specific enumeration for SMB shares but that's a story for a different day. According to my experience of solving CTFs, I have hardly come across any instance where I am required to enumerate any user-specific share.&#x20;

We can also use Metasploit to enumerate SMB servers using the `smb_enumshares` module but I will write about that sometime later.
