Skip to content

Instantly share code, notes, and snippets.

@maikgreubel
maikgreubel / closest_color.py
Created July 29, 2025 16:55
Give a HTML color code and the script will tell you the three best names matching the color
import webcolors
import sys
import urllib.request
import os
# Make use of xkcd 954 color name mappings in one name to rgb file (thank you dudes!)
if not os.path.exists(os.path.join(os.path.realpath(__file__), "rgb.txt")):
urllib.request.urlretrieve("https://xkcd.com/color/rgb.txt", "rgb.txt")
def closest_color(requested_color:str):
@maikgreubel
maikgreubel / harden-sshd.sh
Created February 5, 2023 16:13
harden-sshd
#!/bin/bash
if [ $UID -ne 0 ]; then
echo "root only"
exit 1
fi
restart=0
for i in $(grep "Failed password" /var/log/secure | grep -oE '((1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])' | uniq)
do
if [ `grep -c " $i\$" /etc/hosts.deny` -eq 0 ]; then
for o in $(grep -A1 "failed mail authentication attempt for user" /var/log/maillog |grep "authentication fail" | perl -pe 's#.*unknown\[([^\]].*?)\].*#\1#' | grep -E "^[[:digit:]]+" | uniq); do whois $o | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}\/" | grep -v "^%" | awk '{print $2}'; done