Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Apache2Domain.sh | Author: r00t-3xp10it
- # https://sourceforge.net/u/peterubuntu10/profile/
- # ---
- # Config apache2 domain name eg. http://malign0server.com
- # Domain name directorys will be build inside apache2 webroot
- # Example: /var/www/html/public_html/malign0server.com
- # apachedomain.log will be build in working directory
- # ---
- # works in apache/2.2.22 or apache/2.4 (tested)
- # works in linux ubuntu and kali 2.0 or old (tested)
- # screenshot: https://dl.dropboxusercontent.com/u/21426454/malign0server.png
- # ---
- # ---------------------
- # check if user is root
- # ---------------------
- if [ $(id -u) != "0" ]; then
- echo "[☠ ] we need to be root to run this script..."
- echo "[☠ ] execute [ sudo ./apachedomain.sh ] on terminal"
- exit
- else
- echo "root user" > /dev/null 2>&1
- fi
- # ----------------------
- # variable declarations
- # ----------------------
- OS=`uname` # grab OS
- H0m3=`echo ~` # grab home path
- user=`who | cut -d' ' -f1 | sort | uniq` # grab username
- DiStR0=`awk '{print $1}' /etc/issue` # grab distribution - Ubuntu or Kali
- InT3R=`netstat -r | grep "default" | awk {'print $8'}` # grab interface in use
- IP=`ifconfig $InT3R | egrep -w "inet" | cut -d ':' -f2 | cut -d 'B' -f1`
- IPATH=`pwd` # grab apachesetup.sh install path
- clear
- echo ""
- # simple banner
- echo "[☆ ] Author: r00t-3xp10it"
- echo "[☆ ] CONFIG OR DELETE APACHE2 WEBSERVER DOMAIN NAME"
- echo "[☆ ] DIRECTORYS WILL BE WRITEN INSIDE APACHE2 WEBROOT"
- echo "[☆ ] E.G. /var/www/html/public_html/domain_name.com"
- echo "[☆ ] APACHE2 (DOMAIN NAME) CAN BE ACCESSED IN:"
- echo "[☆ ] E.G. http://domain_name.com"
- echo "" && echo ""
- # check if apache2 exists
- ch3=`which apache2`
- if [ "$?" -eq "0" ]; then
- echo "[✔ ] apache2 webserver..........[found]"
- sleep 2
- else
- echo ""
- echo "[☠ ] apache2 webserver -> not found ]"
- echo "[☠ ] This script requires apache2 ]"
- echo ""
- sudo apt-get install apache2
- echo ""
- sleep 2
- fi
- # -----------------------------------------------
- # grab apache2 webroot path or config domain name
- # http://192.168.1.208 OR http://malign0server
- # -----------------------------------------------
- # Input apache2 webroot path
- ApAcHe=$(zenity --title "☠ Enter APACHE2 WEBROOT PATH ☠" --text "example: /var/www/html" --entry --width 330) > /dev/null 2>&1
- QuE=$(zenity --list --title "APACHE2 DOMAIN NAME CONFIGURATION" --text "\nChose option:" --radiolist --column "Pick" --column "Option" TRUE "Build new domain name" FALSE "Delete old domain name" --width 350 --height 190) > /dev/null 2>&1
- if [ "$QuE" = "Build new domain name" ]; then
- # check if running Apache/2.2 or Apache/2.4
- apache2 -v | grep "Server version" | cut -d ':' -f2 | cut -d '(' -f1 >> version.log
- sed -i "s/ //g" version.log
- un=`cat version.log`
- rm version.log > /dev/null 2>&1
- D0MaIn=$(zenity --title="ENTER DOMAIN NAME TO USE" --text "example: malign0server.com" --entry --width 330) > /dev/null 2>&1
- if [ "$un" = "Apache/2.2.22" ]; then
- # build malign0server.conf apache 2.2
- echo "[✔ ] Building -> $D0MaIn.conf"
- echo "<VirtualHost *:80>" > /etc/apache2/sites-available/$D0MaIn.conf
- echo " ServerName $D0MaIn" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo " DocumentRoot $ApAcHe/public_html/$D0MaIn" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo "</VirtualHost>" >> /etc/apache2/sites-available/$D0MaIn.conf
- sleep 2
- else
- # build malign0server.conf apache 2.4
- echo "[✔ ] Building -> $D0MaIn.conf"
- echo "<VirtualHost *:80>" > /etc/apache2/sites-available/$D0MaIn.conf
- echo " ServerName $D0MaIn" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo " DocumentRoot $ApAcHe/public_html/$D0MaIn" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo " <Directory $ApAcHe/public_html/$D0MaIn/>" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo " Require all granted" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo " </Directory>" >> /etc/apache2/sites-available/$D0MaIn.conf
- echo "</VirtualHost>" >> /etc/apache2/sites-available/$D0MaIn.conf
- sleep 2
- fi
- # build directorys needed by malign0server.conf
- echo "[✔ ] Building -> Domain directorys"
- mkdir -p $ApAcHe/public_html/$D0MaIn
- echo "<html><H1>NEW DOMAIN WORKING ...</H1></html>" > $ApAcHe/public_html/$D0MaIn/index.html
- sudo chmod -R g+rw $ApAcHe/public_html/$D0MaIn
- sleep 2
- # config hosts file (DNS record)
- echo "[✔ ] Added -> DNS record to /etc/hosts"
- echo "127.0.0.1 $D0MaIn" >> /etc/hosts
- echo "" && echo ""
- sleep 2
- # enable new site
- a2ensite $D0MaIn.conf
- /etc/init.d/apache2 restart
- # append recent configs to logfile
- echo "#################################" >> apachedomain.log
- echo "# apache domain - configuration #" >> apachedomain.log
- echo "#################################" >> apachedomain.log
- echo "# apache2 webroot path" >> apachedomain.log
- echo "APACHE_WEBROOT=$ApAcHe" >> apachedomain.log
- echo "DOMAIN_NAME=$D0MaIn" >> apachedomain.log
- echo "URL_VECTOR=http://$D0MaIn" >> apachedomain.log
- echo "/ETC/HOSTS_FILE=127.0.0.1 $D0MaIn" >> apachedomain.log
- echo "DOMAIN_ROOT=$ApAcHe/public_html/$D0MaIn" >> apachedomain.log
- echo "" >> apachedomain.log
- echo "# files build:" >> apachedomain.log
- echo "/etc/apache2/sites-available/$D0MaIn.conf" >> apachedomain.log
- echo "/etc/apache2/sites-enabled/$D0MaIn.conf" >> apachedomain.log
- echo "$ApAcHe/public_html/$D0MaIn" >> apachedomain.log
- echo "/etc/hosts" >> apachedomain.log
- echo "" >> apachedomain.log
- echo "" >> apachedomain.log
- echo ""
- # display active configs to user
- echo "[☆ ] APACHE_WEBROOT -> $ApAcHe"
- echo "[☆ ] DOMAIN_NAME -> $D0MaIn"
- echo "[☆ ] URL_VECTOR -> http://$D0MaIn"
- echo "[☆ ] HOSTS_FILE -> 127.0.0.1 $D0MaIn"
- echo "[☆ ] DOMAIN_ROOT -> $ApAcHe/public_html/$D0MaIn"
- echo ""
- echo "[✔ ] [ ☠ YOUR '$D0MaIn' DOMAIN ITS READY TO BE USED ☠ ]..."
- sleep 2
- echo "[☆ ] RUN THIS SCRIPT AGAIN IF YOU WISH TO DELETE RECENT CONFIGS"
- echo "[☆ ] OR CONFIG A NEW DOMAIN NAME TO USE IN APACHE2 WEBSERVER"
- echo "[☆ ] REMMENBER TO CHECK 'apachedomain.log' FOR FURTHER INFO."
- sleep 2
- else
- # use default configuration
- D0MaIn=$(zenity --title="ENTER DOMAIN NAME TO DELETE" --text "example: malign0server.com" --entry --width 330) > /dev/null 2>&1
- echo "[✔ ] apache2 -> default config in use!"
- rm /etc/apache2/sites-available/$D0MaIn.conf > /dev/null 2>&1
- rm /etc/apache2/sites-enabled/$D0MaIn.conf > /dev/null 2>&1
- rm apachedomain.log > /dev/null 2>&1
- rm -r $ApAcHe/public_html > /dev/null 2>&1
- sed "s|127.0.0.1 $D0MaIn||" /etc/hosts > /etc/hosts.bak
- mv /etc/hosts.bak /etc/hosts > /dev/null 2>&1
- echo "" && echo ""
- /etc/init.d/apache2 restart
- sleep 2
- echo ""
- # display active configs to user
- echo "[☆ ] APACHE_WEBROOT -> $ApAcHe"
- echo "[☆ ] DOMAIN_NAME -> localhost"
- echo "[☆ ] URL_VECTOR -> http://$IP"
- echo "[✔ ] RUN THIS SCRIPT AGAIN IF YOU WISH TO CONFIG A NEW DOMAIN NAME"
- echo ""
- /etc/init.d/apache2 stop
- fi
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement