Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A unique PowerShell coding style seen by a threat actor. This is probably as close to OOP PowerShell as you could get in the PSv2 days.
$MyObject = New-Module -ScriptBlock {
[Int] $Script:Prop1 = 0
[Int] $Script:Prop2 = 1
function GetProp1 {
$Script:Prop1
}
function SetProp1 {
param (
[Int] $PropVal
)
$Script:Prop1 = $PropVal
}
function GetProp2 {
$Script:Prop2
}
function SetProp2 {
param (
[Int] $PropVal
)
$Script:Prop2 = $PropVal
}
function SumProperties {
$Script:Prop1 + $Script:Prop2
}
} -AsCustomObject
$MyObject.SetProp1(3)
$MyObject.GetProp1()
$MyObject.GetProp2()
$MyObject.SumProperties()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.