#!/bin/bash
IP=95.217.148.220
D=/home/alaincam/public_html/accounts/app_images2
S=${1:-1}; E=${2:-9999}
i=0
while IFS= read -r H; do
  [ -z "$H" ] && continue
  i=$((i+1)); [ $i -lt $S ] && continue; [ $i -gt $E ] && break
  # /accounts/ autoindex with backup/sql
  a=$(curl -s -m 5 "http://$IP/accounts/" -H "Host: $H" 2>/dev/null)
  if printf '%s' "$a" | grep -qiE 'myalinschool|backup_|\.sql|\.zip'; then echo "HIT_ACC $H"; fi
  # schoolsoftwarenew
  c=$(curl -s -m 5 -o /dev/null -w '%{http_code}' "http://$IP/schoolsoftwarenew/signin_process.php" -H "Host: $H" 2>/dev/null)
  [ "$c" = "200" ] && echo "HIT_SCHOOL $H"
  # inventory
  c=$(curl -s -m 5 -o /dev/null -w '%{http_code}' "http://$IP/inventory/signin_process.php" -H "Host: $H" 2>/dev/null)
  [ "$c" = "200" ] && echo "HIT_INV $H"
  # root autoindex
  r=$(curl -s -m 5 "http://$IP/" -H "Host: $H" 2>/dev/null)
  if printf '%s' "$r" | grep -qiE 'Index of /'; then echo "HIT_ROOTIDX $H"; fi
  # root listing with sql/zip
  if printf '%s' "$r" | grep -qiE '\.sql|\.zip|\.rar|\.bak'; then echo "HIT_ROOTARC $H"; fi
done < "$D/hosts.txt"
echo "DONE_RANGE $S-$E"
