Skip to content

Instantly share code, notes, and snippets.

View amigus's full-sized avatar

Adam Migus amigus

View GitHub Profile
@amigus
amigus / DNSMASQ-database.md
Last active September 8, 2024 01:18
Dnsmasq Lease Database

Dnsmasq Lease Database

A dhcp-script for Dnsmasq that makes it manage DHCP lease information in an SQLite database.

What is it?

Dnsmasq has a dhcp-script configuration parameter. When set, Dnsmasq invokes the script whenever DHCP lease information changes. When combined with leasefile-ro it fully replaces the leases file.

@amigus
amigus / smb.conf
Created March 17, 2024 15:33
Minimal smb.conf
# A minimal configuration using non-default settings
[global]
log level = auth:6 idmap:6
map to guest = Bad User
restrict anonymous = 1
use sendfile = Yes
[root$]
path = /srv/smb
inherit permissions = Yes
browsable = No
@amigus
amigus / harden-kali.sh
Last active December 18, 2023 07:10
Kali (so mostly Debian) Hardening Script
#!/bin/sh
UMASK=027
TIMEZONE='EST'
# set the timezone *before* creating a bunch of logs 🕛✅
timedatectl set-timezone $TIMEZONE
# update and fire up sshguard first 🔥
apt -y update
@amigus
amigus / Microsoft.PowerShell_profile.ps1
Last active May 24, 2024 21:19
Microsoft PowerShell $PROFILE
Invoke-Expression (&{
curl -Ls https://gist.githubusercontent.com/amigus/555b34d0b1c872c33f3fee55c7ed17e9/raw/ByteCalculationFunctions.ps1
oh-my-posh init -s pwsh
zoxide init --cmd 'cd' powershell
} | Out-String)
Import-Module posh-git, PSfzf, Terminal-Icons
Enable-PoshToolTips
Set-PSReadLineOption -EditMode Windows -PredictionSource History -HistoryNoDuplicates
@amigus
amigus / Create-VM.ps1
Last active February 3, 2024 21:41
Create a Generation 2 Hyper-V VM easily with reasonable defaults.
<#
.SYNOPSIS
Easily create a new Gen 2 Hyper-V VM with reasonable defaults.
.DESCRIPTION
Easily create a Generation 2 VM using a VHD or ISO image.
The defaults are also meant to be "reasonable in most cases," so as to allow
@amigus
amigus / WiZBulbFunctions.ps1
Last active September 28, 2024 00:15
Functions to mess with Philips WiZ Smart Bulbs
<#
.SYNOPSIS
Controls WiZ lightbulbs.
.DESCRIPTION
I want to control my lightbulbs. These functions allow me to do that.
.EXAMPLE
# Get the current state of all bulbs on the first network with a gateway
Get-WiZBulb
.EXAMPLE
# Get the current state of all bulbs on the specified network interface
@amigus
amigus / Install-NerdFonts.ps1
Created October 29, 2023 16:17
Install Nerd Fonts directly from the downloaded ZIP files
<#
.SYNOPSIS
Install the 'Regular' fonts in Nerdfonts ZIP files
.DESCRIPTION
Extract NerdFont Zip files into a temporary directory and install the fonts
the fonts matching '-Regular' while filtering out the '-Mono' and '-Propo'
variants.
.EXAMPLE
@amigus
amigus / OpenSSLSubordinatetoMicrosoftCA.md
Last active October 29, 2023 00:10
An OpenSSL setup to generate a subordinate CA to Microsoft Certificate Services

OpenSSL Subordinate to Microsoft Root CA

Generate a Certificate Request

OpenSSL installs a default configuration file in /etc/ssl/openssl.cnf. The configuration defines a (boilerplate) v3_ca section. We can use it to generate a subordinate CA certificate request, a.k.a., a CSR, for Microsoft Certificate Services by executing:

@amigus
amigus / ByteCalculationFunctions.ps1
Last active November 26, 2024 21:11
Byte Calculation Functions; use: Invoke-Expression (&{curl -Ls https://mig.us/bcfps1 | Out-String}); (44040192 | bytesfromk | bytestogigs)
function ConvertFrom-BytesByFactor {
[CmdletBinding()]
param(
[Parameter(Mandatory)][int]$Factor,
[Parameter(Mandatory, ValueFromPipeline)][Int64]$Amount
)
process {
Write-Debug ("Rounding the result of $Amount * 1024 ^ $Factor")
[Convert]::ToInt64([Math]::Round($Amount * [Math]::Pow(1024, $Factor)))
}
@amigus
amigus / Makefile
Last active February 20, 2024 15:31
OpenLDAP 2.4.x configuration
CONF := /etc/openldap
BACKUP := $(CONF)/backup.ldif
DATA := $(CONF)/slapd.d
LIB := /var/lib/ldap
LDIF := ./data.ldif
INPUT := ./slapd.conf.custom
GROUP := ldap
OWNER := root