Skip to content

Instantly share code, notes, and snippets.

View Chaz6's full-sized avatar

Chris Hills Chaz6

View GitHub Profile
@Chaz6
Chaz6 / readme.md
Last active February 19, 2026 23:27
How to replace UEFI Secure Boot certificates in VMware

Custom Secure Boot configuration while deploying a new Virtual Machine

The Secure Boot configuration is stored in NVRAM. If the NVRAM contains no Secure Boot configuration (a freshly deployed VM, or a VM for which the .nvram file has been deleted from the datastore), the Secure Boot configuration will be reset to the defaults described in the UEFI Specification (the variables named PKDefault, KEKDefault, dbDefault and dbxDefault). You can use advanced VM config options to control those defaults, through which you can pre-populate the Secure Boot configuration before the VM is first powered on.

If you want to deploy the certificates as part of the VM's configuration, copy the DER-encoded certificate into the VM's directory and add the following advanced VM config options:

uefi.secureBoot.dbDefault.file0 = "custom-cert.der"

where "custom-cert.der" is the name of the DER-encoded certificate file within the VM's directory. You can repeat that for file1, file2, file3, etc., to add multiple certificate

#!/bin/bash
/usr/bin/certbot renew
if test $(find /etc/letsencrypt/live/unifi.example.com/cert.pem -mmin -60)
then
/bin/systemctl stop unifi.service
/usr/bin/openssl pkcs12 -export -inkey /etc/letsencrypt/live/unifi.example.com/privkey.pem -in /etc/letsencrypt/live/unifi.example.com/fullchain.pem -out /tmp/unifi.example.com.p12 -name ubnt -password pass:temppass
/bin/keytool -importkeystore -deststorepass aircontrolenterprise -destkeypass aircontrolenterprise -destkeystore /opt/UniFi/data/keystore -srckeystore /tmp/unifi.example.com.p12 -srcstoretype PKCS12 -srcstorepass temppass -alias ubnt -noprompt
/bin/rm -f /tmp/unifi.example.com.p12
@Chaz6
Chaz6 / make-datamatrix-label-pdf.py
Last active June 13, 2025 20:11
Generate a datmatrix label from input
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "ppf.datamatrix",
# "reportlab",
# "setuptools",
# ]
# ///
@Chaz6
Chaz6 / make-datamatrix-asset-labels.py
Last active June 13, 2025 20:11
Generate random datamatrix codes for asset labels
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "ppf.datamatrix",
# "reportlab",
# "setuptools",
# "shortuuid",
# ]
# ///
@Chaz6
Chaz6 / daytime_server.rs
Created July 3, 2024 14:05
daytime server in rust
use chrono::Local;
use std::io::Write;
use std::net::{TcpListener, TcpStream};
fn handle_client(mut stream: TcpStream) {
let dt = Local::now().to_utc();
stream.write_all(dt.to_string().as_bytes()).unwrap();
stream.shutdown(std::net::Shutdown::Both).unwrap();
}
@Chaz6
Chaz6 / Cargo.toml
Created June 20, 2024 18:04
SHAllenge in Rust
[package]
name = "shallenge"
version = "0.1.0"
edition = "2021"
[dependencies]
sha2 = "0.11.0-pre.3"
@Chaz6
Chaz6 / build-llvm-on-almalinux.bash
Last active April 14, 2024 15:24
build-llvm-on-almalinux.bash
#!/usr/bin/bash
LLVM_VERSION=18.1.3
LLVM_VERSION_BETA=
PREFIX=$HOME
if [ -n "$LLVM_VERSION_BETA" ]; then
FILENAME="llvm-project-${LLVM_VERSION}${LLVM_VERSION_BETA}.src.tar.xz"
INSTALL_PREFIX="$PREFIX/.local/local/llvm-${LLVM_VERSION}${LLVM_VERSION_BETA}"
@Chaz6
Chaz6 / build-python-on-almalinux.bash
Created April 14, 2024 15:20
build-python-on-almalinux.bash
#!/usr/bin/bash
PYTHON_VERSION=3.13.0
BETA_VERSION=a6
INSTALLDIR="${HOME}"/.local/local
cd /tmp &&
wget -4 "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
echo "Extracting archive..." &&
tar xvf "Python-${PYTHON_VERSION}${BETA_VERSION}.tar.xz" &&
@Chaz6
Chaz6 / update-weechat-ssl-letsencrypt.bash
Last active August 22, 2022 11:35
Script to update weechat relay ssl certificate using LetsEncrypt
#!/bin/bash
/usr/bin/certbot renew
if /usr/bin/test $(find /etc/letsencrypt/live/weechat.example.com/cert.pem -mmin -60)
then
/bin/cat /etc/letsencrypt/live/weechat.example.com/cert.pem /etc/letsencrypt/live/weechat.example.com/privkey.pem > /home/user/.weechat/ssl/weechat.example.com_ssl.pem
/bin/cat /etc/letsencrypt/live/weechat.example.com/fullchain.pem > /home/user/.weechat/ssl/weechat.example.com_fullchain.pem
/usr/bin/su -c 'echo "*/relay sslcertkey" > /home/user/.weechat/weechat_fifo_*' user
fi
@Chaz6
Chaz6 / jnh_exception_packet_trace.rb
Created May 19, 2022 12:05 — forked from ytti/jnh_exception_packet_trace.rb
script to turn JunOS Trio exception capture into a PCAP
#!/usr/bin/env ruby
# script to generate PCAP from Trio exception trace. Potentially you may need to change POP_BYTES variable.
# Trio exception trace allows you to capture things like broken packets (checksum error), to see who is sending them
# clogin junos-trio-box | tee exception_trace
# start shell pfe network fpc0
# show jnh 0 exceptions terse
# debug jnh exceptions N discard ## get N from above command
# debug jnh exceptions-trace