Files
dark-lord/scripts/vanity-onion-mine.sh
2026-04-26 22:28:40 -07:00

51 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Brute-force a Tor v3 .onion whose address starts with PREFIX (base32: az, 27).
# Longer prefixes take exponentially more CPU time. Run on a strong machine; be patient.
#
# bash scripts/mkp224o-build.sh
# bash scripts/vanity-onion-mine.sh cyberl
# sudo bash scripts/install-vanity-onion-key.sh var/vanity-mine
#
# Env:
# CYBERLUX_MKP224O — path to mkp224o binary (default: vendor/mkp224o/mkp224o)
# CYBERLUX_VANITY_OUT — output directory (default: repo var/vanity-mine)
# CYBERLUX_MKP224O_DOCKER=1 — use Docker image instead of local binary
#
set -euo pipefail
REPO="$(cd "$(dirname "$0")/.." && pwd)"
PREFIX="${1:-}"
if [[ -z "${PREFIX}" ]]; then
echo "Usage: $0 <prefix>"
echo "Example: $0 cyberl (8 chars: expect long run; 46 is more practical on one PC)"
echo "Onion v3 hostnames use base32: letters az and digits 27 only (no 0,1,8,9)."
exit 1
fi
if ! [[ "${PREFIX}" =~ ^[a-z2-7]+$ ]]; then
echo "Invalid prefix: use only az and 27 (Tor onion base32)."
exit 1
fi
OUT_DIR="${CYBERLUX_VANITY_OUT:-${REPO}/var/vanity-mine}"
mkdir -p "${OUT_DIR}"
if [[ "${CYBERLUX_MKP224O_DOCKER:-0}" == "1" ]]; then
echo "[*] Mining with Docker (ghcr.io/cathugger/mkp224o:master) → ${OUT_DIR}"
# -s = print stats every 10s; last arg is the base32 filter
exec docker run --rm -it -v "${OUT_DIR}:/keys" ghcr.io/cathugger/mkp224o:master -d /keys -s "${PREFIX}"
fi
MKP="${CYBERLUX_MKP224O:-${REPO}/vendor/mkp224o/mkp224o}"
if [[ ! -x "${MKP}" ]]; then
echo "Missing ${MKP}. Build first:"
echo " bash ${REPO}/scripts/mkp224o-build.sh"
echo "Or set CYBERLUX_MKP224O_DOCKER=1 and re-run this script."
exit 1
fi
echo "[*] Mining (Ctrl+C to stop). Output: ${OUT_DIR}/"
echo "[*] Statistics (-s) enabled. First match appears as a new directory ending in .onion"
"${MKP}" -d "${OUT_DIR}" -s "${PREFIX}"