Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ addd Public

Small script written in Bash, to quickly add domain names and their IPs in /etc/hosts and delete old entries.

Notifications You must be signed in to change notification settings

4ndymcfly/addd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 

Repository files navigation

ADDD - Advanced Domain DNS Daemon

Version License Bash Platform

Professional /etc/hosts management tool for penetration testing and CTF challenges

Features β€’ Installation β€’ Usage β€’ Examples β€’ Troubleshooting


πŸ“‹ Table of Contents


🎯 Overview

ADDD is a powerful Bash script designed to simplify /etc/hosts file management during penetration testing, CTF competitions, and general system administration. It provides an intuitive interface with color-coded output, automatic backups, and comprehensive error handling.

Why ADDD?

During penetration testing and CTF challenges, you often need to:

  • Quickly add discovered subdomains to /etc/hosts
  • Manage multiple domains pointing to the same IP
  • Clean up entries after completing a challenge
  • Search for previously added domains

ADDD streamlines all these tasks with simple commands and prevents common mistakes like duplicate entries or invalid IPs.


✨ Features

Core Functionality

  • βœ… Add domains - Single or multiple domains to any IP address
  • βœ… List entries - View all custom DNS entries in a formatted table
  • βœ… Search domains - Quickly find which IP a domain points to
  • βœ… Remove domains - Delete specific domains without affecting others
  • βœ… Edit entries - Change a domain's IP address
  • βœ… Clean all - Remove all custom entries at once

Safety & Reliability

  • πŸ”’ Automatic backups - Creates /etc/hosts.old before first modification
  • βœ… IP validation - Prevents invalid IP addresses
  • πŸ” Duplicate detection - Avoids creating duplicate entries
  • 🎨 Color-coded output - Easy to read success/error messages
  • πŸ“Š Summary reports - Shows what was added, skipped, or removed

Smart Management

  • πŸ”„ Intelligent merging - Automatically adds domains to existing IP entries
  • 🧹 Clean removal - Removes entire line if last domain or just the domain if others exist
  • πŸ”Ž Pattern matching - Uses word boundaries to prevent partial matches
  • πŸ“ Organized structure - Keeps custom entries under # Others section

πŸš€ Installation

Quick Install (Recommended)

# Clone the repository
git clone https://github.com/4ndymcfly/addd.git

# Navigate to directory
cd addd

# Make executable
chmod +x addd.sh

# Optional: Install globally
sudo cp addd.sh /usr/local/bin/addd

Manual Installation

# Download the script
wget https://raw.githubusercontent.com/4ndymcfly/addd/main/addd.sh

# Make executable
chmod +x addd.sh

# Move to PATH (optional)
sudo mv addd.sh /usr/local/bin/addd

Verify Installation

sudo ./addd.sh --help
# or if installed globally:
sudo addd --help

πŸ“– Usage

All commands require root privileges (sudo)

sudo addd.sh [OPTIONS] [ARGUMENTS]

Basic Syntax

Command Description
addd.sh <IP> <domain> Add a single domain
addd.sh <IP> <domain1> <domain2> ... Add multiple domains to same IP
addd.sh -l List all custom entries
addd.sh -s <domain> Search for a domain
addd.sh -r <domain> Remove a specific domain
addd.sh -e <domain> <new_ip> Edit domain's IP address
addd.sh -c Clean all custom entries
addd.sh -h Show help

πŸ”§ Command Reference

Add Domain(s)

# Add single domain
sudo addd.sh 10.10.10.50 contoso.htb

# Add multiple domains to same IP
sudo addd.sh 10.10.10.50 contoso.htb www.contoso.htb admin.contoso.htb

Output:

[+] Backup created: /etc/hosts.old
[+] Added new entry: 10.10.10.50 contoso.htb
[+] Added 'www.contoso.htb' to existing IP 10.10.10.50
[+] Added 'admin.contoso.htb' to existing IP 10.10.10.50

Summary: 3 added, 0 skipped

List Entries

sudo addd.sh --list
# or
sudo addd.sh -l

Output:

═══════════════════════════════════════════════════════════════
Custom DNS Entries in /etc/hosts:
═══════════════════════════════════════════════════════════════
IP Address      Domain(s)
10.10.10.50     contoso.htb www.contoso.htb admin.contoso.htb
10.10.10.60     example.htb api.example.htb

Search Domain

sudo addd.sh --search contoso.htb
# or
sudo addd.sh -s contoso.htb

Output:

Searching for 'contoso.htb'...

[+] Found: contoso.htb β†’ 10.10.10.50

Remove Domain

sudo addd.sh --remove admin.contoso.htb
# or
sudo addd.sh -r admin.contoso.htb

Output:

[+] Removed 'admin.contoso.htb' from IP 10.10.10.50 in /etc/hosts

Edit Domain's IP

sudo addd.sh --edit contoso.htb 10.10.10.60
# or
sudo addd.sh -e contoso.htb 10.10.10.60

Output:

[+] Updated 'contoso.htb': 10.10.10.50 β†’ 10.10.10.60

Clean All Entries

sudo addd.sh --clean
# or
sudo addd.sh -c

Output:

[+] All custom entries have been removed from /etc/hosts

πŸ’‘ Examples

Scenario 1: Starting a HackTheBox Machine

# Add the machine's IP and hostname
sudo addd.sh 10.10.10.50 soccer.htb

# Later, discover subdomains during enumeration
sudo addd.sh 10.10.10.50 soc-player.soccer.htb

# List all entries to verify
sudo addd.sh -l

Scenario 2: CTF with Multiple Services

# Add main domain and discovered subdomains
sudo addd.sh 192.168.1.100 ctf.local www.ctf.local admin.ctf.local api.ctf.local

# Search for a specific subdomain
sudo addd.sh -s admin.ctf.local

# Remove a subdomain that's no longer needed
sudo addd.sh -r api.ctf.local

Scenario 3: Managing Multiple Targets

# Add different targets
sudo addd.sh 10.10.10.50 target1.htb
sudo addd.sh 10.10.10.60 target2.htb www.target2.htb
sudo addd.sh 10.10.10.70 target3.htb

# List all targets
sudo addd.sh -l

# Target IP changed? Update it
sudo addd.sh -e target2.htb 10.10.10.65

# Finished with all targets? Clean up
sudo addd.sh -c

Scenario 4: Subdomain Discovery Workflow

# Initial target
sudo addd.sh 10.10.10.50 example.htb

# Found subdomains via gobuster/ffuf
sudo addd.sh 10.10.10.50 admin.example.htb dev.example.htb staging.example.htb

# Found more during testing
sudo addd.sh 10.10.10.50 api.example.htb cdn.example.htb

# Verify all added correctly
sudo addd.sh -l

🎯 Common Use Cases

HackTheBox / TryHackMe / CTF Platforms

# Standard workflow
sudo addd.sh <MACHINE_IP> <machine>.htb
sudo addd.sh -s <machine>.htb  # Verify it was added
# ... perform your testing ...
sudo addd.sh -c  # Clean up when done

Web Application Pentesting

# Add discovered virtual hosts
sudo addd.sh 192.168.1.50 app.company.local admin.company.local

# Update IP if moved to different environment
sudo addd.sh -e app.company.local 10.0.0.50
sudo addd.sh -e admin.company.local 10.0.0.50

Local Development Testing

# Set up local dev environment
sudo addd.sh 127.0.0.1 myapp.local api.myapp.local admin.myapp.local

# List to verify
sudo addd.sh -l

πŸ› οΈ Troubleshooting

Permission Denied

Problem: Permission denied error when running the script

Solution:

# Ensure you're running with sudo
sudo ./addd.sh <arguments>

# Or make sure the script is executable
chmod +x addd.sh

Invalid IP Address

Problem: Invalid IP address format error

Solution:

  • Verify the IP format is correct (e.g., 10.10.10.50, not 10.10.10.256)
  • Each octet must be 0-255
# βœ… Correct
sudo addd.sh 10.10.10.50 example.htb

# ❌ Incorrect
sudo addd.sh 10.10.10.256 example.htb

Domain Already Exists

Problem: Domain already exists in /etc/hosts

Solution:

# Search where it currently points
sudo addd.sh -s domain.htb

# Option 1: Remove and re-add
sudo addd.sh -r domain.htb
sudo addd.sh <new_ip> domain.htb

# Option 2: Use edit command
sudo addd.sh -e domain.htb <new_ip>

Can't Find Domain

Problem: Cannot find a domain you know you added

Solution:

# List all entries to see what's there
sudo addd.sh -l

# Check if it's in a different section of /etc/hosts
cat /etc/hosts | grep domain.htb

# Search using the tool
sudo addd.sh -s domain.htb

Backup Not Created

Problem: Want to restore but no /etc/hosts.old exists

Solution:

  • The backup is only created on the first modification
  • If you need to restore, copy from your system backup or:
# Manual backup before using
sudo cp /etc/hosts /etc/hosts.backup

# Restore if needed
sudo cp /etc/hosts.backup /etc/hosts

Colors Not Showing

Problem: Color codes appearing as text instead of colors

Solution:

  • Ensure your terminal supports ANSI colors
  • Try a different terminal emulator (e.g., GNOME Terminal, iTerm2, Windows Terminal)

πŸ“Έ Screenshots

Help Screen

═══════════════════════════════════════════════════════════════
  ADDD - Advanced Domain DNS Daemon v2.0
  /etc/hosts management tool for pentesting
═══════════════════════════════════════════════════════════════

USAGE:
  ./addd.sh <IP> <domain> [domain2] [domain3] ...  # Add domain(s) to IP
  ./addd.sh -l | --list                            # List all custom entries
  ./addd.sh -s | --search <domain>                  # Search for a domain
  ./addd.sh -r | --remove <domain>                  # Remove a specific domain
  ./addd.sh -c | --clean                           # Remove all custom entries
  ./addd.sh -e | --edit <domain> <new_ip>            # Edit domain's IP
  ./addd.sh -h | --help                            # Show this help

🀝 Contributing

Contributions are welcome! Feel free to:

  • πŸ› Report bugs
  • πŸ’‘ Suggest new features
  • πŸ”§ Submit pull requests
  • πŸ“– Improve documentation

Development

# Fork and clone the repo
git clone https://github.com/yourusername/addd.git
cd addd

# Make your changes
# Test thoroughly with different scenarios

# Submit a PR

πŸ“„ License

This project is licensed under the MIT License - see the repository for details.


πŸ‘€ Author

4ndyMcFly


πŸ™ Acknowledgments

  • Inspired by the needs of the pentesting and CTF community
  • Built for efficiency during HackTheBox, TryHackMe, and CTF challenges
  • Thanks to all contributors and users providing feedback

πŸ“Š Project Stats

GitHub stars GitHub forks GitHub watchers


⭐ If you find this tool useful, please consider giving it a star! ⭐

Made with ❀️ for the pentesting community

Report Bug β€’ Request Feature

About

Small script written in Bash, to quickly add domain names and their IPs in /etc/hosts and delete old entries.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages