Skip to content

Instantly share code, notes, and snippets.

View SpareSimian's full-sized avatar

SpareSimian

  • San Pablo, CA, US
View GitHub Profile
@SpareSimian
SpareSimian / tar-compress-encrypt-verify.sh
Created January 10, 2025 23:14
Tar, compress, and encrypt a directory hierarchy
# commands used to encrypt a filesystem image
# create the encryption key (256 bits in hex)
openssl rand -hex 32 > /root/aes_key.txt
# move to top of desired filesystem to backup and encrypt
cd /mnt/root-to-back-up
# Tar using xz compression and pipe to AES256 encryption
tar cvfJ - . | openssl enc -aes-256-cbc -e -pass file:/root/aes_key.txt -out /mnt/USB-thumb-drive/encrypted-backup.tar.xz
@SpareSimian
SpareSimian / mimedefang-filter-discard-backup.pl
Created December 17, 2024 18:51
MIMEDefang milter extract: Discard spam from backup MX
use Net::DNS;
# GetHostAddresses(resolver,hostname)
# returns list of IP addresses for hostname
sub GetHostAddresses ($$) {
my ($resolver,$hostname) = @_;
my @addresses;
my $received = $resolver->search($hostname);
if ($received) {
@SpareSimian
SpareSimian / build-debian-package.md
Last active May 28, 2024 01:20
Building a Debian package

Building a Debian package

The following assumes a user named "builder" will be created to build packages.

  • Create a Debian instance
  • Update package database: apt-get update
  • Install basic build system: apt-get install build-essential fakeroot devscripts
  • Create mortal to build package and add to sudoers: adduser builder
  • Add mortal to sudoers: usermod -aG sudo builder
  • Allow mortal to sudo without password (optional): Create /etc/sudoers.d/builder-nopasswd containing: builder ALL=(ALL) NOPASSWD:ALL
@SpareSimian
SpareSimian / WoWAddonMinimalPackager
Last active April 7, 2024 00:07
WoW addon automatic release generation for WoWUp addon manager
Minimal steps to publish a World of Warcraft addon for use by multiple addon updaters.
Start by installing a simple GitHub "workflow". This describes a
GitHub action that will be invoked when you push an annotated tag to
your repository. The action will spawn a virtual machine and run a
script that checks out your addon, zips it up in a format suitable
for various addon updater programs, and creates a GitHub "Release".
You can grab a minimal version of this file here:
@SpareSimian
SpareSimian / netstats2lcd.py
Last active May 25, 2023 09:23
Display interface bit rates on Adafruit LCD display for eth0 and eth1
import copy
import time
import Adafruit_CharLCD as LCD
ifstats = {
"eth0": { "tx": 0, "rx": 0 },
"eth1": { "tx": 0, "rx": 0 }
}
ifnames = [ "eth0", "eth1" ]
@SpareSimian
SpareSimian / asntoipset.py
Created November 30, 2022 01:52
Convert a list of records from iptoasn.com to a firewalld ipset XML file.
#!/usr/bin/env python3
""" Convert a list of records from iptoasn.com to a firewalld ipset XML file.
Download https://iptoasn.com/data/ip2asn-v4.tsv.gz, uncompress, filter
with grep, and feed to this script to generate a file to place in
/etc/firewalld/ipsets for use in firewall rules.
Example:
wget -q -O - https://iptoasn.com/data/ip2asn-v4.tsv.gz | \
@SpareSimian
SpareSimian / dumpFail2bans.pl
Last active October 9, 2022 17:51
List bans in fail2ban database
#!/usr/bin/perl -T -w
# dump current fail2ban bans for all jails in jail order, for use in
# daily emailed reports
use strict;
use DBI;
sub formatBantime {
my $banDurationSeconds = $_[0];
@SpareSimian
SpareSimian / isc-leases-to-json.pl
Created March 7, 2022 03:57
Convert ISC dhcpd.leases file to JSON
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
use experimental qw(switch);
my %leases;
my %current_lease;
my $current_lease_ip;
@SpareSimian
SpareSimian / BuildAllVC16.cmd
Created April 11, 2021 18:08
Build all variants of wxWidgets for Visual Studio 2019
@rem build all variations for VC16
@rem if running on 32 bit, we need to use the cross compiler for 64 bit
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set "OSWIDTH=32BIT" || set "OSWIDTH=64BIT"
if "%OSWIDTH%"=="32BIT" set VSAMD64=x86_amd64
if "%OSWIDTH%"=="64BIT" set VSAMD64=amd64
if "%OSWIDTH%"=="" exit /B 1
@echo using %VSAMD64% for 64 bit builds
@SpareSimian
SpareSimian / ipdeny-to-NonUS.py
Created August 2, 2019 20:25
Non-US ipset from whois database via ipdeny website
#!/usr/bin/env python
# See http://www.ipdeny.com/ipblocks/
# allow function-like print when using Python 2
from __future__ import print_function
import argparse
import requests
import io