Skip to content

Instantly share code, notes, and snippets.

@ReK42
ReK42 / domain-watch.py
Created March 3, 2025 06:53
AWS Lambda function to monitor a domain registration for changes
import logging
from hashlib import sha256
from json import dumps
from pathlib import Path
import boto3
import whoisit
logger = logging.getLogger()
@ReK42
ReK42 / README.md
Last active July 27, 2023 22:46
Juniper Interface Name Regex

Juniper Interface Name Regex

Basic Matching

^(((irb|vlan|lo0)|(ae|em|me|fxp|ps|demux)[0-9]+|(c?[et][0-9]?|cm|[fgsx]e|[aep]t)-[0-9]+/[0-9]+/[0-9]+(:[0-9]+)?)\.[0-9]+)$

Matching with Named Groups

Raw:

^(?P<ifl>(?P<ifd>(?:lo0|irb|vlan)|(?:ae|em|me|fxp|ps|demux)[0-9]+|(?:c?[et][0-9]?|cm|[fgsx]e|[aep]t)-(?P<fpc>[0-9]+)/(?P<pic>[0-9]+)/(?P<port>[0-9]+)(?::(?P<chan>[0-9]+))?)\.(?P<unit>[0-9]+))$
@ReK42
ReK42 / gencert.sh
Last active July 18, 2023 00:07
BASH OpenSSL Generate Self-Signed Certificate
#!/bin/bash
show_help() {
echo "$(basename "$0") [OPTIONS] COMMONNAME"
echo
echo "Options:"
echo " -h|-?|--help Show this help text"
echo " -p|--path File path to store results, default: ."
echo " -m|--modulus Key modulus (size), default: 2048"
echo " --hash Hash algorithm, default: sha256"
echo " -d|--days Days valid, default: 3650"
@ReK42
ReK42 / README.md
Created June 28, 2023 23:45
Hyper-V Guest Numlock On

Run the following in an elevated Powershell prompt:

New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name InitialKeyboardIndicators -Value 2
Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name InitialKeyboardIndicators -Value 2
@ReK42
ReK42 / README.md
Last active July 27, 2023 22:59
Private ASN Regex

Private ASN Regex

https://www.arin.net/resources/guide/asn/

16-bit Private ASNs (64512 to 65534)

6451[2-9]|645[2-9][0-9]|64[6-9][0-9]{2}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-4]

32-bit Private ASNs (4200000000 to 4294967294)

@ReK42
ReK42 / Visio_ExportPagesAsPNG.vbs
Created April 19, 2023 00:42
Export all non-background pages in the active document as PNG
Public Sub ExportPagesAsPNG()
' Set the export settings
Dim settings As Visio.ApplicationSettings
Set settings = Visio.Application.settings
settings.SetRasterExportResolution (visRasterUsePrinterResolution)
settings.SetRasterExportSize (visRasterFitToSourceSize)
' Prepare the export file paths
Dim basePath As String
Set fso = CreateObject("Scripting.FileSystemObject")
@ReK42
ReK42 / add-routes.bat
Created March 9, 2023 23:43
Windows batch file to add multiple static routes
@echo off
rem #################
rem # Configuration #
rem #################
rem Interface name to search for
set interface=SEARCH STRING
rem Routes in the form "<network>/<mask> <gateway>"
@ReK42
ReK42 / sysprep.sh
Created January 16, 2023 19:02
Rocky Linux 9.1 Sysprep Script
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Stop logging services
echo "Stopping logging service..."
systemctl stop rsyslog
@ReK42
ReK42 / README.md
Last active June 28, 2023 22:11
firewalld internal zone config

1. Installation

Enterprise Linux (RHEL/CentOS/Fedora/Rocky/Alma) has firewalld installed by default.

To install on Debian, run:

apt install firewall
systemctl enable firewalld
systemctl start firewalld
@ReK42
ReK42 / python-windows.sublime-project
Last active August 16, 2022 00:23
Sublime Text Python Virtual Environment Project
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\".\\.env\\Scripts\\python.exe\" -u \"$file\"",
}
],