diff --git a/README.md b/README.md index 156ffd7..417dbf0 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Miscellaneous scripts for different purposes. Mostly unrelated to each other. | Infosec
Automation | [`make-mac-prefixes.py`](bin/make-mac-prefixes.py)
Python 3.6+ | Processes registered MAC address prefixes from [IEEE MA-L Assignments (CSV)](https://standards.ieee.org/products-programs/regauth/) (stdin) to Nmap's [`nmap-mac-prefixes`](https://github.com/nmap/nmap/blob/master/nmap-mac-prefixes) (stdout) with a few additional unregistered OUIs.
`curl https://standards-oui.ieee.org/oui/oui.csv \| make-mac-prefixes.py > nmap-mac-prefixes` | | WordPress | [`test-cache-enabler.py`](bin/test-cache-enabler.py)
Python 3.6+ | Tests whether the Cache Enabler by KeyCDN (WordPress) is working properly on the URLs given as arguments.
`test-cache-enabler.py https://example.com [...]` | | Web | [`detect-modified-html-element.sh`](bin/detect-modified-html-element.sh)
Shell (bash) | Checks HTML element changes on a web page since last run. Configured via environment variables.
Recommended to be executed as a SystemD [service](systemd/detect-modified-html-element.service.example). | +| Web | [`http-dns-round-robin.sh`](bin/http-dns-round-robin.sh)
Shell (bash) | Print HTTP headers for every DNS round-robin IP (IPv4 + IPv6)
`http-dns-round-robin.sh URL`| | Web | [`product-pricelimiter.sh`](bin/product-pricelimiter.sh)
Shell (bash) | Compare product price on a web page with a given maximum price. Use, e.g., developer tools on your browser to find the HTML element containing the price.
`product-pricelimiter.sh -u URL -s Selector [-m MaxPrice] [-n N] [-d N]` | | Web | `koronarokotusaika.sh`
Shell (bash) | This script has been removed as koronarokotusaika.fi (bookcovidvaccine.fi) has been shut down on April 28, 2023. | | Web | `xxl-product-pricelimiter.sh`
Shell (bash) | This script has been replaced by the generalized [`product-pricelimiter.sh`](bin/product-pricelimiter.sh) as the HTML structure of XXL.fi has changed. | diff --git a/bin/http-dns-round-robin.sh b/bin/http-dns-round-robin.sh new file mode 100755 index 0000000..0ac5cdf --- /dev/null +++ b/bin/http-dns-round-robin.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# ------------------------------------------------------------------------------ +# Print HTTP headers for every DNS round-robin IP (IPv4 + IPv6) +# +# Usage: http-dns-round-robin.sh URL +# +# Author : Esa Jokinen (oh2fih) +# Home : https://github.com/oh2fih/Misc-Scripts +# ------------------------------------------------------------------------------ + +URL="$1" + +required_command() { + if ! command -v "$1" &> /dev/null; then + if [ -z ${2+x} ]; then + echo "This script requires ${1}!" >&2 + else + echo "This script requires ${1} ${2}!" >&2 + fi + ((UNMET=UNMET+1)) + fi +} + +UNMET=0 + +required_command "curl" "for HTTP connections" +required_command "dig" "for DNS queries" +required_command "head" +required_command "tail" +required_command "awk" + +if [ "$UNMET" -gt 0 ]; then + exit 1 +fi + +regex='http(s)?://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' +if ! [[ $URL =~ $regex ]]; then + echo "The first argument was not a valid URL!" >&2 + exit 1 +fi + +HOSTNAME=$(echo "$URL" | awk -F/ '{print $3}') + +while read -r ip +do + echo "[${ip}]" + curl --resolve "[${HOSTNAME}]:443:${ip}" --silent --head "$URL" +done <<< "$( \ + dig +short "$HOSTNAME" A | tail -n 1 \ + ; dig +short "$HOSTNAME" AAAA | tail -n 1 +)"