The Excel File Never Contained a Macro — It Still Started PowerShell
Excel opened the document.
Seconds later, PowerShell appeared.
The obvious explanation was a malicious macro.
Except the workbook contained no VBA macro.
That did not make the process chain harmless.
Agent Foskett stopped trying to prove a macro existed.
He followed what Excel actually launched.
No Macro Did Not End the Investigation
The absence of VBA answers one question about the document. Endpoint telemetry still has to explain why Excel was associated with a PowerShell child process.
The first theory was wrong
Start with every child process created by Excel
DeviceProcessEvents to identify processes whose initiating process was excel.exe. Preserve both command lines and the initiating process ID so the investigation can reconstruct the relationship rather than relying on process names alone.- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
let Device = "LAPTOP-042";
DeviceProcessEvents
| where Timestamp > ago(7d)
| where DeviceName =~ Device
| where InitiatingProcessFileName =~ "excel.exe"
| project Timestamp,
DeviceName,
AccountName,
FileName,
ProcessCommandLine,
InitiatingProcessFileName,
InitiatingProcessCommandLine,
InitiatingProcessId
| order by Timestamp asc
Isolate the Excel-to-PowerShell relationship
ProcessCommandLine is the key evidence here: it can reveal switches, script paths, encoded content or other arguments that explain what PowerShell was instructed to do.- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
let Device = "LAPTOP-042";
DeviceProcessEvents
| where Timestamp > ago(7d)
| where DeviceName =~ Device
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where InitiatingProcessFileName =~ "excel.exe"
| project Timestamp,
FileName,
ProcessCommandLine,
ProcessId,
InitiatingProcessFileName,
InitiatingProcessCommandLine,
InitiatingProcessId
| order by Timestamp asc
The process tree mattered more than the macro theory
What did PowerShell connect to?
DeviceNetworkEvents. This avoids guessing that the command contacted the internet. If network telemetry exists for that process, preserve the remote URL, IP, port and command line.- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
let Device = "LAPTOP-042";
let PowerShellPid = 7840;
DeviceNetworkEvents
| where Timestamp > ago(7d)
| where DeviceName =~ Device
| where InitiatingProcessId == PowerShellPid
| project Timestamp,
RemoteUrl,
RemoteIP,
RemotePort,
Protocol,
InitiatingProcessFileName,
InitiatingProcessCommandLine
| order by Timestamp asc
Did PowerShell create or modify a file?
DeviceFileEvents. File creation or modification shortly after the PowerShell execution can expose a downloaded payload, script, archive or other artefact that becomes the next investigative pivot.- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
let Device = "LAPTOP-042";
let PowerShellPid = 7840;
DeviceFileEvents
| where Timestamp > ago(7d)
| where DeviceName =~ Device
| where InitiatingProcessId == PowerShellPid
| project Timestamp,
ActionType,
FileName,
FolderPath,
SHA1,
InitiatingProcessFileName,
InitiatingProcessCommandLine
| order by Timestamp asc
Did the resulting payload execute later?
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
let Device = "LAPTOP-042";
let PayloadHash = "0123456789abcdef0123456789abcdef01234567";
DeviceProcessEvents
| where Timestamp > ago(30d)
| where DeviceName =~ Device
| where SHA1 == PayloadHash
or InitiatingProcessSHA1 == PayloadHash
| project Timestamp,
FileName,
FolderPath,
ProcessCommandLine,
InitiatingProcessFileName,
InitiatingProcessCommandLine
| order by Timestamp asc
Has Excel launched PowerShell anywhere else?
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
DeviceProcessEvents
| where Timestamp > ago(30d)
| where InitiatingProcessFileName =~ "excel.exe"
| where FileName in~ ("powershell.exe", "pwsh.exe")
| summarize Executions=count(),
FirstSeen=min(Timestamp),
LastSeen=max(Timestamp),
Users=dcount(AccountName)
by DeviceName,
ProcessCommandLine
| order by Executions desc

