# T1049 - System Network Connections Discovery
## [Description from ATT&CK](https://attack.mitre.org/techniques/T1049)
<blockquote>Adversaries may attempt to get a listing of network connections to or from the compromised system they are currently accessing or from remote systems by querying for information over the network. 

An adversary who gains access to a system that is part of a cloud-based environment may map out Virtual Private Clouds or Virtual Networks in order to determine what systems and services are connected. The actions performed are likely the same types of discovery techniques depending on the operating system, but the resulting information may include details about the networked cloud environment relevant to the adversary's goals. Cloud providers may have different ways in which their virtual networks operate.(Citation: Amazon AWS VPC Guide)(Citation: Microsoft Azure Virtual Network Overview)(Citation: Google VPC Overview)

Utilities and commands that acquire this information include [netstat](https://attack.mitre.org/software/S0104), "net use," and "net session" with [Net](https://attack.mitre.org/software/S0039). In Mac and Linux, [netstat](https://attack.mitre.org/software/S0104) and <code>lsof</code> can be used to list current connections. <code>who -a</code> and <code>w</code> can be used to show which users are currently logged in, similar to "net session".</blockquote>

## Atomic Tests

- [Atomic Test #1 - System Network Connections Discovery](#atomic-test-1---system-network-connections-discovery)

- [Atomic Test #2 - System Network Connections Discovery with PowerShell](#atomic-test-2---system-network-connections-discovery-with-powershell)

- [Atomic Test #3 - System Network Connections Discovery Linux & MacOS](#atomic-test-3---system-network-connections-discovery-linux--macos)

- [Atomic Test #4 - System Discovery using SharpView](#atomic-test-4---system-discovery-using-sharpview)


<br/>

## Atomic Test #1 - System Network Connections Discovery
Get a listing of network connections.

Upon successful execution, cmd.exe will execute `netstat`, `net use` and `net sessions`. Results will output via stdout.

**Supported Platforms:** Windows


**auto_generated_guid:** 0940a971-809a-48f1-9c4d-b1d785e96ee5






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


```cmd
netstat
net use
net sessions
```






<br/>
<br/>

## Atomic Test #2 - System Network Connections Discovery with PowerShell
Get a listing of network connections.

Upon successful execution, powershell.exe will execute `get-NetTCPConnection`. Results will output via stdout.

**Supported Platforms:** Windows


**auto_generated_guid:** f069f0f1-baad-4831-aa2b-eddac4baac4a






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


```powershell
Get-NetTCPConnection
```






<br/>
<br/>

## Atomic Test #3 - System Network Connections Discovery Linux & MacOS
Get a listing of network connections.

Upon successful execution, sh will execute `netstat` and `who -a`. Results will output via stdout.

**Supported Platforms:** Linux, macOS


**auto_generated_guid:** 9ae28d3f-190f-4fa0-b023-c7bd3e0eabf2






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


```sh
netstat
who -a
```




#### Dependencies:  Run with `sh`!
##### Description: Check if netstat command exists on the machine
##### Check Prereq Commands:
```sh
if [ -x "$(command -v netstat)" ]; then exit 0; else exit 1; fi;
```
##### Get Prereq Commands:
```sh
echo "Install netstat on the machine."; exit 1;
```




<br/>
<br/>

## Atomic Test #4 - System Discovery using SharpView
Get a listing of network connections, domains, domain users, and etc.  
sharpview.exe located in the bin folder, an opensource red-team tool.
Upon successful execution, cmd.exe will execute sharpview.exe <method>. Results will output via stdout.

**Supported Platforms:** Windows


**auto_generated_guid:** 96f974bb-a0da-4d87-a744-ff33e73367e9





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| SharpView_url | sharpview download URL | Url | https://github.com/tevora-threat/SharpView/blob/b60456286b41bb055ee7bc2a14d645410cca9b74/Compiled/SharpView.exe?raw=true|
| SharpView | Path of the executable opensource redteam tool used for the performing this atomic. | Path | PathToAtomicsFolder&#92;T1049&#92;bin&#92;SharpView.exe|
| syntax | Arguements method used along with SharpView to get listing of network connections, domains, domain users, and etc. | String | "Invoke-ACLScanner", "Invoke-Kerberoast", "Find-DomainShare"|


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


```powershell
$syntaxList = #{syntax}
foreach ($syntax in $syntaxList) {
#{SharpView} $syntax -}
```




#### Dependencies:  Run with `powershell`!
##### Description: Sharpview.exe must exist on disk at specified location (#{SharpView})
##### Check Prereq Commands:
```powershell
if (Test-Path #{SharpView}) {exit 0} else {exit 1}
```
##### Get Prereq Commands:
```powershell
New-Item -Type Directory (split-path #{SharpView}) -ErrorAction ignore | Out-Null
Invoke-WebRequest #{SharpView_url} -OutFile "#{SharpView}"
```




<br/>
