Last active
October 16, 2025 02:25
-
-
Save GangGreenTemperTatum/10f94ebec43328069012973b4f11038d to your computer and use it in GitHub Desktop.
recon install script for ubuntu for live recon talks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # setup-recon.sh (v4) | |
| # Works on Ubuntu / Debian / Kali | |
| # Usage: sudo ./setup-recon.sh | |
| set -euo pipefail | |
| export DEBIAN_FRONTEND=noninteractive | |
| #----------------------------- | |
| # Config | |
| #----------------------------- | |
| GO_VERSION="1.24.3" # change to pin another Go release | |
| TOOLS_DIR="${HOME}/tools" # where git-based tools (massdns) live | |
| MASSDNS_REPO="https://github.com/blechschmidt/massdns.git" | |
| PDTM_PKG="github.com/projectdiscovery/pdtm/cmd/pdtm@latest" | |
| GOWITNESS_PKG="github.com/sensepost/gowitness@latest" | |
| EYEBALLER_REPO="https://github.com/BishopFox/eyeballer.git" | |
| EYEBALLER_DIR="/opt/eyeballer" # install location for eyeballer | |
| PYTHON_BIN="/usr/bin/python3" | |
| # Arch map for Go tarball | |
| case "$(uname -m)" in | |
| x86_64|amd64) GO_ARCH="amd64" ;; | |
| aarch64|arm64) GO_ARCH="arm64" ;; | |
| *) echo "Unsupported architecture: $(uname -m). Edit script to add mapping."; exit 1 ;; | |
| esac | |
| GO_TARBALL="go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" | |
| GO_DOWNLOAD_URL="https://dl.google.com/go/${GO_TARBALL}" | |
| # If the script is run with sudo, capture the original user (to optionally update their rc files too) | |
| ORIG_USER="${SUDO_USER:-}" | |
| ORIG_HOME="" | |
| if [ -n "$ORIG_USER" ] && [ "$ORIG_USER" != "root" ]; then | |
| ORIG_HOME="$(getent passwd "$ORIG_USER" | cut -d: -f6 || true)" | |
| fi | |
| #----------------------------- | |
| # Helpers | |
| #----------------------------- | |
| msg() { printf "\n\033[1;32m[+]\033[0m %s\n" "$*"; } | |
| warn(){ printf "\n\033[1;33m[!]\033[0m %s\n" "$*"; } | |
| die() { printf "\n\033[1;31m[x]\033[0m %s\n" "$*"; exit 1; } | |
| ensure_line_in_rc() { | |
| local line="$1" rcfile="$2" | |
| [ -z "$rcfile" ] && return 0 | |
| [ -f "$rcfile" ] || touch "$rcfile" | |
| chmod 644 "$rcfile" || true | |
| grep -qxF "$line" "$rcfile" 2>/dev/null || printf '\n%s\n' "$line" >> "$rcfile" | |
| } | |
| add_paths_for_user() { | |
| local home_dir="$1" | |
| [ -z "$home_dir" ] && return 0 | |
| ensure_line_in_rc 'export GOPATH="$HOME/go"' "$home_dir/.bashrc" | |
| ensure_line_in_rc 'export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin:$HOME/.pdtm/go/bin"' "$home_dir/.bashrc" | |
| ensure_line_in_rc 'export GOPATH="$HOME/go"' "$home_dir/.zshrc" | |
| ensure_line_in_rc 'export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin:$HOME/.pdtm/go/bin"' "$home_dir/.zshrc" | |
| } | |
| #----------------------------- | |
| # Start | |
| #----------------------------- | |
| msg "Running setup on: $(lsb_release -ds 2>/dev/null || head -n1 /etc/os-release)" | |
| msg "This will install: build deps, oh-my-zsh, Go ${GO_VERSION}, nmap, massdns, pdtm, gowitness, eyeballer." | |
| # 0) Require root/sudo | |
| if [ "$EUID" -ne 0 ]; then | |
| die "Please run as root (e.g., sudo ./setup-recon.sh)." | |
| fi | |
| # 1) apt update & base deps | |
| msg "Updating apt and installing base packages…" | |
| apt-get update -y | |
| apt-get install -y --no-install-recommends \ | |
| build-essential git curl wget ca-certificates gnupg lsb-release \ | |
| zsh sudo apt-transport-https make pkg-config libpcap-dev \ | |
| python3 python3-venv python3-pip | |
| # 2) oh-my-zsh (non-interactive; won’t change default shell) | |
| if [ ! -d "${HOME}/.oh-my-zsh" ]; then | |
| msg "Installing Oh My Zsh (non-interactive)…" | |
| RUNZSH=no CHSH=no \ | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
| else | |
| msg "Oh My Zsh already present; skipping." | |
| fi | |
| # 3) Install Go into /usr/local | |
| if command -v go >/dev/null 2>&1 && go version | grep -q "go${GO_VERSION} "; then | |
| msg "Go ${GO_VERSION} already installed." | |
| else | |
| msg "Installing Go ${GO_VERSION} for ${GO_ARCH}…" | |
| rm -rf /usr/local/go | |
| cd /tmp | |
| wget -q --show-progress "${GO_DOWNLOAD_URL}" | |
| tar -C /usr/local -xzf "${GO_TARBALL}" | |
| rm -f "${GO_TARBALL}" | |
| fi | |
| # 3b) Set GOPATH and PATH for current + future shells (root and invoking user if any) | |
| GOPATH_DEFAULT="${HOME}/go" | |
| export GOPATH="${GOPATH_DEFAULT}" | |
| export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin:${HOME}/.pdtm/go/bin" | |
| add_paths_for_user "$HOME" # root | |
| if [ -n "$ORIG_HOME" ]; then | |
| add_paths_for_user "$ORIG_HOME" # sudo-invoking user | |
| fi | |
| # Also create a system-wide profile.d snippet so new shells inherit PATH reliably | |
| cat >/etc/profile.d/golang_pdtm_path.sh <<'EOF' | |
| # Go + ProjectDiscovery (pdtm) paths | |
| export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin:$HOME/.pdtm/go/bin" | |
| EOF | |
| chmod 644 /etc/profile.d/golang_pdtm_path.sh | |
| # 4) nmap | |
| if ! command -v nmap >/dev/null 2>&1; then | |
| msg "Installing nmap…" | |
| apt-get install -y nmap | |
| else | |
| msg "nmap already installed." | |
| fi | |
| # 5) massdns from source | |
| mkdir -p "${TOOLS_DIR}" | |
| if [ ! -d "${TOOLS_DIR}/massdns" ]; then | |
| msg "Cloning massdns…" | |
| git clone --depth 1 "${MASSDNS_REPO}" "${TOOLS_DIR}/massdns" | |
| else | |
| msg "massdns repo exists; pulling latest…" | |
| git -C "${TOOLS_DIR}/massdns" pull --ff-only || true | |
| fi | |
| msg "Building and installing massdns…" | |
| make -C "${TOOLS_DIR}/massdns" | |
| # Try install target; fallback to copying the built binary | |
| if make -C "${TOOLS_DIR}/massdns" -n install >/dev/null 2>&1; then | |
| make -C "${TOOLS_DIR}/massdns" install | |
| else | |
| if [ -f "${TOOLS_DIR}/massdns/bin/massdns" ]; then | |
| install -m 0755 "${TOOLS_DIR}/massdns/bin/massdns" /usr/local/bin/massdns | |
| elif [ -f "${TOOLS_DIR}/massdns/massdns" ]; then | |
| install -m 0755 "${TOOLS_DIR}/massdns/massdns" /usr/local/bin/massdns | |
| fi | |
| fi | |
| # 6) pdtm install (ProjectDiscovery tool manager) | |
| if ! command -v go >/dev/null 2>&1; then | |
| die "go not available after install; check /usr/local/go/bin in PATH." | |
| fi | |
| if ! command -v pdtm >/dev/null 2>&1; then | |
| msg "Installing pdtm (${PDTM_PKG})…" | |
| GO111MODULE=on go install -v "${PDTM_PKG}" || die "pdtm installation failed" | |
| fi | |
| # Make sure pdtm is accessible system-wide right away | |
| if [ -x "${HOME}/go/bin/pdtm" ] && [ ! -e "/usr/local/bin/pdtm" ]; then | |
| ln -sf "${HOME}/go/bin/pdtm" /usr/local/bin/pdtm || true | |
| fi | |
| # 7) gowitness (Go-based screenshot tool) | |
| if ! command -v gowitness >/dev/null 2>&1; then | |
| msg "Installing gowitness (${GOWITNESS_PKG}) via go install…" | |
| GO111MODULE=on go install -v "${GOWITNESS_PKG}" || warn "gowitness go install reported an issue" | |
| # symlink for convenience | |
| if [ -x "${HOME}/go/bin/gowitness" ]; then | |
| ln -sf "${HOME}/go/bin/gowitness" /usr/local/bin/gowitness || true | |
| fi | |
| else | |
| msg "gowitness already installed." | |
| fi | |
| # 8) Eyeballer (AI triage for screenshots) - clone, create venv, pip install | |
| if [ ! -d "${EYEBALLER_DIR}" ]; then | |
| msg "Cloning Eyeballer to ${EYEBALLER_DIR}…" | |
| git clone --depth 1 "${EYEBALLER_REPO}" "${EYEBALLER_DIR}" | |
| else | |
| msg "Eyeballer repo exists; pulling latest…" | |
| git -C "${EYEBALLER_DIR}" pull --ff-only || true | |
| fi | |
| # Create venv and install python deps (idempotent) | |
| if [ -d "${EYEBALLER_DIR}" ]; then | |
| msg "Setting up Eyeballer python venv and installing requirements…" | |
| python3 -m venv "${EYEBALLER_DIR}/venv" || warn "venv creation failed (maybe already exists)" | |
| # Upgrade pip and install requirements if requirements.txt present | |
| if [ -f "${EYEBALLER_DIR}/requirements.txt" ]; then | |
| "${EYEBALLER_DIR}/venv/bin/python" -m pip install --upgrade pip setuptools wheel | |
| "${EYEBALLER_DIR}/venv/bin/pip" install -r "${EYEBALLER_DIR}/requirements.txt" || warn "Some pip packages for Eyeballer failed to install (TensorFlow or GPU deps may be heavy)." | |
| else | |
| warn "Eyeballer requirements.txt not found; skip pip install." | |
| fi | |
| # create a simple wrapper so /usr/local/bin/eyeballer launches the venv/python eyeballer.py | |
| if [ -f "${EYEBALLER_DIR}/eyeballer.py" ]; then | |
| cat >/usr/local/bin/eyeballer <<EOF | |
| #!/usr/bin/env bash | |
| exec "${EYEBALLER_DIR}/venv/bin/python" "${EYEBALLER_DIR}/eyeballer.py" "\$@" | |
| EOF | |
| chmod 755 /usr/local/bin/eyeballer | |
| else | |
| warn "eyeballer.py not found in repo; wrapper not created. Check ${EYEBALLER_DIR}." | |
| fi | |
| else | |
| warn "Eyeballer repo missing; skipped python venv setup." | |
| fi | |
| # 9) Use pdtm to install ProjectDiscovery tools (install all) | |
| if command -v pdtm >/dev/null 2>&1; then | |
| msg "Running pdtm to install all ProjectDiscovery tools… (this can take a while)" | |
| if pdtm -h 2>&1 | grep -q -- '-install-all'; then | |
| pdtm -install-all || warn "pdtm -install-all reported errors (some tools may need extra libs)." | |
| else | |
| pdtm -ia || warn "pdtm -ia reported errors." | |
| fi | |
| else | |
| warn "pdtm not found on PATH even after install. Ensure PATH includes \$HOME/go/bin and \$HOME/.pdtm/go/bin." | |
| fi | |
| # 10) Final report & hint to reload shell | |
| msg "Done." | |
| echo "Open a new shell or run: source ~/.bashrc (or: source ~/.zshrc)" | |
| echo | |
| echo "Quick checks (these should show locations):" | |
| echo " go: $(command -v go || echo 'not found') -> $(go version 2>/dev/null || true)" | |
| echo " nmap: $(command -v nmap || echo 'not found')" | |
| echo " massdns: $(command -v massdns || echo 'not found')" | |
| echo " pdtm: $(command -v pdtm || echo 'not found')" | |
| echo " gowitness: $(command -v gowitness || echo 'not found')" | |
| echo " eyeballer: $(command -v eyeballer || echo 'not found')" | |
| # Helpful note about eyeballer weights (optional) | |
| if [ -d "${EYEBALLER_DIR}" ]; then | |
| echo | |
| echo "To use Eyeballer you may want the pre-trained weights. Example:" | |
| echo " wget https://github.com/BishopFox/eyeballer/releases/download/3.0/bishop-fox-pretrained-v3.h5 -P ${EYEBALLER_DIR}" | |
| echo "Then run (example):" | |
| echo " eyeballer --weights ${EYEBALLER_DIR}/bishop-fox-pretrained-v3.h5 predict /path/to/screenshots" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment