Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jborean93 on github.
  • I am jborean93 (https://keybase.io/jborean93) on keybase.
  • I have a public key ASBK396SPyaXDgm1YsnDbsIuacm8LKPknZa0C4omPUU8SAo

To claim this, I am signing this object:

@jborean93
jborean93 / shadow-copy-deviceiocontrol.ps1
Created March 20, 2019 01:44
Use DeviceIoControl to enumerate shadow copies
<#
This does not work due to the unsupported CTL_CODE used in DeviceIoControl
DeviceIoControl() get buffer size failed - Incorrect function (Win32 ErrorCode 1 - 0x00000001)
At C:\temp\enumerate_snapshots.ps1:145 char:1
+ Get-ShadowCopy -Path "\\localhost\c$"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ShadowCopy
#>
@jborean93
jborean93 / Get-ProcessSessionStationAndDesktop.ps1
Last active May 3, 2019 09:34
Get process session, station, and desktop
Add-Type -TypeDefinition @'
using System;
using System.Runtime.InteropServices;
namespace ProcessInfo
{
public class NativeMethods
{
[DllImport("User32.dll", SetLastError = true)]
public static extern bool CloseDesktop(
@jborean93
jborean93 / Remove-LongPath.ps1
Last active August 8, 2019 23:23
Deletes files and folders that exceed max path
Add-Type -TypeDefinition @'
using Microsoft.Win32.SafeHandles;
using System;
using System.IO;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace FileIO
{
public class NativeHelpers
@jborean93
jborean93 / PSRunas.psm1
Last active December 23, 2019 05:22
Quick and dirty PowerShell module that implements Start-Process using CreateProcessWithToken
# Copyright: (c) 2019, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
$pinvokeParams = @{
IgnoreWarnings = $true
WarningAction = 'Ignore'
TypeDefinition = @'
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections;
@jborean93
jborean93 / Get-ItemWithCredential.ps1
Created February 3, 2020 03:21
Basic example of how to access network paths with custom credentials
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Add-Type -Namespace LogonUtil -Name NativeMethods -MemberDefinition @'
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern bool CloseHandle(
IntPtr hObject);
[DllImport("Advapi32.dll", SetLastError = true)]
public static extern bool ImpersonateLoggedOnUser(
@jborean93
jborean93 / shippable-target-time.py
Last active March 3, 2020 17:52
Simple script that turns the test.json output of https://github.com/ansible/ansible/blob/devel/hacking/shippable/download.py to a easy to view table of test target runtimes
#!/usr/bin/env python
import json
import operator
import os
def get_raw_test_targets(test_path):
with open(test_path, mode='rb') as fd:
test_info = json.loads(fd.read().decode('utf-8'))
@jborean93
jborean93 / ansible_migrate.py
Created March 11, 2020 04:59
Python script to help with migrating issues and PRs from ansible/ansible to a target collection.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# PYTHON_ARGCOMPLETE_OK
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
"""
Script that can be used to copy issues and PRs from the Ansible GitHub repo to it's target collection repo. Current
limitations are;
@jborean93
jborean93 / Install-Driver.ps1
Created March 22, 2020 03:07
Installs a driver from an .inf file.
# Copyright: (c) 2020, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
Function Install-Driver {
<#
.SYNOPSIS
Install a driver from an .inf.
.DESCRIPTION
Long description
@jborean93
jborean93 / parse_negotiate_token.py
Last active March 28, 2020 03:04
Parse a raw Negotiate authentication token and create an easy to understand dict of it's key/values
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# PYTHON_ARGCOMPLETE_OK
# Copyright: (c) 2018, Jordan Borean (@jborean93) <jborean93@gmail.com>
# MIT License (see LICENSE or https://opensource.org/licenses/MIT)
"""
Script that can be used to parse a Negotiate token and output a human readable structure. You can pass in an actual
SPNEGO token or just a raw Kerberos or NTLM token, the script should be smart enough to detect the structure of the