This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StringBase { | |
hidden static [string] $_pattern = '(?!)' | |
hidden [string] $_value | |
# define single ctor with input string as its only parameter | |
StringBase([string]$value) { | |
$this._value = $value | |
if (-not $this.TryParse()) { | |
throw [ArgumentException]::new("Failed to parse input string '$value'", 'value') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AvailableLicenseTemplates { | |
[CmdletBinding()] | |
param () | |
process { | |
Write-Host "`$PSScriptRoot:" $PSScriptRoot -ForegroundColor Green | |
# Define the parent directory containing the folders | |
$ParentDirectory = "$PSScriptRoot\..\Templates\LICENSE\" | |
# Get the list of folders | |
$Folders = Get-ChildItem -Path $ParentDirectory -Directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Scan-LOLDrivers { | |
param( | |
[Parameter(Mandatory = $true)] | |
[string]$path | |
) | |
Add-Type -TypeDefinition @" | |
using System; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-ADPrincipalRedirection { | |
param( | |
[Parameter(Mandatory)] | |
$Domain, | |
[string] | |
$ComputersOU, | |
[string] | |
$UsersOU |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertFrom-WildcardPattern { | |
param( | |
[Parameter(Mandatory, ValueFromPipeline)] | |
[WildcardPattern]$InputObject | |
) | |
begin { | |
$pctrProp = [WildcardPattern]. | |
GetMember('PatternConvertedToRegex', [Reflection.BindingFlags]'NonPublic, Instance') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-PSReadLineOption |Get-Content -LiteralPath { $_.HistorySavePath } |ForEach-Object { | |
if($_.EndsWith('`')){ | |
$last += "{0}`r`n" -f $_.Remove($_.Length - 1) | |
}else{ | |
"${last}${_}" | |
$last = $null | |
} | |
} |Where-Object {$_ -like '*::*'} |ForEach-Object { | |
# parse history entry as powershell script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System.Reflection | |
using namespace System.Reflection.Emit | |
using namespace System.Runtime.CompilerServices | |
# We'll attempt to construct a subset of the functionality of: | |
# public record TestRecord(int M1, string M2); | |
# | |
# Namely, we'll generate: | |
# - property getters (`get_M1()`, `get_M2()`), | |
# - a public constructor (`TestRecord(int, int);`), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function target { | |
param($Caller = $((Get-PSCallStack)[0].Command)) | |
"'$Caller' called!" | |
} | |
function volunteerID { | |
target -Caller $MyInvocation.MyCommand | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dictionary to hold superclass names | |
$superClass = @{} | |
# List to hold class names that inherit from container and are allowed to live under computer object | |
$vulnerableSchemas = [System.Collections.Generic.List[string]]::new() | |
# Resolve schema naming context | |
$schemaNC = (Get-ADRootDSE).schemaNamingContext | |
# Enumerate all class schemas |
NewerOlder