Skip to content

Instantly share code, notes, and snippets.

@jborean93
jborean93 / PowerShell Certificate Signing.md
Last active Jan 5, 2021
Behaviour of signed PowerShell scripts
View PowerShell Certificate Signing.md

PowerShell Code Signing

This is to try and document the behaviour around PowerShell code signing.

Setup

The following code can be used to set up this scenario. This must be run as an administrator in Windows PowerShell.

Note: PowerShell uses implicit remoting for the New-SelfSignedCertificate which breaks the constains serialization. You must run this on Windows PowerShell.

@jborean93
jborean93 / New-PSSessionLogger.ps1
Last active Dec 21, 2020
Log PSRP packets to a file and subsequently parse them into rich PSObjects
View New-PSSessionLogger.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Add-Type -TypeDefinition @'
using System;
using System.IO;
using System.IO.Pipes;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Threading;
@jborean93
jborean93 / Get-SSHAgentKey.ps1
Created Oct 13, 2020
Extract SSH keys from ssh-agent for the current user
View Get-SSHAgentKey.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Find-InArray {
<#
.SYNOPSIS
Finds the index of a byte[] in a byte[].
#>
[CmdletBinding()]
param (
@jborean93
jborean93 / smb_security_descriptor.py
Created Oct 1, 2020
How to get the security descriptor of a file/dir using smbprotocol
View smb_security_descriptor.py
import smbclient
from smbprotocol.file_info import (
InfoType,
)
from smbprotocol.open import (
DirectoryAccessMask,
FilePipePrinterAccessMask,
SMB2QueryInfoRequest,
@jborean93
jborean93 / setup.sh
Created Sep 15, 2020
ansible-galaxy collection update scenarios
View setup.sh
#!/usr/bin/env bash
set -o pipefail -eu
function create_package {
name="${1}"
version="${2}"
requirements="${3:-}"
if [ ! -z "${requirements}" ]; then
@jborean93
jborean93 / New-EXOPSSession.ps1
Last active Aug 21, 2020
Cross platform function that can connect to Exchange Online using modern auth
View New-EXOPSSession.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
#Requires -Module MSAL.PS
Function New-EXOPSSession {
<#
.SYNOPSIS
Will open a PSSession to Exchange Online.
@jborean93
jborean93 / ConvertFrom-IndirectString.ps1
Created Aug 13, 2020
Converts an indirect string to the actual string value
View ConvertFrom-IndirectString.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function ConvertFrom-IndirectString {
<#
.SYNOPSIS
Converts a indirect string identifier to the actual string value it represents.
.PARAMETER IndirectString
The indirect string that begins with '@' to convert to the proper string value.
@jborean93
jborean93 / Get-FtpFile.ps1
Created Aug 12, 2020
Gets a file from an FTP server
View Get-FtpFile.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Get-FtpFile {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[System.Uri]
[Alias('Uri')]
$FtpUrl,
@jborean93
jborean93 / Get-WindowsUpdate.ps1
Created Aug 4, 2020
Output a list of updates based on the criteria that you define
View Get-WindowsUpdate.ps1
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Write-WUAError {
<#
.SYNOPSIS
Convert raw HRESULT codes to a human readable error.
.PARAMETER Exception
The COMException that the error code is from.
@jborean93
jborean93 / runtime_checker.py
Last active Jul 29, 2020
Checks Ansible's ansible_builtin_runtime.yml for any missing or extra plugin entries
View runtime_checker.py
#!/usr/bin/env python3
import asyncio
import json
import os
import subprocess
import sys
import tempfile
import yaml
You can’t perform that action at this time.