Skip to content

Instantly share code, notes, and snippets.

Mathias R. Jessen IISResetMe

  • Booking.com
  • Netherlands
Block or report user

Report or block IISResetMe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@IISResetMe
IISResetMe / Get-LMHash.ps1
Last active Mar 15, 2019
LMHash generator in written in PowerShell
View Get-LMHash.ps1
function Get-WeakDESEncryptor {
<#
.SYNOPSIS
Creates a DESCryptoProviderService encryptor from a potentially unsafe key
.DESCRIPTION
DESCryptoProviderService.GetEncryptor() attempts to ensure that 0-keys can't be used. This function bypasses the protection and creates a DES encryptor from a potentially unsafe key and an empty initialization vector
.EXAMPLE
PS C:\> $DESProvider = [System.Security.Cryptography.DESCryptoServiceProvider]::new()
PS C:\> $encryptor = Get-WeakDESEncryptor -CSP $DESProvider -Key @(,0*8)
@IISResetMe
IISResetMe / TypoHijack.ps1
Last active Mar 14, 2019
Hijack a subset of non-existing commands in PowerShell
View TypoHijack.ps1
$ExecutionContext.InvokeCommand.CommandNotFoundAction = {
param([string]$CommandName, [System.Management.Automation.CommandLookupEventArgs]$evtArgs)
if($CommandName -like '*glue*'){
$evtArgs.CommandScriptBlock = {
Write-Host "Eating glue because of $CommandName ..." -ForegroundColor Green
}.GetNewClosure()
$evtArgs.StopSearch = $true
}
}
@IISResetMe
IISResetMe / PinnedHandle.cs
Created Mar 11, 2019
Disposable pinned GCHandle
View PinnedHandle.cs
using System;
using System.Runtime.InteropServices;
namespace IISResetMe.SafeHandles
{
/// <summary>Disposable pinned memory handles, useful for non-blittable type references passed to unmanaged code</summary>
public class GCPinnedHandle : IDisposable
{
private GCHandle gcHandle;
View Join-Uri.ps1
function Join-Uri
{
param(
[Parameter(Mandatory = $true, Position = 0)]
[uri]$BaseUri,
[Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)]
[string[]]$PathSegments
)
View RegisterCompleter.ps1
# define an argument completer
$completer = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
if($null -eq $script:_listOfArgCompletions){
# download list and populate $script:_listOfArgComplettions
$script:_listOfArgCompletions = @('Apples','Oranges','Nectarines')
}
$script:_listOfArgCompletions -like "$wordToComplete*" |ForEach-Object {
View Add-GroupMembership.ps1
function Add-GroupMembership
{
[CmdletBinding(DefaultParameterSet='Pipeline')]
param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true, ParameterSetName = 'Pipeline')]
[object[]]$InputObject,
[Parameter(Mandatory=$true, Position=0, ParameterSetName = 'Explicit')]
[string]$User,
View RandomSortOrder.ps1
$Sentence = 'PowerShell is super cool and awesome'
3..6 |ForEach-Object {
$words = -split $Sentence |Select -First $_
$target = $words -join ' '
$avg = $(1..20 |ForEach-Object {
$c = 0
do{
$guess = ($words |Sort-Object {Get-Random}) -join ' '
$c++
View ValidateScopeAttribute.cs
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Management.Automation.Internal;
using System.Management.Automation.Language;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
@IISResetMe
IISResetMe / Resolve-MemberChain.ps1
Created Feb 12, 2019
Recursively dereference powershell instance members without actually resorting to recursion
View Resolve-MemberChain.ps1
function Resolve-MemberChain
{
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[psobject[]]$InputObject,
[Parameter(Mandatory = $true, Position = 0)]
[string[]]$MemberPath,
[Parameter(Mandatory = $false)]
You can’t perform that action at this time.