Skip to content

Instantly share code, notes, and snippets.

View samuelwilliams's full-sized avatar

Sam Williams samuelwilliams

View GitHub Profile
@samuelwilliams
samuelwilliams / uuid.php
Last active August 4, 2021 10:32
Generates a UUID in 8-4-4-4-12 notation
<?php
function uuid() {
$s = bin2hex(random_bytes(16));
return sprintf('%s-%s-%s-%s-%s',
substr($s, 0, 8),
substr($s, 8, 4),
substr($s, 12, 4),
substr($s, 16, 4),
@samuelwilliams
samuelwilliams / UpdateLocalCredentials.ps1
Created September 9, 2020 03:15
Update local credentials of remote machines.
#Small object to simplify the handling of credentials.
class CredObject {
$Name
$Ip
$Username
$Password
}
#Change to full path of the credentials file with columns: Name, Ip, Username, Password
$machines = Import-CSV -Path "\path\to\machines.csv"
@samuelwilliams
samuelwilliams / HelperCommands.ps1
Created September 9, 2020 03:03
List of helpful powershell commands
#Get the local accounts on a machine
Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='$True'" | Select-Object Name, Disabled
@samuelwilliams
samuelwilliams / UpdatePasswordsOnDC.ps1
Created September 9, 2020 02:57
Update user passwords on a domain controller.
#Small object to make the handling of credentials simpler.
class CredObject {
$Username
$Password
}
#Create the session to the domain controller.
$dcSession = Create-Session -Ip 10.0.0.10 -Username "Administrator" -Password "MyVerySecurePassword"
#Get all the users who aren't the Administrator
Function Show-ProcessTree {
[CmdletBinding()]
Param($allprocess)
Begin {
# Identify top level processes
# They have either an identified processID that doesn't exist anymore
# Or they don't have a Parentprocess ID at all
#$allprocess = Get-WmiObject -Class Win32_process
$uniquetop = ($allprocess).ParentProcessID | Sort-Object -Unique
@samuelwilliams
samuelwilliams / less-cheatsheet.md
Created January 29, 2020 02:33 — forked from glnds/less-cheatsheet.md
Less Cheatsheet

Less Cheatsheet

less {filename}
Navigation
SPACE forward one window
b backward one window
d forward half window
@samuelwilliams
samuelwilliams / example.php
Created September 30, 2019 07:29
Badcow DNS Parse Comments
<?php
use Badcow\DNS\Parser\Parser;
use Badcow\DNS\ZoneBuilder;
require_once __DIR__ . '/../vendor/autoload.php';
$example = <<< 'DNS'
$ORIGIN example.com.
$TTL 1337
@samuelwilliams
samuelwilliams / gist:b08bbdc978cce86582bd
Created February 15, 2016 07:43
Browser Bookmarklet to show passwords on a webpage
javascript:(function(){var a=document.getElementsByTagName('input');for(var i=0,e;e=a[i];i++)if(e.getAttribute('type')=='password')e.setAttribute('type', 'text');})()
@samuelwilliams
samuelwilliams / batch_dload.bash
Created October 18, 2015 09:35
Simple script to batch download sequential files.
#!/usr/bin/env bash
PREFIX='http://example.com/gallery/pic_'
SUFFIX='.jpg'
START=1
END=25
FORMAT="%02d"
for i in `seq $START $END`;
do
sh$ ffmpeg -i file.flac -b:a 256k file.mp3
sh$ for f in *.flac;do ffmpeg -i $f -b:a 256k $f.mp3;done
sh$ for f in *.m4a; do ffmpeg -i "$f" -acodec libmp3lame -ab 256k "${f%.m4a}.mp3"; done