# T1020 - Automated Exfiltration

## SOC Recommendation
Investigate Automated Exfiltration activity in the context of Exfiltration: confirm scope, affected host/identity, and whether it matches expected administrative behaviour before deciding this is benign.

## D3FEND Mappings
| D3FEND Technique | Relationship | Practical SOC Action |
|---|---|---|
| User Geolocation Logon Pattern Analysis | Detect | Monitor for User Geolocation Logon Pattern Analysis indicators relevant to this technique. |
| Network Traffic Filtering | Isolate | Apply Network Traffic Filtering to contain the blast radius once this technique is observed. |

## Investigation Steps
1. Review Defender for Endpoint / Defender XDR alerts and timeline for the affected host or identity.
2. Check Sentinel analytics rules and incidents correlated with this technique.
3. Review Entra ID sign-in and audit logs if the technique involves an identity or cloud resource.

## Evidence to Collect
- Host or resource affected
- Account or identity involved
- Timestamp of the activity
- Related process, file, or network artifact
- Any preceding or follow-on alerts

## Response Actions
| Action | Risk | Automation Safe | Approval Required |
|---|---|---|---|
| Contain the affected host or account | Medium | No | Yes |
| Collect and preserve evidence | Low | Yes | No |

## KQL
```kql
ClarotyEvent
| where EventOriginalType has 'Suspicious File Transfer' or EventType has 'Suspicious File Transfer'
| project TimeGenerated, DstIpAddr, EventOriginalType, EventType
| extend IPCustomEntity = DstIpAddr
| project TimeGenerated, DstIpAddr, EventOriginalType, EventType, IPCustomEntity
```
```kql
DeviceEvents   
| where InitiatingProcessFileName =~ "powershell.exe"
| where ActionType == "AmsiScriptContent"
| where AdditionalFields endswith '[mArS.deiMos]::inteRaCt()"}'
| project InitiatingProcessParentFileName, InitiatingProcessFileName, InitiatingProcessCommandLine, ActionType, AdditionalFields, DeviceName
| extend HostName = iff(DeviceName has '.', substring(DeviceName, 0, indexof(DeviceName, '.')), DeviceName)
| extend DnsDomain = iff(DeviceName has '.', substring(DeviceName, indexof(DeviceName, '.') + 1), "")
```
```kql
let timeframe = 1d;
let spanoftime = 10m;
let threshold = 0;
ExchangeAdminAuditLogs 
  | where TimeGenerated > ago(2 * timeframe)
  | where isempty(UserOriented)
  | project serverExecutedTime = TimeGenerated,
    ServerCmdlet = CmdletName,
    ServerCmdletParams = CmdletParameters,
    Computer,
    Caller,
    ServerCmdletTargetObject = TargetObject
  | join kind= inner (
      ExchangeAdminAuditLogs
      | where TimeGenerated > ago(timeframe)
      | where UserOriented =~ 'Yes'
      | project userExecutedTime = TimeGenerated,
        UserCmdlet = CmdletName,
        UserCmdletParams = CmdletParameters,
        Computer,
        Caller,
        UserCmdletTargetObject = TargetObject,
        userPrincipalName,
        objectGUID,
        sAMAccountName,
        IsVIP)
    on Computer, Caller
  | where userExecutedTime - serverExecutedTime < spanoftime
  | extend TimeDelta = userExecutedTime - serverExecutedTime
  | extend TimeDeltaInverse = serverExecutedTime - userExecutedTime
  | where tolong(TimeDelta) >= threshold or tolong(TimeDeltaInverse) >= threshold
```

## Escalation Criteria
- Automated Exfiltration activity observed on a privileged account or critical system.
- Activity follows or precedes other suspicious behaviour in the same investigation.
- Automated triage cannot confidently rule out malicious intent.

## False Positive Considerations
- Legitimate administrative or maintenance activity matching this pattern.
- Approved security testing or red team exercise.
- Known benign software producing similar telemetry.

Generated by SOC Response Atlas by Basyrix.
