Skip to content

Instantly share code, notes, and snippets.

@rufflabs
rufflabs / Get-Hash
Created May 23, 2015 14:38
Gets the hash of a file, useful for versions of PowerShell before the built in commandlet.
function Get-Hash {
param(
[Parameter(Position=0,Mandatory=$true)]$Path
)
# Load crypto library if needed
if(([AppDomain]::CurrentDomain.GetAssemblies() | ? {$_ -Match 'System.Security'}) -eq $Null) {
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
}
@rufflabs
rufflabs / Set-ADLogonHours.ps1
Created December 4, 2015 16:34
Sets logon hours for AD users to unrestricted.
# Create a HashTable for logonHours, contents is a byte array.
# The code given by AD Admin Center's PowerShell History does not appear to work, but this does.
$logonHours = @{"logonHours" = [byte[]]$hours=@(255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255)}
Set-ADUser $User -Replace $logonHours
@rufflabs
rufflabs / Report-UnprotectedVMs.ps1
Created January 20, 2016 02:11
Emails a report of VM's that aren't assigned a backup policy tag in vCenter.
Add-PSSnapin VMware.VimAutomation.Core
Set-PowerCliConfiguration -InvalidCertificateAction Ignore -Confirm:$False
Connect-VIServer $vCenterServer
# vCenter hostname
$vCenterServer = ''
$smtpServer = ''
# Email report from address
Import-Module ActiveDirectory
Import-Module DhcpServer
Import-Module PSReadLine
Add-PsSnapin VMware.VimAutomation.Core
Add-PSSnapin VeeamPSSnapIn
##
# Authenticode Signing
##
@rufflabs
rufflabs / PSService.ps1
Created April 15, 2021 13:48
PSService.ps1
###############################################################################
# #
# File name PSService.ps1 #
# #
# Description A sample service in a standalone PowerShell script #
# #
# Notes The latest PSService.ps1 version is available in GitHub #
# repository https://github.com/JFLarvoire/SysToolsLib/ , #
# in the PowerShell subdirectory. #
# Please report any problem in the Issues tab in that #
Add tun0 IP to top panel in Kali
1. Right click top panel and choose Add
2. Add a Generic Monitor
3. Right click the new monitor in the panel and choose Properties
4. Label as "tun0: " and enter the following for the command to run:
bash -c 'base64 -d <<< aXAgYSBzIHR1bjAgfCBncmVwICJpbmV0ICIgfCBhd2sgJ3twcmludCAkMn0nIHwgc2VkICdzL1wvLiovL2cn | bash'
This is piping the below base64 encoded command to bash. Without the base64 encoding, the pipes and parameters caused errors for me in the panel:
@rufflabs
rufflabs / Fix-BootHole.ps1
Last active May 25, 2023 20:08
Applies BootHole UEFI fixes, requires some editing.
<#
.SYNOPSIS
Applies UEFI dbx updates to fix BootHole vulnerability.
.DESCRIPTION
Applies the UEFI dbxupdates to fix the BootHole vulnerability. Prior to running,
edit this script to choose between Embedded files or link to a file share.
See https://www.rufflabs.com/post/nessus-plugin-139239-remediating-boothole-windows/
.EXAMPLE
@rufflabs
rufflabs / mount-shared-folders.sh
Created December 14, 2022 02:25
Kali's mount-shared-folders script to mount VMware shared folders.
#!/bin/sh
test $(id -u) -eq 0 || { echo "Please call this script with sudo" >&2; exit 1; }
vmware-hgfsclient | while read folder; do
vmwpath="/mnt/hgfs/${folder}"
echo "[i] Mounting ${folder} (${vmwpath})"
mkdir -p "${vmwpath}"
umount -f "${vmwpath}" 2>/dev/null
vmhgfs-fuse -o allow_other -o auto_unmount ".host:/${folder}" "${vmwpath}"
done
sleep 2s