Last active
May 28, 2020 20:02
-
-
Save sumgr0/e89176a4cc75157c07b81eae9cad3159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
domain=$1 | |
root="/var/www/$domain/html" | |
block="/etc/nginx/sites-available/$domain" | |
# Create the Document Root directory | |
sudo mkdir -p $root | |
#Create index.html & POC file | |
echo '<b> The webpage is currently under maintanence, kindly visit later! </b>' > $root/index.html | |
echo '<! PoC of sub-domain takeover by @sumgr0!>' > $root/sumgr0.html | |
# Assign ownership to your regular user account | |
sudo chown -R $USER:$USER $root | |
# Create the Nginx server block file: | |
sudo tee $block > /dev/null <<EOF | |
server { | |
listen 80; | |
listen [::]:80; | |
root /var/www/$domain/html; | |
index index.html index.htm; | |
server_name $domain www.$domain; | |
location / { | |
try_files \$uri \$uri/ =404; | |
} | |
} | |
EOF | |
# Link to make it available | |
sudo ln -s $block /etc/nginx/sites-enabled/ | |
# Test configuration and reload if successful | |
sudo nginx -t && sudo service nginx reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment