#!/bin/bash
# Copyright (C) 2025 CEA - All Rights Reserved
# 
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
# 
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <http://www.gnu.org/licenses/>.


if [ "$(id -u)" != "0" ]; then
   echo "[!] This script must be run as root" 1>&2
   exit 1
fi

echo "[+] Configuring the DNS server..."

echo "[+] Configuring DNS zones :"
echo "[+] The domain name of the C&C is www.cnc.com and its address IP is : 50.50.50.53"
echo "[+] The domain name of the loader is www.loader.com and its address IP is : 50.50.50.53"
echo "[+] The domain name of the target is www.target.com and its address IP is : 50.50.50.53"

echo "[+] Moving DNS zone configuration files to /etc/bind..."
sudo cp named.conf.local db.loader.com db.cnc.com db.target.com /etc/bind

echo "[+] Restarting the Bind9 DNS service to apply the configuration changes..."
sudo systemctl restart named

# Prevent the BIND9 service from starting automatically on system boot
sudo systemctl disable named

echo "[+] DNS server configuration completed."
