Skip to content

Instantly share code, notes, and snippets.

@daemonhorn
daemonhorn / PivKey_Taglio_Self-Signed_PIV_Setup.md
Last active August 4, 2024 15:54
PivKey_Taglio_Self-Signed_PIV_Setup

Use a Taglio PivKey smartcard with a self-signed certificate

The default instructions on the PivKey documentation site: https://pivkey.zendesk.com/hc/en-us do not provide any examples for configuring a self-signed certificate in any of the 25 slots. These instructions were tested with the PivKey C910 version, but likely most Taglio variants will work the same way.

Powershell New-SelfSignedCertificate

There is support in powershell 5.1+ on currently supported Windows OS (Server 2012+/Windows 10+) configurations for generating self-signed certificates with a wide variety of configuration parameters, including support for the Microsoft Smart Card Key Storage Provider to generate keys on a smartcard.

@daemonhorn
daemonhorn / Microsoft.PowerShell_profile.ps1
Last active August 10, 2024 23:57
Powershell $profile helper examples
# Place this file in our $profile location and restart powershell.
# e.g.: copy Downloads\example.ps1 $profile
# $profile defaults to $HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
# aka: c:\Users\username\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
# If you want to sign it see function `user-sign-psscript` below for signing
# This enables the use of:
# set-executionPolicy -ExecutionPolicy AllSigned -Scope CurrentUser
# Or if you don't care about security on Powershell locally, you can ignore local signing, and just use:
# set-executionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
@daemonhorn
daemonhorn / pfsense-airgap-environment.md
Last active May 18, 2024 23:08
PfSense as an air-gapped router

PfSense Air-gapped configuration

In certain environments, it is useful to have a router and firewall between two private vlans. When the WAN interface of PfSense is not able to access the internet (e.g. DNS Resolution, Update Checks, etc.) it can become sluggish to boot and configure. This guide attempts to capture configuration knobs that can improve the usability in these environments, and was written with PfSense CE 2.7.2 configuration as a baseline.

TODO

  • Finish Documentation
  • tcpdump -nn -i XXX pfsense at steady state air-gapped {for em0 (WAN), em1 (LAN), lo0 (loopback)} Loopback will show you all of the items that would have being queried via root.hints or other pfsense internals. Start with udp port 53 capture filter to look for DNS traffic.
  • tcpdump pfsense at boot with WAN interface to look for extra ntp, dns, http, tls packets

Install

Installation from the PfSense CE ISO file can easily be done in these environments. Download the ISO from mirror (to avoid creatin

@daemonhorn
daemonhorn / Cloudflare-WARP_Wireguard.md
Last active September 13, 2024 22:56
Cloudflare WARP tunnel via Wireguard client

Cloudflare WARP tunnel via Wireguard client

This example provides a simple configuration for a Debian client to have a Cloudflare tunnel while not installing the official Cloudflare WARP client. Note: Tunnel transport outbound to engage.cloudlflare.com on udp/2408 is default, with a dynamic listening udp port and a fwmark for packet matching by wireguard. Any applicable firewall rules may need to be adjusted.

Install dependancies

sudo apt install openresolv wireguard-tools golang git

Get the latest client from Github and build using go

git clone https://github.com/ViRb3/wgcf.git
@daemonhorn
daemonhorn / FreeBSD Arm64 Qemu.md
Last active October 3, 2023 12:20
FreeBSD-arm64-aarch64 via Qemu from ports

Intro

This Quickstart receipe for Qemu assumes a recent FreeBSD release (stable/13 or newer), and provides an example configuration for running arm64 (aarch64) FreeBSD guest on an amd64 FreeBSD Host. Concepts can be applied to other architectures as desired, but syntax and capabilities will vary.

Dependancies

  • Install qemu pkg install qemu or pkg instal qemu-nox11. Latest pre-built package release as of this writeup is 8.1.0
  • Sufficient disk space (50+GB) on a mounted FreeBSD Host disk (e.g.: /qemu-data in this example)
@daemonhorn
daemonhorn / FreeBSD Ports Cheat Sheet.md
Last active September 9, 2023 19:01
FreeBSD Ports Cheat Sheet and Notes

FreeBSD Ports

Some random FreeBSD Ports information for future me

Configuration file: /etc/make.conf

  • Add BATCH=YES to prevent questions and dialog4ports(1) from slowing you down.

Ports make targets from man ports(7)

  • config to force a configuration display/choice (even if BATCH=YES has been defined)
  • fetch and fetch-recursive to download the source packages if not cached
  • install and reinstall to install and force-reinstall the port and register with package database
  • deinstall to uninstall/remove the port and de-register from package database
  • build-depends-list, run-depends-list, all-depends-list to just list the names of the dependancies
@daemonhorn
daemonhorn / Inkplate10_Example_NOAA_Weather.py
Created July 16, 2023 19:56
Inkplate10_Example_NOAA_Weather
import network
import time
from soldered_inkplate10 import Inkplate
ssid = "My_SSID"
password = "My_Pass"
# Function which connects to WiFi
# More info here: https://docs.micropython.org/en/latest/esp8266/tutorial/network_basics.html
def do_connect():
@daemonhorn
daemonhorn / Example_microsocks_stunnel_freebsd_config.md
Last active March 26, 2024 05:26
Socks5 using Microsocks and Stunnel on FreeBSD

Socks5 proxy using Microsocks and Stunnel on FreeBSD

Configuration information for the Microsocks package on FreeBSD as the existing documentation does not give sufficient details to create a secure configuration flexible enough to use for various use cases. See https://github.com/rofl0r/microsocks for the latest source code and wiki documentation. Note: The user authentication method supported by Microsocks is only plaintext, and is not protected by any layer of encryption. Please be hyper aware and use other layers of protection to secure your socks5 endpoint. (Firewall + TLS encryption with client authentication using something like stunnel).

  • If you want an easy way of doing this, just look at ssh -D localhost:1080 <user@host> instead since SSH provides a native Socks5 tunnel with encryption.
  • You can also use stunnel in socks5 protocol mode without Microsocks since it has native support for protocol = socks. See stunnel documentation here: https://www.stunnel.org/static/stunnel
@daemonhorn
daemonhorn / unifi_nginx.md
Last active September 7, 2024 16:35
Unifi Network Controller and NGNIX Configuration

Create specific folder for certs and allow user to have permission based on group

mkdir /etc/nginx/certs
chmod 770 /etc/nginx/certs
chown root:www-data /etc/nginx/certs
groupmod -a www-data -U dhorn

Add www-data group to sudoers for service (service restart nginx)

echo "%www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/service" >/etc/sudoers.d/20_nginx
@daemonhorn
daemonhorn / bash_tcsh_unified_config.md
Last active January 16, 2024 15:04
Make bash do the nice tcsh things

Overview

I want to forget about differences between my Linux machines (running bash), and my BSD machines (running tcsh), and have user-friendly cli experience. The knobs below will cause bash/readline/less to behave more like tcsh defaults.

  1. Searching through history with filters
echo '"\e[B": history-search-forward' >>~/.inputrc
echo '"\e[A": history-search-backward' >>~/.inputrc
  1. Pager re-init and thus manpages causing screen to clear on quit