Skip to content

Instantly share code, notes, and snippets.

View awakecoding's full-sized avatar

Marc-André Moreau awakecoding

View GitHub Profile
function New-PSHostSession {
[CmdletBinding(DefaultParameterSetName = 'ById')]
param (
[Parameter(ParameterSetName = 'ById', Mandatory = $true, Position = 0)]
[int] $Id,
[Parameter(ParameterSetName = 'ByProcess', Mandatory = $true, ValueFromPipeline = $true)]
[System.Diagnostics.Process] $Process,
[Parameter(ParameterSetName = 'ByCustomPipeName', Mandatory = $true)]
@awakecoding
awakecoding / ReadyToRun.ps1
Last active August 4, 2024 21:07
ReadyToRun.ps1
param(
[Parameter(Mandatory = $true, Position = 0)]
[string] $InputPath,
[string] $OutputPath,
[ValidateSet("x64", "arm64")]
[string] $TargetArch = "x64",
[ValidateSet("windows", "linux", "osx")]
[string] $TargetOS = "windows",
[Parameter(Mandatory = $true)]
[string] $RuntimeConfigFile,
@awakecoding
awakecoding / Set-ZipFileUnixPermissions.ps1
Created March 12, 2024 18:25
Set zip file unix permissions (useful to set execute bit on executables without using chmod +x)
#!/usr/bin/env pwsh
param(
[Parameter(Position = 0, Mandatory = $true)]
[string] $ZipFilePath,
[Parameter(Position = 1, Mandatory = $true)]
[string] $FilePattern,
[Parameter(Position = 2, Mandatory = $true)]
function Install-WinDbg {
param(
[switch] $Start
)
# Change default progress preference (faster downloads)
$DefaultProgressPreference = $ProgressPreference
$ProgressPreference = 'SilentlyContinue'
Write-Host "Downloading windbg.appinstaller (XML manifest file)"
function Install-DbgHelp {
param (
[Parameter(Mandatory=$true, Position=0)]
[string] $DbgHelpBaseDir,
[Parameter()]
[string[]] $DbgHelpFiles = @('dbghelp.dll','symsrv.dll','srcsrv.dll'),
[Parameter()]
[switch] $Cleanup
@awakecoding
awakecoding / CertCredentialMarshaledString.ps1
Last active January 19, 2024 16:03
Handle RDP smartcard automatic selection through special '@@'-prefixed usernames containing SHA1 certificate hash
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
namespace WinCred
{
public enum CRED_MARSHAL_TYPE
{
CertCredential = 1,
UsernameTargetCredential,
@awakecoding
awakecoding / Get-AadJoinInformation.ps1
Created August 8, 2023 14:21
Get Azure AD (Entra ID) Join Information without dsregcmd
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
public enum DSREG_JOIN_TYPE {
DSREG_UNKNOWN_JOIN = 0,
DSREG_DEVICE_JOIN = 1,
DSREG_WORKPLACE_JOIN = 2
}
@awakecoding
awakecoding / gist:9ba01506210b3e732e84e83da558a598
Created August 4, 2023 13:06
kdcsvc.dll (NTDS) certificate loading functions
__int64 KdcInitializeCerts(void)
{
unsigned __int8 v0; // cl
int v1; // r12d
HANDLE EventW; // rax
unsigned int v3; // r14d
char *Heap; // rax
char *v5; // r15
const char *v6; // r9
const char *v7; // rdi
# script to duplicate and edit the smartcard logon certificate template for easy testing
$certca = @"
using System;
using System.Runtime.InteropServices;
public class CertCA
{
public const uint CA_FLAG_ENUM_ALL_TYPES = 0x00000004;
public const uint CT_FIND_LOCAL_SYSTEM = 0x00000002;
function Invoke-PortKnock
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string] $HostName,
[Parameter(Mandatory=$true,Position=1)]
[Int32[]] $Sequence,
[Parameter(Mandatory=$false,Position=2)]
[Int32] $Delay = 500