Skip to content

Instantly share code, notes, and snippets.

@jeroenhe
jeroenhe / check_cert_data.sh
Created July 14, 2022 07:20
Check certificate expiration date using timeout, openssl and date cli tools
#!/usr/bin/env bash
HOST=$1
PORT=$2
DAYS=${3:-10}
CERT_FILE=$(mktemp)
### Read Site Certificate and save as File ###
timeout --preserve-status 3 openssl s_client -servername $HOST -connect $HOST:$PORT 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > "$CERT_FILE"
@jeroenhe
jeroenhe / update_node.sh
Last active June 19, 2021 20:03
Perform automated update for https://flows.nodered.org/add/node
#!/usr/bin/env bash
RESULT_FILE="/tmp/result.txt"
FILE_WITH_CSRF="/tmp/output.html"
COOKIES_FILE="/tmp/cookies.txt"
MODULE_NAME="node-red-contrib-openhab3"
FLOWS_URL="https://flows.nodered.org/add/node"
# remove any previous cookies
if [ -f "${COOKIES_FILE}" ]; then
@jeroenhe
jeroenhe / get_token.py
Created June 19, 2021 19:24
Acquire _csrf token from html page using python
#!/usr/bin/env python3
import re
import sys
for i in sys.stdin:
g = re.match('.*\<.*name="_csrf".*value="(.*)"\>.*', i);
if g is not None:
print (g.group(1))
@jeroenhe
jeroenhe / check_pass.sh
Created February 3, 2021 12:11
Check whether a linux bcrypt password hash matches with a plain-text password
#!/usr/bin/env bash
read -p "Username >" username
IFS= read -p "Password >" password
salt=$(sudo getent shadow $username | cut -d$ -f3)
epassword=$(sudo getent shadow $username | cut -d: -f2)
match=$(python3 -c 'import crypt; print(crypt.crypt("'"${password}"'", "$6$'${salt}'"))')
echo "salt=$salt"
echo "match=$match"
echo "epassword=$epassword"
@jeroenhe
jeroenhe / Dockerfile
Last active March 24, 2024 23:34
UniFi Network Controller behind a Traefik reverse proxy
FROM traefik:v2.3.2
COPY traefik.yml /etc/traefik/traefik.yml
RUN mkdir /etc/traefik/conf
COPY tls.yml /etc/traefik/conf
COPY http.yml /etc/traefik/conf