Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias R. Jessen IISResetMe

  • Booking.com
  • Netherlands
View GitHub Profile
@IISResetMe
IISResetMe / Set-ADPrincipalRedirection.ps1
Created Nov 22, 2022
Quick and dirty function to affect the same changes as redircmp.exe and redirusr.exe
View Set-ADPrincipalRedirection.ps1
function Set-ADPrincipalRedirection {
param(
[Parameter(Mandatory)]
$Domain,
[string]
$ComputersOU,
[string]
$UsersOU
View ConvertFrom-WildcardPattern.ps1
function ConvertFrom-WildcardPattern {
param(
[Parameter(Mandatory, ValueFromPipeline)]
[WildcardPattern]$InputObject
)
begin {
$pctrProp = [WildcardPattern].
GetMember('PatternConvertedToRegex', [Reflection.BindingFlags]'NonPublic, Instance')
}
View Get-ADCertificateAuthority.ps1
$ConfigurationDN = $([ADSI]"LDAP://RootDSE").ConfigurationNamingContext;
$SearchRoot = "LDAP://CN=Enrollment Services,CN=Public Key Services,CN=Services,$ConfigurationDN"
$SearchFilter = "(objectCategory=pkiEnrollmentService)"
foreach($CAEnrollService in (New-Object adsiSearcher([ADSI]$SearchRoot,$SearchFilter)).FindAll()){
$serviceProperties = [ordered]@{}
foreach($propName in 'Name CN DnsHostName'.Split()){
$serviceProperties[$propName] = $CAEnrollService.Properties[$propName] |Select -First 1
}
View Get-PSRStaticInvocationHistory.ps1
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
View half_a_record_typer.ps1
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);`),
View MeasureCallstackPenalty.ps1
function target {
param($Caller = $((Get-PSCallStack)[0].Command))
"'$Caller' called!"
}
function volunteerID {
target -Caller $MyInvocation.MyCommand
}
@IISResetMe
IISResetMe / Find-VulnerableSchemas.ps1
Last active Jan 24, 2023
Find-VulnerableSchemas.ps1
View Find-VulnerableSchemas.ps1
# 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
View flatten.ps1
using namespace System.Collections
function flatten
{
param(
[IDictionary]$Dictionary,
[string]$KeyDelimiter = ':'
)
$newDict = @{}
View stackoverflow-font-hack.css
body *:not(code) { font-family: arial !important; }
code {font-family: monospace !important;}
@IISResetMe
IISResetMe / Get-InvocationQuote.ps1
Created Dec 31, 2020
Quote repeatable command invocation from [InvocationInfo] for simple parameter types
View Get-InvocationQuote.ps1
function Get-InvocationQuote
{
param([System.Management.Automation.InvocationInfo]$Invocation)
$cmdText = $Invocation.InvocationName
foreach($param in $Invocation.BoundParameters.GetEnumerator()){
$name = $param.Key
$value = switch($param.Value){
{$_ -is [string]} {
# Quote and escape all string values as sigle-quoted literals