Skip to content

Instantly share code, notes, and snippets.

@Caligatio
Caligatio / dyndns_cloudflare
Last active March 29, 2023 12:47
Dynamic DNS script to detect and update A, AAAA, and HTTPS (with ipv4hint and ipv6hint) records at Cloudflare
#!/usr/bin/python3
"""
dyndns_cloudflare
This is a Python 3.8+ script that will attempt to identify a computer's external IPv4 and "static" (non RFC 4941) IPv6
addresses to then update Cloudflare DNS entries. It currently supports A, AAAA, and the new HTTPS DNS record types. For
HTTPS records, it will embed the "ipv4hints" and "ipv6hints" values into the record along with the ALPN specified in the
config. It has optional support for saving the IPv4 and IPv6 addresses from the last run of the program to avoid
unnecessary updates.
**Note that it only updates DNS records: the records must already exist and it will not delete any records. If you add more
@Caligatio
Caligatio / caddy_autoupgrade
Created April 8, 2021 05:07
This is a simplistic Python 3.8+ script that will download the latest available version of Caddy (with plugins!), compare to the existing Caddy, and will replace/upgrade if the downloaded version is different. It also has rudimentary systemd support to stop and restart the service after upgrade.
#!/usr/bin/env python3
"""
caddy_autoupgrade
This is a simplistic Python 3.8+ script that will download the latest available version of Caddy (with plugins!),
compare to the existing Caddy, and will replace/upgrade if the downloaded version is different. It also has rudimentary
systemd support to stop and restart the service after upgrade.
It was written by Brian Turek (https://github.com/Caligatio) and released under the Unlicense (https://unlicense.org/).
"""
@Caligatio
Caligatio / iptables.grok
Created August 6, 2016 10:45
iptables Grok Pattern
# GROK Custom Patterns (add to patterns directory and reference in GROK filter for iptables events):
# GROK Patterns for iptables Logging Format
#
# Created 6 Aug 2016 by Brian Turek <brian.turek@gmail.com>
# Most of this was taken from another source but now I cannot find it for credit
#
# Usage: Use the IPTABLES pattern
NETFILTERMAC %{MAC:dest_mac}:%{MAC:src_mac}:%{ETHTYPE:ethtype}
ETHTYPE (?:(?:[A-Fa-f0-9]{2}):(?:[A-Fa-f0-9]{2}))
@Caligatio
Caligatio / pfsense2-3.grok
Last active February 24, 2018 00:17
pfSense 2.3 Grok Pattern
# GROK Custom Patterns (add to patterns directory and reference in GROK filter for pfSense events):
# GROK Patterns for pfSense 2.3 Logging Format
#
# Created 27 Jan 2015 by J. Pisano (Handles TCP, UDP, and ICMP log entries)
# Edited 14 Feb 2015 by Elijah Paul elijah.paul@gmail.com
# Edited 10 Mar 2015 by Bernd Zeimetz <bernd@bzed.de>
# Edited 6 Aug 2016 by Brian Turek <brian.turek@gmail.com>
# taken from https://gist.github.com/elijahpaul/3d80030ac3e8138848b5
# - adding PFSENSE_IGMP_DATA
# - moved and tweaked IPv4 ECN pattern (ecn is a WORD, not INT)
@Caligatio
Caligatio / VerifiedHTTPSHandler.py
Created August 20, 2012 01:33
Certificate validating HTTPSHandler class, VerifiedHTTPSHandler, for Python 2.7
from httplib import HTTPSConnection
import urllib2
import socket
import ssl
class VerifiedHTTPSConnection(HTTPSConnection):
'''
Modified version of the httplib.HTTPSConnection class that forces server
certificate validation
'''