#!/bin/bash
D=/home/alaincam/public_html/accounts/app_images2
S=${1:-1}; E=${2:-9999}
one(){
  local H="$1" IP=95.217.148.220
  local a c r
  a=$(curl -s -m 6 "http://$IP/accounts/" -H "Host: $H" 2>/dev/null)
  printf '%s' "$a" | grep -qiE 'myalinschool|backup_|\.sql|\.zip' && echo "HIT_ACC $H"
  c=$(curl -s -m 6 -o /dev/null -w '%{http_code}' "http://$IP/schoolsoftwarenew/signin_process.php" -H "Host: $H" 2>/dev/null)
  [ "$c" = "200" ] && echo "HIT_SCHOOL $H"
  c=$(curl -s -m 6 -o /dev/null -w '%{http_code}' "http://$IP/inventory/signin_process.php" -H "Host: $H" 2>/dev/null)
  [ "$c" = "200" ] && echo "HIT_INV $H"
  r=$(curl -s -m 6 "http://$IP/" -H "Host: $H" 2>/dev/null)
  printf '%s' "$r" | grep -qiE 'Index of /' && echo "HIT_ROOTIDX $H"
  printf '%s' "$r" | grep -qiE '\.sql|\.zip|\.rar|\.bak' && echo "HIT_ROOTARC $H"
}
export -f one
sed -n "${S},${E}p" "$D/hosts.txt" | xargs -P 12 -d '\n' -I{} bash -c 'one "$@"' _ "{}"
echo "DONE_RANGE $S-$E"
