From be3665906ad75674b9b617555984ea20a4e30ed2 Mon Sep 17 00:00:00 2001 From: DocTator Date: Wed, 21 May 2025 16:25:23 -0400 Subject: [PATCH] Auto-commit from giteapush.sh at 2025-05-21 16:25:23 --- miscellaneous/vps/.env | 5 - miscellaneous/vps/check-hardened.sh | 37 ----- miscellaneous/vps/check_rdns_retry.sh | 27 ---- .../vps/functions/destroy_vps_by_label.sh | 28 ---- .../vps/functions/disable_backups_by_label.sh | 23 --- miscellaneous/vps/functions/disable_ip.sh | 18 --- .../vps/functions/enable_backups_by_label.sh | 23 --- miscellaneous/vps/functions/list_all_vps.sh | 9 -- miscellaneous/vps/functions/provision.sh | 135 ------------------ miscellaneous/vps/functions/reboot_vps.sh | 7 - miscellaneous/vps/functions/resize_vps.sh | 27 ---- .../vps/functions/safe_create_dataset.sh | 12 -- miscellaneous/vps/functions/status_vps.sh | 8 -- miscellaneous/vps/functions/usage.sh | 22 --- miscellaneous/vps/functions/verify_ptr.sh | 29 ---- miscellaneous/vps/genesis_squeaky.sh | 44 ------ miscellaneous/vps/genesisctl.sh | 104 -------------- 17 files changed, 558 deletions(-) delete mode 100644 miscellaneous/vps/.env delete mode 100755 miscellaneous/vps/check-hardened.sh delete mode 100755 miscellaneous/vps/check_rdns_retry.sh delete mode 100755 miscellaneous/vps/functions/destroy_vps_by_label.sh delete mode 100755 miscellaneous/vps/functions/disable_backups_by_label.sh delete mode 100644 miscellaneous/vps/functions/disable_ip.sh delete mode 100755 miscellaneous/vps/functions/enable_backups_by_label.sh delete mode 100755 miscellaneous/vps/functions/list_all_vps.sh delete mode 100755 miscellaneous/vps/functions/provision.sh delete mode 100755 miscellaneous/vps/functions/reboot_vps.sh delete mode 100755 miscellaneous/vps/functions/resize_vps.sh delete mode 100755 miscellaneous/vps/functions/safe_create_dataset.sh delete mode 100755 miscellaneous/vps/functions/status_vps.sh delete mode 100755 miscellaneous/vps/functions/usage.sh delete mode 100755 miscellaneous/vps/functions/verify_ptr.sh delete mode 100755 miscellaneous/vps/genesis_squeaky.sh delete mode 100755 miscellaneous/vps/genesisctl.sh diff --git a/miscellaneous/vps/.env b/miscellaneous/vps/.env deleted file mode 100644 index 1be49f0..0000000 --- a/miscellaneous/vps/.env +++ /dev/null @@ -1,5 +0,0 @@ -LINODE_API_TOKEN=8140523e8d64f16f490b70096b04d221a44236eda552b0caa35fe9be35442f6d -# Cloudflare API -CF_API_TOKEN="PrUbZD1bj0ky1T32waiis2hp91e4Az1ZiCule9Ys" -CF_ZONE_ID="c9b0c727c2c55594f62d38227133e3ac" -CF_DOMAIN="failzero.net" diff --git a/miscellaneous/vps/check-hardened.sh b/miscellaneous/vps/check-hardened.sh deleted file mode 100755 index cdaeef8..0000000 --- a/miscellaneous/vps/check-hardened.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# check-hardened.sh - Scan all known Genesis VPSes for hardening status -# Requirements: ssh access to all VPSes by label or IP - -LOG_BASE="/home/doc/vpslogs" -MARKER_FILE="/var/log/genesis-hardened.ok" - -if [ ! -d "$LOG_BASE" ]; then - echo "āŒ Log directory $LOG_BASE does not exist. Are you running this on Krang?" - exit 1 -fi - -cd "$LOG_BASE" || exit 1 - -echo "šŸ” Scanning for hardened Genesis VPSes..." -echo - -for LOG in *.log; do - VPS_LABEL="${LOG%.log}" - LAST_KNOWN_IP=$(grep -Eo '\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\)' "$LOG" | tail -1 | tr -d '()') - - if [ -z "$LAST_KNOWN_IP" ]; then - echo "āš ļø $VPS_LABEL: No IP found in log. Skipping." - continue - fi - - echo -n "šŸ”§ $VPS_LABEL ($LAST_KNOWN_IP): " - - ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@"$LAST_KNOWN_IP" "test -f $MARKER_FILE" >/dev/null 2>&1 - - if [ $? -eq 0 ]; then - echo "āœ… Hardened" - else - echo "āŒ Not marked as hardened" - fi - -done diff --git a/miscellaneous/vps/check_rdns_retry.sh b/miscellaneous/vps/check_rdns_retry.sh deleted file mode 100755 index b11208b..0000000 --- a/miscellaneous/vps/check_rdns_retry.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -set -e -[ -f ".env" ] && source .env -LOGFILE="/home/doc/vpslogs/pending_rdns.log" -TMPFILE="/tmp/rdns_retry.log" - -touch "$TMPFILE" - -while IFS="|" read -r LINODE_ID IP LABEL; do - CURRENT_RDNS=$(dig -x "$IP" +short) - EXPECTED_RDNS="$LABEL.failzero.net." - - if [[ "$CURRENT_RDNS" == "$EXPECTED_RDNS" ]]; then - echo "āœ… $IP already has correct rDNS ($CURRENT_RDNS)" - else - echo "ā³ rDNS not set correctly for $LABEL ($IP). Retrying..." - RESPONSE=$(curl -s -X PUT "https://api.linode.com/v4/linode/instances/$LINODE_ID/ips/$IP" \ - -H "Authorization: Bearer $LINODE_API_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{"rdns": "'"$LABEL.failzero.net"'"}') - echo "šŸ” Retry result for $IP: $RESPONSE" - fi - - echo "$LINODE_ID|$IP|$LABEL" >> "$TMPFILE" -done < "$LOGFILE" - -mv "$TMPFILE" "$LOGFILE" diff --git a/miscellaneous/vps/functions/destroy_vps_by_label.sh b/miscellaneous/vps/functions/destroy_vps_by_label.sh deleted file mode 100755 index 09d807e..0000000 --- a/miscellaneous/vps/functions/destroy_vps_by_label.sh +++ /dev/null @@ -1,28 +0,0 @@ -destroy_vps_by_label() { - LABEL="$1" - echo "Looking for VPS with label '$LABEL'..." - LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ - https://api.linode.com/v4/linode/instances | \ - jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id') - - if [ -z "$LINODE_ID" ]; then - echo "Error: No Linode found with label '$LABEL'" - exit 1 - fi - - read -rp "Are you sure you want to destroy VPS '$LABEL' (ID: $LINODE_ID)? [y/N] " confirm - if [[ "$confirm" =~ ^[Yy]$ ]]; then - echo "Destroying Linode with ID $LINODE_ID (label: $LABEL)..." - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE \ - https://api.linode.com/v4/linode/instances/$LINODE_ID \ - -H "Authorization: Bearer $LINODE_API_TOKEN") - - if [[ "$HTTP_STATUS" == "204" ]]; then - echo "āœ… Linode $LABEL (ID $LINODE_ID) has been destroyed." - else - echo "āŒ Failed to destroy VPS. HTTP status: $HTTP_STATUS" - fi - else - echo "Cancelled. VPS '$LABEL' not destroyed." - fi -} diff --git a/miscellaneous/vps/functions/disable_backups_by_label.sh b/miscellaneous/vps/functions/disable_backups_by_label.sh deleted file mode 100755 index 417bdb8..0000000 --- a/miscellaneous/vps/functions/disable_backups_by_label.sh +++ /dev/null @@ -1,23 +0,0 @@ -disable_backups_by_label() { - LABEL="$1" - LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ - https://api.linode.com/v4/linode/instances | \ - jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id') - - if [ -z "$LINODE_ID" ]; then - echo "āŒ No Linode found with label '$LABEL'" - exit 1 - fi - - echo "Disabling backups for Linode '$LABEL' (ID: $LINODE_ID)..." - - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ - https://api.linode.com/v4/linode/instances/$LINODE_ID/backups/disable \ - -H "Authorization: Bearer $LINODE_API_TOKEN") - - if [[ "$HTTP_STATUS" == "200" ]]; then - echo "āœ… Backups disabled for Linode $LABEL." - else - echo "āŒ Failed to disable backups (HTTP $HTTP_STATUS)" - fi -} diff --git a/miscellaneous/vps/functions/disable_ip.sh b/miscellaneous/vps/functions/disable_ip.sh deleted file mode 100644 index 0021b74..0000000 --- a/miscellaneous/vps/functions/disable_ip.sh +++ /dev/null @@ -1,18 +0,0 @@ -disable_ip() { - local ip="$1" - - if [[ -z "$ip" ]]; then - echo "[!] No IP specified." - exit 1 - fi - - echo "[*] Disabling access to VPS with IP: $ip" - - # Block all traffic to/from that IP via iptables - iptables -A INPUT -s "$ip" -j DROP - iptables -A OUTPUT -d "$ip" -j DROP - - echo "$ip - disabled on $(date)" >> /var/log/genesis-disabled.log - - echo "[āœ“] $ip has been blocked and logged." -} diff --git a/miscellaneous/vps/functions/enable_backups_by_label.sh b/miscellaneous/vps/functions/enable_backups_by_label.sh deleted file mode 100755 index 08fb31d..0000000 --- a/miscellaneous/vps/functions/enable_backups_by_label.sh +++ /dev/null @@ -1,23 +0,0 @@ -enable_backups_by_label() { - LABEL="$1" - LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ - https://api.linode.com/v4/linode/instances | \ - jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id') - - if [ -z "$LINODE_ID" ]; then - echo "āŒ No Linode found with label '$LABEL'" - exit 1 - fi - - echo "Enabling backups for Linode '$LABEL' (ID: $LINODE_ID)..." - - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ - https://api.linode.com/v4/linode/instances/$LINODE_ID/backups/enable \ - -H "Authorization: Bearer $LINODE_API_TOKEN") - - if [[ "$HTTP_STATUS" == "200" ]]; then - echo "āœ… Backups enabled for Linode $LABEL." - else - echo "āŒ Failed to enable backups (HTTP $HTTP_STATUS)" - fi -} diff --git a/miscellaneous/vps/functions/list_all_vps.sh b/miscellaneous/vps/functions/list_all_vps.sh deleted file mode 100755 index 8ce99eb..0000000 --- a/miscellaneous/vps/functions/list_all_vps.sh +++ /dev/null @@ -1,9 +0,0 @@ -list_all_vps() { - curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ - https://api.linode.com/v4/linode/instances | \ - jq -r ' - .data[] | [.label, .id, .region, .type, .ipv4[0], .status] | - @tsv' | column -t -s $'\t' | \ - awk 'BEGIN { print "LABEL ID REGION TYPE IP STATUS" } - { printf "%-11s %-10s %-10s %-16s %-15s %s\n", $1, $2, $3, $4, $5, $6 }' -} diff --git a/miscellaneous/vps/functions/provision.sh b/miscellaneous/vps/functions/provision.sh deleted file mode 100755 index f6e9d39..0000000 --- a/miscellaneous/vps/functions/provision.sh +++ /dev/null @@ -1,135 +0,0 @@ -provision_vps() { - LABEL="$1" - REGION="$2" - TYPE="$3" - IMAGE="$4" - ROOT_PASS="${5:-$(openssl rand -base64 16)}" - - if [[ "$LINODE_API_TOKEN" == "REPLACE_WITH_YOUR_LINODE_API_TOKEN" ]]; then - echo "āŒ Error: You must set your LINODE_API_TOKEN at the top of this script." - exit 1 - fi - - CLOUD_INIT=$(cat </dev/null || true - systemctl disable linode-cloudinit 2>/dev/null || true - touch /etc/cloud/cloud-init.disabled - rm -rf /etc/cloud /var/lib/cloud /var/log/cloud-init.log - - rm -f /etc/motd /etc/update-motd.d/linode - rm -rf /usr/share/linode* - rm -f /etc/apt/sources.list.d/linode.list - apt remove --purge -y linode-cli linode-config 2>/dev/null || true - - echo "[genesisctl] Attempting to log to Krang via webhook..." >> /var/log/genesis-harden.log - curl -s -X POST -H "Content-Type: application/json" \ - -d "{\"host\": \"$GEN_HOSTNAME\", \"ip\": \"$IP_ADDR\", \"timestamp\": \"$(date)\"}" \ - http://krang.core.sshjunkie.com:8080/genesislog >> /var/log/genesis-harden.log 2>&1 || echo "[genesisctl] Krang webhook logging failed" >> /var/log/genesis-harden.log - - touch /var/log/genesis-hardened.ok - -runcmd: - - [ bash, /usr/local/bin/genesis_squeaky.sh ] -EOF -) - - USER_DATA=$(echo "$CLOUD_INIT" | base64 -w 0) - - echo "Provisioning VPS '$LABEL' in $REGION with type $TYPE and image $IMAGE..." - TMP_FILE=$(mktemp) - JSON_PAYLOAD=$(cat <> /home/doc/vpslogs/pending_rdns.log -} diff --git a/miscellaneous/vps/functions/reboot_vps.sh b/miscellaneous/vps/functions/reboot_vps.sh deleted file mode 100755 index 2741b9c..0000000 --- a/miscellaneous/vps/functions/reboot_vps.sh +++ /dev/null @@ -1,7 +0,0 @@ -reboot_vps() { - LINODE_ID="$1" - echo "Rebooting Linode VPS ID $LINODE_ID..." - - curl -s -X POST https://api.linode.com/v4/linode/instances/$LINODE_ID/reboot \ - -H "Authorization: Bearer $LINODE_API_TOKEN" | jq -} diff --git a/miscellaneous/vps/functions/resize_vps.sh b/miscellaneous/vps/functions/resize_vps.sh deleted file mode 100755 index c06ea91..0000000 --- a/miscellaneous/vps/functions/resize_vps.sh +++ /dev/null @@ -1,27 +0,0 @@ -resize_vps() { - LABEL="$1" - NEW_TYPE="$2" - - LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ - https://api.linode.com/v4/linode/instances | \ - jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id') - - if [ -z "$LINODE_ID" ]; then - echo "āŒ No Linode found with label '$LABEL'" - exit 1 - fi - - echo "Resizing Linode '$LABEL' to type '$NEW_TYPE'..." - - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer $LINODE_API_TOKEN" \ - -d '{"type": "'"$NEW_TYPE"'"}' \ - https://api.linode.com/v4/linode/instances/$LINODE_ID/resize) - - if [[ "$HTTP_STATUS" == "200" ]]; then - echo "āœ… Linode $LABEL resized to $NEW_TYPE." - else - echo "āŒ Failed to resize VPS. HTTP status: $HTTP_STATUS" - fi -} diff --git a/miscellaneous/vps/functions/safe_create_dataset.sh b/miscellaneous/vps/functions/safe_create_dataset.sh deleted file mode 100755 index 1960e55..0000000 --- a/miscellaneous/vps/functions/safe_create_dataset.sh +++ /dev/null @@ -1,12 +0,0 @@ -safe_create_dataset() { - FULLPATH="$1" - - # Remove any trailing slash - FULLPATH="${FULLPATH%/}" - - POOL="${FULLPATH%%/*}" - DATASET="${FULLPATH#*/}" - - echo "šŸ›° Connecting to Shredder to safely create '${POOL}/${DATASET}'..." - ssh shredder "/usr/local/bin/genesis-safe-zfs.sh $POOL $DATASET" -} diff --git a/miscellaneous/vps/functions/status_vps.sh b/miscellaneous/vps/functions/status_vps.sh deleted file mode 100755 index 91996e9..0000000 --- a/miscellaneous/vps/functions/status_vps.sh +++ /dev/null @@ -1,8 +0,0 @@ -status_vps() { - LABEL="$1" - curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" \ - https://api.linode.com/v4/linode/instances | \ - jq -r --arg LABEL "$LABEL" ' - .data[] | select(.label == $LABEL) | - "Label: \(.label)\nID: \(.id)\nRegion: \(.region)\nType: \(.type)\nStatus: \(.status)\nIP: \(.ipv4[0])\nCreated: \(.created)"' -} diff --git a/miscellaneous/vps/functions/usage.sh b/miscellaneous/vps/functions/usage.sh deleted file mode 100755 index 25861b8..0000000 --- a/miscellaneous/vps/functions/usage.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -function usage() { - echo "Usage: genesisctl [command]" - echo "Commands:" - echo " watch-abuse Start abuse monitoring via IPTables" -} - -function watch_abuse() { - echo "[*] Launching abuse watch via screen..." - screen -dmS abusewatch /usr/local/bin/genesisctl-watch-abuse.sh - echo "[āœ“] Abuse watch running in detached screen session 'abusewatch'" -} - -case "$1" in - watch-abuse) - watch_abuse - ;; - *) - usage - ;; -esac diff --git a/miscellaneous/vps/functions/verify_ptr.sh b/miscellaneous/vps/functions/verify_ptr.sh deleted file mode 100755 index 8ce2f6c..0000000 --- a/miscellaneous/vps/functions/verify_ptr.sh +++ /dev/null @@ -1,29 +0,0 @@ -verify_ptr() { - LABEL="$1" - IP=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" https://api.linode.com/v4/linode/instances \ - | jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .ipv4[0]') - LINODE_ID=$(curl -s -H "Authorization: Bearer $LINODE_API_TOKEN" https://api.linode.com/v4/linode/instances \ - | jq -r --arg LABEL "$LABEL" '.data[] | select(.label == $LABEL) | .id') - - if [[ -z "$IP" || -z "$LINODE_ID" ]]; then - echo "āŒ Could not retrieve IP or Linode ID for label '$LABEL'" - return 1 - fi - - echo "Re-attempting rDNS update for $LABEL ($IP)..." - PTR_NAME="${LABEL}.doinkle.pro" - RDNS_PAYLOAD=$(cat </dev/null || true -systemctl disable linode-cloudinit 2>/dev/null || true -touch /etc/cloud/cloud-init.disabled -rm -rf /etc/cloud /var/lib/cloud /var/log/cloud-init.log -echo "[+] Cloud-init neutered." - -# === STEP 4: Scrub Linode Stuff === -echo "[*] Scrubbing Linode fingerprints..." -rm -f /etc/motd /etc/update-motd.d/linode -rm -rf /usr/share/linode* -rm -f /etc/apt/sources.list.d/linode.list -apt remove --purge -y linode-cli linode-config 2>/dev/null || true -yum remove -y linode-cli linode-config 2>/dev/null || true -echo "[+] Linode packages and branding removed." - -# === STEP 5: Optional Telegram Notice === -# Uncomment if you want to alert yourself when a VPS is hardened -# curl -s -X POST "$TG_API_URL" -d chat_id="$TG_CHAT_ID" -d text="Genesis VPS hardened: $GEN_HOSTNAME is stealth-ready." > /dev/null - -# === STEP 6: Final Touch === -echo "[āœ…] Genesis VPS hardened. You are now off-the-grid and good to go." diff --git a/miscellaneous/vps/genesisctl.sh b/miscellaneous/vps/genesisctl.sh deleted file mode 100755 index 21fdf7d..0000000 --- a/miscellaneous/vps/genesisctl.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env bash -# genesisctl - Genesis VPS Provisioning and Reboot CLI -# Usage: -# genesisctl provision