Skip to content

Instantly share code, notes, and snippets.

View codeskipper's full-sized avatar

Martinus Verburg codeskipper

  • Datamind AS
View GitHub Profile
@codeskipper
codeskipper / ntlm-hash.py
Created February 27, 2024 14:00
create NTLM hash from Mac pasteboard secret and copy to pasteboard
#!/usr/bin/python3
## ntlm-hash.py
# create a NTLM hash from user input (or input redirect)
# thanks to https://stackoverflow.com/a/15603809
# usage:
# - put this content in ~/dev/ntlm-hash.py
# - append next line (without comment) to ~/.zprofile
# alias 2ntlm="pbpaste | /usr/bin/python3 ~/dev/ntlm-hash.py | pbcopy"
# source ~/.zprofile
@codeskipper
codeskipper / gist:23a1f46b6228fd2cb09d1777c0f52408
Last active March 13, 2021 17:29
macOS - bash/python - Check for user presence at console by checking for screen lock and console login status (must run locally by logged in account)
#!/bin/bash
# Check for user presence at console by checking for screen lock and console login status
# Thanks to https://stackoverflow.com/users/908494/abarnert at
# https://stackoverflow.com/a/11511419/4326287
# Wait until console is logged in and screen is unlocked
while true ;
do
timestamp=$(date +%Y-%m-%dT%H:%M:%S%z)
python -c 'import sys,Quartz; d=Quartz.CGSessionCopyCurrentDictionary(); sys.exit(d and d.get("CGSSessionScreenIsLocked", 0) == 0 and d.get("kCGSSessionOnConsoleKey", 0) == 1)'
@codeskipper
codeskipper / gist:3a57a5809b561599663fbb584537bd2a
Last active March 13, 2021 15:39
macOS - python - Detect active user at console (must run locally)
#!/usr/bin/python
# Check for user presence at console by checking for screen lock and console login status
# Thanks to https://stackoverflow.com/users/908494/abarnert at
# https://stackoverflow.com/a/11511419/4326287
import sys
import Quartz
from datetime import datetime
from dateutil.tz import tzlocal
import time