Skip to content

Instantly share code, notes, and snippets.

@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'
}
@jborean93
jborean93 / KDCProxy.ps1
Last active November 28, 2022 14:34
Functions to help set up a KDC proxy server and add client proxy servers - https://syfuhs.net/kdc-proxy-for-remote-access
# Copyright: (c) 2022, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Install-KDCProxyServer {
<#
.SYNOPSIS
Set up a KDC Proxy server.
.DESCRIPTION
Sets up the KDC proxy server on the current host.
@jborean93
jborean93 / NetServiceAccount.ps1
Created February 2, 2022 00:44
APIS that wrap the LMAccess Net*ServiceAccount APIS for Managed Service Accounts
Add-Type -Namespace LmAccess -Name Native -MemberDefinition @'
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "NetAddServiceAccount")]
private static extern int NativeNetAddServiceAccount(
IntPtr ServerName,
string AccountName,
IntPtr Password,
AddServiceFlags Flags);
/// <summary>Add a sMSA or gMSA to the current host.</summary>
/// <param name="accountName">The name of the MSA to install.</param>
@jborean93
jborean93 / libvirt-network.py
Created January 31, 2022 06:24
Libvirt Register Network DNS Server
#!/usr/bin/python
import os.path
import subprocess
import sys
import xml.etree.ElementTree as ET
def main():
iface = sys.argv[1]
hook_case = sys.argv[2]
@jborean93
jborean93 / Kerberos.cs
Created December 16, 2021 00:17
C# Kerberos API stubs
using System;
using System.Runtime.InteropServices;
namespace PSOpenAD
{
internal static partial class Helpers
{
[StructLayout(LayoutKind.Sequential)]
public struct krb5_keyblock
{
@jborean93
jborean93 / Get-PEDetails.ps1
Last active November 10, 2021 20:42
Get Windows PE Header details
# Copyright: (c) 2021, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-PEDetails {
<#
.SYNOPSIS
Parses an executable's PE header.
.DESCRIPTION
Parses the PE Header and extracts the details of a Windows executable.