Skip to content

Instantly share code, notes, and snippets.

View h0tw1r3's full-sized avatar
🏝️
Living the dream

Jeffrey Clark h0tw1r3

🏝️
Living the dream
View GitHub Profile
@h0tw1r3
h0tw1r3 / redirect-test.sh
Created January 4, 2026 02:18
bash redirect all output to a script
#!/bin/bash
# prefix all output with a timestamp
exec > >(perl -pe 'use POSIX qw(strftime); print strftime("[%Y-%m-%d %H:%M:%S] ", localtime)')
exec 2> >(perl -pe 'use POSIX qw(strftime); print strftime("[%Y-%m-%d %H:%M:%S] ", localtime)' >&2)
echo "This goes to stdout :)"
echo >&2 "This goes to stderr :("
@h0tw1r3
h0tw1r3 / rsa_pkey_decrypt.pl
Last active October 16, 2025 13:32
decrypt rsa private key with just perl
#!/usr/bin/env perl
use strict;
use warnings;
use Net::SSLeay;
# Check for the correct number of command-line arguments
unless (@ARGV == 3) {
die "Usage: perl $0 <encrypted_key_file> <passphrase_file> <decrypted_key_file>\n";
}
@h0tw1r3
h0tw1r3 / procs.sh
Created September 17, 2025 17:17
how to get a linux process list when the ps command isn't available
for x in /proc/*/cmdline; do echo -n "${x#/proc/}: "; cat $x; echo; done
@h0tw1r3
h0tw1r3 / nginx.conf
Created September 4, 2025 20:00
nginx mail proxy in front of mta submission server (no auth) with STARTTLS required
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
env RELAY_HOST;
env RELAY_PORT;
@h0tw1r3
h0tw1r3 / fix-openscap-report.py
Last active March 8, 2025 14:21
Fix openscap report, externalize all inline scripts and stylesheets
#!/usr/bin/env python3
# * finds all inline style and script elements in an html file
# exports the code into a file (ie. filename.css, filename.js)
# removes the original tag from the html
# * replaces inline styles and scripts with tags in the header
# sourcing the new external code
# disable tracebacks
@h0tw1r3
h0tw1r3 / genkey.sh
Last active September 17, 2024 15:43
Generate GPG key for signing packages, export keys and generate public keyring
#!/bin/sh
set -eo nounset
export GNUPGHOME="$(mktemp -d)"
trap 'cleanup' EXIT
cleanup() { rm -Rf "$GNUPGHOME" ; }
export NAME_REAL="Signing Key"
@h0tw1r3
h0tw1r3 / disable_verification.py
Created September 6, 2024 00:13
python globally disable requests ssl verification
import requests
def disable_request_verification():
requests.urllib3.disable_warnings()
old_init = requests.Session.__init__
def new_init(self, *k, **kw):
old_init(self, *k, **kw)
self.verify = False
@h0tw1r3
h0tw1r3 / asyncsubprocess.py
Created September 3, 2024 04:38
python async subprocess example module with stdout and stderr support
#!/usr/bin/env python3
import collections
import asyncio
import sys
class AsyncSubProcess:
def __init__(self, program, *args, env={}, output=True, cwd=None):
self.proc = None
@h0tw1r3
h0tw1r3 / Dockerfile
Last active August 31, 2024 04:05
base alpine dockerfile with fips support
# syntax=docker/dockerfile:1.6
ARG BUILD_OS_TAG
FROM alpine:${BUILD_OS_TAG} as build
ARG BUILD_OS_TAG
RUN apk add --no-cache alpine-sdk doas \
&& echo 'permit nopass :wheel' >> /etc/doas.conf
RUN adduser -D build \
ifeq (${MAKELEVEL},0)
export SCRATCH := $(shell mktemp -d ./.tmp_XXXXXXXX)
$(info Launching clean up task for ${SCRATCH})
$(shell bash -c "set -m ; trap 'rm -rvf ${SCRATCH};' EXIT; lsof -p $$PPID +r 1;" </dev/null >/dev/null 2>/dev/null & disown)
endif