Skip to content

Instantly share code, notes, and snippets.

@jborean93
jborean93 / Get-TlsCipherSuite.ps1
Created November 3, 2022 02:38
Basic replacement for Get-TlsCipherSuite for older OS versions.
Function Get-TlsCipherSuite {
<#
.DESCRIPTION
Get a list of enabled TLS cipher suites for the server.
This is like the Get-TlsCipherSuite cmdlet but works on older Windows
versions.
#>
[OutputType([string])]
param ()
@jborean93
jborean93 / Remove-FileEntry.ps1
Last active July 1, 2023 21:03
Removes a file/dir using direct Win32 calls
Add-Type -TypeDefinition @'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
namespace Kernel32
{
public enum FileInfoLevel
@jborean93
jborean93 / tls-keylogger.ps1
Last active August 11, 2023 04:11
Logs Wireshark compatible TLS keys like the SSLKEYLOGFILE env var
#Requires -Module PSDetour
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$LogPath
)
$LogPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($LogPath)
@jborean93
jborean93 / Get-SMBApplicationKey.ps1
Last active October 12, 2022 19:44
Gets the SMB2 Application Key from a Logon Session
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
<# Example Code to Run on the Server
$pipeServer = [System.IO.Pipes.NamedPipeServerStream]::new("jordan-test", [System.IO.Pipes.PipeDirection]::InOut)
$pipeServer.WaitForConnection()
try {
$tokenStat = Get-NamedPipeClientStatistics -Pipe $pipeServer
$appKey = Get-SMBApplicationKey -LogonId $tokenStat.AuthenticationId
[System.Convert]::ToBase64String($appKey.Applicationkey)
@jborean93
jborean93 / Get-LogonSessionData.ps1
Created August 30, 2022 11:57
Get LSA logon session data
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-LogonSessionData {
<#
.SYNOPSIS
Get LSA logon session data.
.DESCRIPTION
Get the logon session information for all or a specific logon session or specific process logon sessions.
@jborean93
jborean93 / Get-WTSSessionInfo.ps1
Last active March 26, 2024 14:49
Tries to replicate qwinsta but return structured objects
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-WTSSessionInfo {
<#
.SYNOPSIS
Enumerates sessions on a Windows host.
.DESCRIPTION
Enumerates all the sessions available on a Windows host through the WTSEnumerateSessionsExW API.
@jborean93
jborean93 / Trace-TlsHandshake.ps1
Last active December 7, 2023 14:49
Debug TLS Handshakes using .NET
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Trace-TlsHandshake {
<#
.SYNOPSIS
TLS Handshake Diagnostics.
.DESCRIPTION
Performs a TLS handshake and returns diagnostic information about that
@jborean93
jborean93 / HttpSslCert.ps1
Created April 1, 2022 01:35
Create pwsh wrapper for netsh.exe http add|delete|show sslcert
[Flags()] enum CertCheckMode {
VerifyClientCertRevocation = 0x00000000
VerifyRevocationUsingCacheOnly = 0x00000002
DefaultRevocationFreshnessTimeIsEnabled = 0x00000004
NoUsageCheck = 0x00010000
}
[Flags()] enum SslFlags {
None = 0x00000000
UseDsMapper = 0x00000001
@jborean93
jborean93 / win_powershell_ssh.ps1
Last active October 15, 2023 15:14
Windows PowerShell SSH Remoting Stub
<#
.SYNOPSIS
Windows PowerShell SSH Server Subsystem Shim.
.DESCRIPTION
Used as a basic wrapper for Windows PowerShell that allows it to be used as a target for SSH based remoting sessions.
This allows a PowerShell client to target a Windows host through SSH without having PowerShell 7 installed.
.NOTES
This is experimental and used as a POC.
@jborean93
jborean93 / PSClassSplat.ps1
Last active December 5, 2023 10:25
Example on how to use a class as a PowerShell splat value
class SplatClass : System.Collections.IEnumerable {
SplatClass() {}
[System.Collections.IEnumerator] GetEnumerator() {
# This can be any hashtable stored or derived from the class. This is
# just an example
$params = @{
Path = '/tmp'
}