Public/Invoke-Phase12DomainCompromisePersistence.ps1
|
<#
.SYNOPSIS Runs Phase 12 of the AS2Go attack simulation: Domain Compromise and Persistence. .DESCRIPTION Invoke-ASPhase12DomainCompromisePersistence executes the final attack phase in the AS2Go workflow. It prepares the phase context, shows the phase banner, and starts the Phase 12 action chain after interactive confirmation (or automatically in unattended mode). The phase demonstrates persistence and impact actions such as: - Creating a persistent backdoor domain account - User account manipulation (disable/reset) - Tier 0 group membership manipulation - Group Policy Template tampering - Encrypting backup files on a domain controller - Exporting domain DPAPI backup keys - Forging a Kerberos Golden Ticket - Rebooting available domain machines .PARAMETER Preview Browses descriptions and workflow steps offline without executing actions. Uses a separate preview menu; runtime selection and skip parameters are not evaluated. .PARAMETER UnAttended Runs the phase without interactive confirmation prompts. .PARAMETER Continue Reserved switch for workflow continuation handling. .PARAMETER EnableLogging Enables extended logging for this phase execution. .PARAMETER SkipImages Skips visual phase assets (for example, phase HTML images/pages). .PARAMETER SkipClearHost Prevents clearing the console during phase execution. .PARAMETER AS2GoDemo Runs the phase in AS2Go demo mode and skips selected setup interactions. .PARAMETER DeveloperMode Developer convenience mode. When set, this switch enables logging and automatically skips images and host clearing. .EXAMPLE Invoke-ASPhase12DomainCompromisePersistence Runs Phase 12 interactively. .EXAMPLE Invoke-ASPhase12DomainCompromisePersistence -UnAttended -EnableLogging Runs Phase 12 without prompts and with logging enabled. .EXAMPLE Invoke-ASPhase12DomainCompromisePersistence -DeveloperMode Runs Phase 12 with developer defaults (logging on, images skipped, no clear-host). .NOTES Alias: P12, Compromise Part of: AS2Go attack phase orchestration .COMPONENT Category: Main Function .FUNCTIONALITY Demonstrates backdoor creation, GPO tampering, privileged membership removal, and account access disruption. Supports staged file encryption, domain DPAPI backup-key export, and Golden Ticket creation and injection. Executes the selected workflow, requests configured Domain Controller restarts, or exits the demonstration. #> function Invoke-ASPhase12DomainCompromisePersistence { ################################################################################ ##### ##### ##### Run the Attack Phase - Domain Compromise & Persistence ##### ##### ##### ################################################################################ [Alias("ASP12", "Compromise")] Param ( [switch]$Preview, [switch]$UnAttended, [switch]$Continue, [Switch]$EnableLogging, [switch]$SkipImages, [switch]$SkipClearHost, [switch]$AS2GoDemo, [switch]$DeveloperMode, [validateSet("Encrypt", "Reboot", "BackdoorUser", "GPT", "UserManipulation", "GroupManipulation", "GoldenTicket")] [String]$DomainPersistence, [switch]$SafeMode ) if ($Preview) { Show-AS2GoPreview -FunctionName 'Invoke-ASPhase12DomainCompromisePersistence' -UnAttended:([bool]$PSBoundParameters['UnAttended']) return } $info = Measure-FunctionRuntime -Begin Show-CurrentPhase -Phase "phase_12.html" $functionCallParameters = Get-FunctionCallParameters -FunctionName $MyInvocation.MyCommand.Name -BoundParameters $PSBoundParameters $4logfile = $functionCallParameters.Parameters | Out-String Write-Log -Message " >> Used parameter: $4logfile" If ($DeveloperMode) { $SkipImages = $true $SkipClearHost = $true $EnableLogging = $true } If (-not $SkipClearHost) { Clear-Host } If (-not $AS2GoDemo) { Clear-ExfiltrationFolder Set-NewColorSchema -NewStage $Script:InitialStart Get-AS2GoSettings } Update-WindowTitle -NewTitle $Script:Phase12 Set-ASConfig -Setting "LastStage" -Value $Script:Phase12 $result = Get-ASConfig -Setting "BreakGlassAccount" $result = Convert-FromDNToCN -DistinguishedName $result Set-NewColorSchema -NewStage $Script:InitialStart If (-not $SkipClearHost) { Clear-Host } Write-AS2GoOutput -Type Header -M "Attack Phase - $($Script:Phase12.toupper())" Write-AS2GoOutput -Type H1 -Message $((Get-Help (Get-FunctionName)).Functionality) Write-AS2GoOutput -Type Bullet "Establish persistent access by creating a backdoor domain account" Write-AS2GoOutput -Type Bullet "Disrupt legitimate user access by disabling accounts and/or resetting passwords" Write-AS2GoOutput -Type Bullet "Revoke legitimate administrators' Tier 0 access by removing group memberships" Write-AS2GoOutput -Type Bullet "Modify Group Policy Template (GPT) files to distribute malicious policy settings" Write-AS2GoOutput -Type Bullet "Encrypt backup files stored on the domain controller to impair recovery" Write-AS2GoOutput -Type Bullet "Export domain DPAPI backup keys that can help recover domain users' DPAPI-protected data" Write-AS2GoOutput -Type Bullet "Forge a Kerberos Golden Ticket to maintain persistent domain access" Write-AS2GoOutput -Type Bullet "Initiate a domain-wide reboot of all reachable machines" Write-AS2GoOutput -Type H1 -Message "`n`nThe configured break-glass account (BGA) is excluded from privileged group membership removal and `ncan be modified during this phase." Write-AS2GoOutput -Type TextMaker -Message "Current BGA: " -Tm $result -NoExtraLines $SavedPath = Get-ASConfig -Setting 'ADPrivilegedGroupDirectMember' Write-AS2GoOutput -Type H1 -Message "`n`nThe existing direct membership backup for privileged groups `ncan be updated during this phase." Write-AS2GoOutput -Type TextMaker -Message "Current Backup File: " -Tm $SavedPath -NoExtraLines If ($UnAttended) { $answer = $Script:Yes } else { $promptParams = @{} if ($SafeMode) { $promptParams.Options = @( [pscustomobject]@{ Label = '&Skip' Help = 'Skip this step in Safe Mode' Value = $Script:No } ) } $answer = Show-DecisionPrompt @promptParams } If ($answer -ne $Script:Yes) { Measure-FunctionRuntime -End -Details $info return } If (-not $AS2GoDemo) { $Script:MoGPO = Test-PoSHModuleAvailability -PSModule "GroupPolicy" Show-ForestOverview Get-ForestInfo } #Invoke-ASPhase12DomainCompromise Update-WindowTitle -NewTitle $Script:Phase12 Set-ASConfig -Setting "LastStage" -Value $Script:Phase12 Do { #Write-AS2GoOutput -Type H1 -Message "Domain Dominance & Persistence" #Write-AS2GoOutput -Type H1 -Message $((Get-Help (Get-FunctionName)).Functionality) $topicBackdoor = "Establish persistent domain access through a covert backdoor account" $topicBreakGlass = "Select or change the protected break-glass account" $topicGPT = "Weaponize Group Policy Template (GPT) files for domain-wide compromise" $topicPurge = "Purge all privileged group memberships to grant exclusive control to the backdoor account" $topicUserAccount = "Disable user accounts or enforce password resets (retain backdoor control)" $topicEncrypt = "Encrypt critical Domain Controller assets for strategic leverage" $topicDPAPIBackupKeys = "Export domain DPAPI backup keys that can help recover users' DPAPI master keys" $topicGoldenTicket = "Forge a Golden Ticket to achieve unrestricted Kerberos dominance" $topicReboot = "Trigger coordinated reboot across accessible Domain Controllers" $topicExit = "Exit AS2Go." If ($UnAttended) { $answer = $DomainPersistence } else { If (-not $Script:MoGPO) { $topicGPT = $null } $title = "Domain Dominance & Persistence" $message = "Select the action to execute. Options with unmet requirements are hidden." $Options = @( [pscustomobject] @{ Label = "&Change BGA" Help = $topicBreakGlass Value = "BreakGlass" }, [pscustomobject] @{ Label = "&Backdoor" Help = $topicBackdoor Value = "Backdoor" }, [pscustomobject] @{ Label = "GP&T" Help = $topicGPT Value = "GPT" }, [pscustomobject] @{ Label = "&Purge" Help = $topicPurge Value = "Purge" }, [pscustomobject] @{ Label = "&User Account" Help = $topicUserAccount Value = "UserAccount" }, [pscustomobject] @{ Label = "DPAPI Backup &Keys" Help = $topicDPAPIBackupKeys Value = "DPAPIBackupKeys" }, [pscustomobject] @{ Label = "&Golden Ticket" Help = $topicGoldenTicket Value = "GoldenTicket" }, [pscustomobject] @{ Label = "&Encrypt" Help = $topicEncrypt Value = "Encrypt" }, [pscustomobject] @{ Label = "&Reboot" Help = $topicReboot Value = "Reboot" }, [pscustomobject] @{ Label = "E&xit" Help = $topicExit Value = "Exit" } ) $answer = Show-DecisionPrompt -Message $message -Options $Options -Default 0 -Title $title If (-not $SkipClearHost) { Clear-Host } } switch ($answer) { "Backdoor" { Invoke-BackdoorUserCreation $repeat = $Script:Yes } "BreakGlass" { Set-BreakGlassAccount $repeat = $Script:Yes } "Purge" { Invoke-PrivilegeGroupPurge $repeat = $Script:Yes } "GPT" { Invoke-GPTManipulation $repeat = $Script:Yes } "UserAccount" { Invoke-UserAccountDisruption $repeat = $Script:Yes } "GoldenTicket" { Invoke-GoldenTicketAttack $repeat = $Script:Yes } "Encrypt" { Invoke-Encryption $repeat = $Script:Yes } "DPAPIBackupKeys" { Invoke-DPAPIBackupKeyExport $repeat = $Script:Yes } "Reboot" { Invoke-Shutdown $repeat = $Script:No } "Exit" { Stop-AS2GoDemo -NextStepReboot $Script:No $repeat = $Script:No pause } default { Write-Host "out of scope" $repeat = $Script:Yes } } If (-not $SkipClearHost) { Clear-Host } If ($UnAttended) { $repeat = $Script:No } } Until ($repeat -eq $Script:No) Measure-FunctionRuntime -End -Details $info } |