# SMB Enumeration

## Network scan

```bash
nbtscan -r 192.168.1.0/24
```

## Retrieve information

### Nmap

```bash
nmap --script "safe or smb-enum-*" -p 139,445 <IP>
```

### Enum4Linux

```bash
enum4linux-ng -A <IP>
enum4linux-ng -A -u <user> -p <password> <IP>
```

## Enumerate Users & Groups

### Crackmapexec

```bash
crackmapexec smb <IP> --users [-u <user> -p <password>]
crackmapexec smb <IP> --groups [-u <user> -p <password>]
```

## Shares enumeration

### List shares and connect

#### Smbclient

```bash
smbclient -N -L //<IP>
smbclient -N //<IP>/<Folder>
smbclient -U '<username[%password]>' -L //<IP>
smbclient -U '<username[%password]>' //<IP>/<Folder>
```

#### Smbmap

```bash
smbmap -H <IP> [-P <PORT>]
smbmap -u <username> -p <password> -H <IP> [-P <PORT>]
smbmap [-u <username -p <password>] -R [<Folder>] -H <IP> [-P <PORT>]
```

#### Crackmapexec

```bash
crackmapexec smb <IP> -u '' -p '' --shares
crackmapexec smb <IP> -u <username> -p <password> --shares
```

### Mount a shared folder

```bash
mount -t cifs //<IP>/share /mnt/share
mount -t cifs -o "username=<username>,password=<password>" //<IP>/share /mnt/share
```

### Download files

```bash
smbclient //<IP>/<share>
> mask ""
> recurse
> prompt
> mget *
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.kaizoku.eu/offensive-security/services-enumeration/smb-enumeration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
