Skip to content

Instantly share code, notes, and snippets.

@IISResetMe
Last active October 11, 2017 15:39
Show Gist options
  • Save IISResetMe/54d5395ce399b881f8ce1d25499be173 to your computer and use it in GitHub Desktop.
Save IISResetMe/54d5395ce399b881f8ce1d25499be173 to your computer and use it in GitHub Desktop.
A pipeline-heavy twist on 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 = "" |Select-Object _prop1,_prop2
$MyObject |Add-Member -Name Prop1 -MemberType ScriptProperty -Value {return $this._prop1} -SecondValue {param([int]$value) $this._prop1 = $value}
$MyObject |Add-Member -Name Prop2 -MemberType ScriptProperty -Value {return $this._prop2} -SecondValue {param([int]$value) $this._prop2 = $value}
$MyObject |Add-Member -Name SumProperties -MemberType ScriptMethod -Value { return $this.Prop1 + $this.Prop2 }
$MyObject.Prop1 = 3
$MyObject.Prop2 = 2
$MyObject.SumProperties()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment