Reconnaissance is a critical phase in cybersecurity and bug bounty hunting. By automating repetitive tasks, you can save time and focus on identifying vulnerabilities. In this guide, we’ll show you how to automate reconnaissance using Bash and Python scripts, enabling you to collect, organize, and analyze data more efficiently.
Why Automate Reconnaissance?
- Efficiency: Speed up repetitive tasks like subdomain enumeration, port scanning, or HTTP probing.
- Consistency: Reduce errors caused by manual steps.
- Focus: Free up time for deeper analysis of critical findings.
Step 1: Setting Up Your Environment
Before diving into scripting, ensure you have the necessary tools installed:
- Linux/Unix environment: Bash comes pre-installed.
- Python 3: Install it via your package manager (e.g.,
sudo apt install python3). - Recon tools: Tools like
nmap,amass,subfinder, andhttpx. Install them usingaptor download them from GitHub.
Step 2: Bash Script for Reconnaissance
Let’s start with a Bash script to automate subdomain enumeration, HTTP probing, and port scanning.
Bash Script Example
How to Run
- Save the script as
recon.sh. - Make it executable:
chmod +x recon.sh. - Run the script:
./recon.sh example.com.
Step 3: Python Script for Data Analysis
Python is perfect for parsing and analyzing the data collected during reconnaissance. Below is a script to extract and analyze HTTP status codes.
Python Script Example
How to Run
- Install
requests:pip install requests. - Save the script as
analyze_status.py. - Run the script:
python3 analyze_status.py.
Step 4: Combining Bash and Python
Integrate both scripts by calling the Python script at the end of the Bash script:
echo "[+] Analyzing HTTP status codes..."
python3 analyze_status.py
Step 5: Automating with Cron Jobs
Set up a cron job to run your reconnaissance scripts regularly:
- Open the cron editor:
crontab -e. - Add a cron job
Key Tools for Reconnaissance
- Subfinder: Fast subdomain enumeration.
- Amass: Comprehensive subdomain discovery.
- HTTPx: HTTP probing for live hosts.
- Nmap: Network scanning.
- Python libraries:
requests,argparse,concurrent.futures.
Conclusion
Automating reconnaissance with Bash and Python can significantly streamline your workflow. Start with basic scripts and expand them as you encounter new challenges. With time, you’ll have a powerful, customized toolkit for bug bounty hunting or penetration testing.
