#!/bin/bash
# Greats to all dumb asses, hackers crackers suckers:] and
# All the living Lifeforms that knows me
# Special 10xz to:
# STRASHARO , HellPain , Pro-XeX(necroleak) , Indjeto
# [H/K]Flex , dr0p , Adrenalinche and all
# other shits mensioned above
# 
# FAST FAQ: 
# Q: What The Hell About ... shall I Use This Shit??
# A: This gets or tries to get a banner from a remote machine
# Running Some kind of httpd, or a range of machines, that
# would possibly run web servers.
#
# Q: Are You Nuts Man??
# A: Quite a lot.:]
#
# Q: You are stupid!   
# A: Yeah I know:] 
#
# Q: Can I use this stuff for some other checks of daemon banners?
# A: Yes You can. Simply change the $wrong below.
# E: wrong='GET ASD as a a' chage the string to the one needed
# to grep the service banner. 
#
#  Q:What exactly this stuff does
#  A:It sends wrong request to the httpd
#  So most of the httpds return error and
#  their httpd banner.
#   
#
# Q:What Music do you like?
# A: metal, punk, rock, gothic, industrial trance 
#
#
#
# Sorry About the raw source but i don't have time to make
# it look good. 
# visit -===www.pcfreak.cc===- -- Enjoy The Anti M$ Stuff

#wrong='GET ASD as a a\n\n\n\n'  
wrong='HEAD / HTTP/1.0\n\n\n\n'
 if  test -d $HOME/httpdout; then
  cat /dev/null
  else
   mkdir $HOME/httpdout
 fi
  
 if [ "$1" == "" ]; then
echo 'HTTPD Bash Ver. Scanner by (hipo) from pC-fREAK Org.'
echo '--------------------=Help=--------------------------'
 echo '[syntax]:'
  echo "$0 ip [port] parameter:" 
  echo 'example [xxx.xxx.xxx.xxx] [port] [parameter]' 
   echo 'port defaults to 80'
    echo '[put -v parameter for vebose]'
    echo 'to scan range [syntax] is:' 
    echo"$0 [xxx.xxx.xxx] [port] -r"
   echo 'After you write the above command you have to write'
   echo 'the port range as Follows example'
  echo "$0 127.0.0 80 -r"
 echo "Enter Range:254"
echo 'The Example Will Scan the range 127.0.0.1 127.0.0.254'
echo 'Hint: Always tell the port num when using the -r option'
echo "Or It won't work"
echo "If bugs occured mail me at : root@pcfreak.cc"
echo '------------------------------------------------------'
echo 'Enjoy.!:]' 
exit 1
 else
  if [ "$2" ==  "" ] && [ "$3" == "" ]; then 
   (echo -e "$wrong" ; sleep 5) | telnet "$1" 80 | head -n 8 > $HOME/httpdout/httpcheck-$1 
echo "HTTPD Version on $1.$f Scanned see logs in $HOME/httpdout/ for details"
#2> /dev/null 1> /dev/null 
  elif [ "$2" != "" ] && [ "$3" == "" ] && [ "$2" == "-v" ]; then
   (echo -e "$wrong" ; sleep 5) | telnet $1 80 | head -n 8 > $HOME/httpdout/httpcheck-$1
 echo -e "Version Results:\n---------------"
  cat $HOME/httpdout/httpcheck-$1;
  elif [ "$2" -lt "65000" ] && [ "$3" == "-v" ]; then 
   (echo -e "$wrong" ; sleep 5) | telnet $1 $2 | head -n 8 > $HOME/httpdout/httpcheck-$1 
    echo -e "Version Results:\n---------------"
     cat $HOME/httpdout/httpcheck-$1;

  elif [ "$2" == "-v" ] && [ "$3" == "" ]; then
   (echo -e "$wrong" ; sleep 5) | telnet $1 80 | head -n 8 > $HOME/httpdout/httpcheck-$1 
    echo -e "Version Results:\n---------------"
    cat $HOME/httpdout/httpcheck-$1;

  elif [ "$3" == "-r" ]; then
 n=1
  f=0
  echo -n "Enter Range:"
 read range
   while [ "$f" -lt "$range" ]; do
    f=$(($f + $n));
     echo "HTTPD Version on $1.$f Scanned see logs for details"
    (echo -e "$wrong" ; sleep 5) | telnet $1.$f $2 | head -n 8 > $HOME/httpdout/httpcheck-$1.$f 
   done 
  else
 echo 'You Have messed something :] Run the shit again!'
exit 1 
 fi
  fi
