Recon automation with Telegram Notification

7 months ago 68
BOOK THIS SPACE FOR AD
ARTICLE AD

Hello, fellow cybersecurity enthusiasts. I’m Tahir Mujawar, a Certified Ethical Hacker and Security Researcher. With a passion for innovation and a dedication to cybersecurity excellence, I’m excited to share insights on automating subdomain enumeration and leveraging Telegram for real-time notifications.

Automating Subdomain Enumeration with Telegram Notification.

Before diving into the automation of subdomain enumeration, let’s ensure we have the necessary tools installed, If you don’t have the tools installed hit the following commands one by one to install them.

Sublist3rgit clone https://github.com/aboul3la/Sublist3r.git
cd Sublist3r
pip install -r requirements.txt

2. Subfinder

wget https://github.com/projectdiscovery/subfinder/releases/download/v2.4.5/subfinder-linux-amd64.tar.gz
tar -xzvf subfinder-linux-amd64.tar.gz
sudo mv subfinder /usr/local/bin/

3. Assetfinder

wget https://github.com/tomnomnom/assetfinder/releases/download/v0.1.0/assetfinder-linux-amd64.tar.gz
tar -xzvf assetfinder-linux-amd64.tar.gz
sudo mv assetfinder /usr/local/bin/

4. Amass

wget https://github.com/OWASP/Amass/releases/download/v3.16.1/amass_linux_amd64.zip
unzip amass_linux_amd64.zip
sudo mv amass_linux_amd64/amass /usr/local/bin/

You can add more tools according to your preferences.

Let’s set up Telegram notifications for real-time alerts :

Create a Telegram BotStart a conversation with BotFather on Telegram.Use the /newbot command to create a new bot and follow the prompts to set up its name and username.Retrieve the bot token provided by BotFather for authentication purposes.

2. Obtain Your Chat ID

Initiate a conversation with your newly created bot on Telegram.Send a message to the bot to initiate the chat.Visit https://api.telegram.org/bot<YourBOTToken>/getUpdates in your web browser to retrieve your chat ID.

3. Integrate Telegram Notifications in the Script

Replace "your_bot_token" and "your_chat_id" placeholders in the Bash script with your actual bot token and chat ID.This enables the script to send notifications upon completion of subdomain enumeration.#!/bin/bash

# Bash script for subdomain enumeration and Telegram notifications

# Function to send notification to Telegram
send_telegram_notification() {
echo "Sending Telegram notification..."

# Set Telegram bot token and chat ID
TELEGRAM_BOT_TOKEN="your_bot_token" # Replace with your bot token
TELEGRAM_CHAT_ID="your_chat_id" # Replace with your chat ID

# Compose message
MESSAGE="Subdomain Enumeration Complete for $DOMAIN Results are saved in $DOMAIN directory."

# Send message using Telegram Bot API
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" -d "chat_id=$TELEGRAM_CHAT_ID" -d "text=$MESSAGE" > /dev/null

if [ $? -eq 0 ]; then
echo "Telegram notification sent successfully."
else
echo "Failed to send Telegram notification."
fi
}

# Function to perform subdomain enumeration
perform_subdomain_enumeration() {
DOMAIN="$1"
OUTPUT_DIR="$DOMAIN"
mkdir "$OUTPUT_DIR"

# Subdomain enumeration using sublist3r
echo "Running sublist3r..."
sublist3r -d "$DOMAIN" -o "$OUTPUT_DIR/sublist3r.txt"

# Subdomain enumeration using subfinder
echo "Running subfinder..."
subfinder -d "$DOMAIN" -o "$OUTPUT_DIR/subfinder.txt"

# Subdomain enumeration using assetfinder
echo "Running assetfinder..."
assetfinder "$DOMAIN" > "$OUTPUT_DIR/assetfinder.txt"

# Subdomain enumeration using amass
echo "Running amass..."
amass enum -d "$DOMAIN" -o "$OUTPUT_DIR/amass.txt"

echo "Subdomain enumeration completed. Results saved in $OUTPUT_DIR directory."

# Send Telegram notification if requested
if [[ "$SEND_NOTIFICATION" == "yes" ]]; then
send_telegram_notification
fi
}

# Main script
echo "Welcome to Subdomain Enumeration Script! By Tahir Mujawar"

# Ask user if they want to receive notification
read -p "Do you want to receive notification upon completion of subdomain enumeration? (yes/no): " SEND_NOTIFICATION

# Ask user for the domain name for subdomain enumeration
read -p "Enter the domain name for subdomain enumeration: " DOMAIN

# Perform

How to Use It

Copy the provided Bash script code into a text editor such as Nano or Vim.Save the file with a .sh extension (e.g., subdomain_enumeration.sh).Ensure that the file has execute permissions (e.g., chmod +x subdomain_enumeration.sh).Open a terminal and navigate to the directory containing the script.Execute the script by running ./subdomain_enumeration.sh.Follow the prompts to configure Telegram notifications (if desired) and specify the target domain for subdomain enumeration.Sit back and let the script do the work. Results will be saved in a directory named after the target domain. (e.g., example.com)

Thank you for joining me on this journey of automation and cybersecurity vigilance. Don’t forget to hit like, share, and follow for more tech insights and solutions. Stay tuned for the next adventure in securing our digital world!

Bye bye Hackers.! Happy Hacking :)

Read Entire Article