Skip to content

Instantly share code, notes, and snippets.

@sumgr0
Last active May 28, 2020 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumgr0/e89176a4cc75157c07b81eae9cad3159 to your computer and use it in GitHub Desktop.
Save sumgr0/e89176a4cc75157c07b81eae9cad3159 to your computer and use it in GitHub Desktop.
#!/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