#!/bin/bash

#Variables Globales
home=$(pwd)
web=firefox
#banner
f_banner(){
echo 
echo -e "\e[0;31m
           *** RECON BY PLATZI Version 0.1***"
echo
}

f_recon(){

echo -n "Tipo de reconocimiento quieres ejecutar: "
echo 
echo "1. PASIVO"
echo "2. ACTIVO"
echo "3. PERSONAS"
echo "4. Regresar al Menu"

read opcion

case $opcion in
	1)
		echo -n "Digita el dominio"
		read dominio
		
		

		
		echo ""
		
		;;
	2)
		echo "hola"
		;;
	3)
		echo -n "Cual es el Nombre: "
		read nombre
		
		if [[ -z $nombre ]]; then
		f_error
		fi
		
		echo -n "Cual es el Apellido: "
		read apellido
		
		if [[ -z $apellido ]]; then
		f_error
		fi
		
		echo -n "Cual es el Pais donde quiere realizar la busqueda: "
		read pais
		
		if [[ -z $pais ]]; then
		f_error
		fi
		sleep 2
		$web https://pipl.com/search/?q=$nombre+$pais\&l=$pais\&sloc=\&in=5 &
		sleep 2
		$web https://www.linkedin.com/pub/dir/?first=$firstName\&last=$lastName\&search=Search &
		;;
	4)
		f_main;;
	
	*) 
		f_error;;

esac 

exit
}

f_scan(){

  echo 
  echo -n "Descubrir host por arp s/n: "
  read respuesta
  
  if [ "$respuesta" == "s" ];then 
		echo 
		echo -n "Digite la interface de red: "
		read interface
		if [[ -z $interface ]]; then
          f_error
		fi
		
		arp-scan -l -I $interface | egrep -v '(Interface|arp-scan|packets)' | awk '{print $1}' > $home/datos/ip-arp.txt
		
		scan=$(cat $home/datos/ip-arp.txt|wc -l)
		if [ "$scan" == "0" ];then 
			echo -n "no host fueron encontrados"
			echo
		fi	
		let ips=$scan-1
		
		echo -n "fueron encontradas $ips IPs"
		echo
		echo "Desea Ejecutar Nmap: s/n"
		read respuesta
		if [ "$respuesta" == "s" ];then 
		nmap -iL $home/datos/ip-arp.txt -sS -sV -P0 -T4 --osscan_limit --osscan_guess --host_timeout 15m --max-retries 0 --min_parallelism 100 --max_parallelism 500 -O 
		fi
		
		else
		echo 
		echo -n "Digite la IP, Rango de IP, URL: "
		read ip
		if [[ -z $ip ]]; then
          f_error
		fi
		echo "Desea Ejecutar Nmap a: $ip "
		nmap -sS -sV -P0 -T4 --osscan_limit --osscan_guess --host_timeout 15m --max-retries 0 --min_parallelism 100 --max_parallelism 500 -O $ip

		
		fi
		
exit
}


f_error(){
echo
echo -e "\x1B[1;31m           *** Opción Invalida. ***\x1B[0m"
echo
sleep 2
f_main	
}

f_main(){
clear
f_banner

if [ ! -d $home/datos ]; then
     mkdir -p $home/datos
fi

echo -e "\e[1;34m 1.  RECONONOCIMIENTO\x1B[0m"  
echo
echo -e "\e[1;34m 2.  ESCANEO\e[0m"
echo 
echo -n "Que opcion quieres ejecutar: "
read opcion

case $opcion in 
	1) 
		f_recon;;
	2) 
		f_scan;;
	*) 
		f_error;;
esac
}

while true; do f_main; done

