Performing Adversary-in-the-Middle Phishing Detection
Overview
Adversary-in-the-Middle (AiTM) phishing attacks use reverse-proxy infrastructure to sit between the victim and the legitimate authentication service, intercepting both credentials and session cookies in real time. This allows attackers to bypass multi-factor authentication (MFA). The most prevalent PhaaS kits in 2025 include Tycoon 2FA, Sneaky 2FA, EvilProxy, and Evilginx. Over 1 million PhaaS attacks were detected in January-February 2025 alone. These attacks have evolved from QR codes to HTML attachments and SVG files for link distribution.
When to Use
Trigger phrases:
"performing adversary in the middle phishing detection"
"Detect and respond to Adversary-in-the-Middle (AiTM) phishing attacks that use r"
When conducting security assessments that involve performing adversary in the middle phishing detection
When following incident response procedures for related security events
When performing scheduled security testing or auditing activities
When validating security controls through hands-on testing
Prerequisites
- Azure AD / Entra ID Conditional Access policies
- SIEM with authentication log ingestion (Azure AD sign-in logs)
- Web proxy with SSL inspection and URL categorization
- Endpoint Detection and Response (EDR) solution
- FIDO2/phishing-resistant MFA capability
Key Concepts
This section covers key concepts for performing adversary in the middle phishing detection.
- Ensure all prerequisites are met before proceeding
- Follow the documented workflow steps in sequence
- Record results and any anomalies encountered during this phase
How AiTM Works
- Victim receives phishing email with link to attacker-controlled domain
- Attacker domain runs reverse proxy that mirrors legitimate login page
- Victim enters credentials on proxied page; credentials captured in transit
- Reverse proxy forwards credentials to real authentication service
- MFA challenge sent to victim; victim completes MFA on proxied page
- Attacker captures session cookie returned by legitimate service
- Attacker replays session cookie to access victim's account without MFA
Major AiTM Kits (2025)
| Kit |
Type |
Primary Targets |
Evasion |
| Tycoon 2FA |
PhaaS |
Microsoft 365, Google |
CAPTCHA, Cloudflare turnstile |
| EvilProxy |
PhaaS |
Microsoft 365, Google, Okta |
Random URLs, IP rotation |
| Evilginx |
Open-source |
Any web application |
Custom phishlets |
| Sneaky 2FA |
PhaaS |
Microsoft 365 |
Anti-bot checks |
| NakedPages |
PhaaS |
Multiple |
Minimal infrastructure |
Detection Indicators
- Authentication from unusual IP not matching user profile
- Session cookie reuse from different IP/device than authentication
- Login page served from non-Microsoft/non-Google infrastructure
- CDN requests to legitimate auth providers from phishing domains
- Impossible travel between authentication and session usage
Workflow
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- Isolate the sample — ensure the malware is in a sandboxed environment with no network access
- Record file metadata — hash the sample and note file type, size, and compile timestamp
- Static analysis — examine strings, imports, and disassembled code without execution
- Dynamic analysis — execute in a monitored sandbox and record behavior (file, registry, network)
- Document IOCs — extract indicators of compromise and write the analysis report
Step 1: Deploy Phishing-Resistant MFA
- Implement FIDO2 security keys or Windows Hello for Business for high-value accounts
- Configure Conditional Access to require phishing-resistant MFA for admins
- Enable certificate-based authentication where possible
- Disable SMS and voice MFA for privileged accounts
- AiTM cannot intercept FIDO2 because authentication is bound to origin domain
Step 2: Configure Conditional Access Policies
- Require compliant/managed device for sensitive application access
- Block authentication from anonymous proxies and Tor exit nodes
- Enforce token binding to limit session cookie replay
- Configure continuous access evaluation (CAE) for real-time token revocation
- Implement sign-in risk policies that require re-authentication for risky sign-ins
Step 3: Build AiTM Detection Rules
- Alert on sign-in followed by session from different IP within 10 minutes
- Detect authentication where proxy IP does not match user's expected location
- Monitor for impossible travel patterns in session usage
- Alert on inbox rules created immediately after authentication (common post-compromise)
- Detect new MFA method registration from suspicious sign-in
Step 4: Monitor Web Proxy for AiTM Infrastructure
- Log and analyze DNS queries to newly registered domains
- Detect connections to known PhaaS infrastructure IPs
- Alert on authentication page backgrounds loaded from legitimate CDNs through proxy domains
- Monitor for SSL certificates issued to domains mimicking corporate login pages
- Block access to known EvilProxy/Evilginx infrastructure via threat intelligence
Step 5: Implement Post-Compromise Detection
- Alert on mailbox forwarding rules created after suspicious authentication
- Detect OAuth app consent after AiTM sign-in
- Monitor for email sending patterns indicating BEC follow-up
- Alert on SharePoint/OneDrive mass download after session hijack
- Track lateral movement from compromised account
When NOT to Use
- You don't have explicit written authorization to test
- Task is about defense/detection, not offense (use detection skills)
- You need to implement security controls (use implementing-* skills)
- Task requires compliance auditing (use auditing-* skills)
- You're investigating an incident (use incident response skills)
- Target is out of scope for your engagement
- Task is about vulnerability scanning only (use scanning tools)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Analyzing malware on a machine connected to the production network
- Failing to isolate the analysis environment from the internet
- Executing samples without proper containment (VM, sandbox)
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Sample hash recorded and verified (MD5, SHA-1, SHA-256)
- Analysis environment confirmed isolated from production network
- Indicators of compromise (IOCs) extracted and documented
Tools & Resources
- Microsoft Entra ID Protection: Risk-based Conditional Access
- Azure AD Sign-in Logs: Authentication event analysis
- Okta ThreatInsight: AiTM proxy detection at IdP level
- Sekoia TDR: AiTM campaign tracking and intelligence
- Evilginx (defensive): Understanding attack mechanics for detection
Validation
- Phishing-resistant MFA blocks AiTM session capture in test scenario
- Conditional Access denies session replay from different device/IP
- SIEM alerts fire on simulated AiTM sign-in patterns
- Web proxy blocks connections to known PhaaS infrastructure
- Post-compromise rules detect inbox rule creation after suspicious auth
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: performing-adversary-in-the-middle-phishing-detection3description: Use when detect and respond to Adversary-in-the-Middle (AiTM) phishing4 attacks that use reverse proxy kits like EvilProxy, Evilginx, and Tycoon 2FA to5 bypass MFA and steal session tokens. Use when detecting and respond to adversary-in-the-middle6 (aitm) phishing attacks that use.7domain: cybersecurity8subdomain: phishing-defense9tags:10- aitm11- evilproxy12- evilginx13- phishing14- mfa-bypass15- session-hijacking16- reverse-proxy17- credential-theft18version: '1.0'19author: oyi7720license: Apache-2.021nist_csf:22- PR.AT-0123- DE.CM-0924- RS.CO-0225- DE.AE-0226category: cybersecurity27metadata:28 source: https://skillmd.com/skills/oyi77/performing-adversary-in-the-middle-phishing-detection29---3031# Performing Adversary-in-the-Middle Phishing Detection3233## Overview34Adversary-in-the-Middle (AiTM) phishing attacks use reverse-proxy infrastructure to sit between the victim and the legitimate authentication service, intercepting both credentials and session cookies in real time. This allows attackers to bypass multi-factor authentication (MFA). The most prevalent PhaaS kits in 2025 include Tycoon 2FA, Sneaky 2FA, EvilProxy, and Evilginx. Over 1 million PhaaS attacks were detected in January-February 2025 alone. These attacks have evolved from QR codes to HTML attachments and SVG files for link distribution.353637## When to Use38**Trigger phrases:**39- "performing adversary in the middle phishing detection"40- "Detect and respond to Adversary-in-the-Middle (AiTM) phishing attacks that use r"414243- When conducting security assessments that involve performing adversary in the middle phishing detection44- When following incident response procedures for related security events45- When performing scheduled security testing or auditing activities46- When validating security controls through hands-on testing4748## Prerequisites49- Azure AD / Entra ID Conditional Access policies50- SIEM with authentication log ingestion (Azure AD sign-in logs)51- Web proxy with SSL inspection and URL categorization52- Endpoint Detection and Response (EDR) solution53- FIDO2/phishing-resistant MFA capability5455## Key Concepts5657This section covers key concepts for performing adversary in the middle phishing detection.5859- Ensure all prerequisites are met before proceeding60- Follow the documented workflow steps in sequence61- Record results and any anomalies encountered during this phase62### How AiTM Works631. Victim receives phishing email with link to attacker-controlled domain642. Attacker domain runs reverse proxy that mirrors legitimate login page653. Victim enters credentials on proxied page; credentials captured in transit664. Reverse proxy forwards credentials to real authentication service675. MFA challenge sent to victim; victim completes MFA on proxied page686. Attacker captures session cookie returned by legitimate service697. Attacker replays session cookie to access victim's account without MFA7071### Major AiTM Kits (2025)72| Kit | Type | Primary Targets | Evasion |73|---|---|---|---|74| Tycoon 2FA | PhaaS | Microsoft 365, Google | CAPTCHA, Cloudflare turnstile |75| EvilProxy | PhaaS | Microsoft 365, Google, Okta | Random URLs, IP rotation |76| Evilginx | Open-source | Any web application | Custom phishlets |77| Sneaky 2FA | PhaaS | Microsoft 365 | Anti-bot checks |78| NakedPages | PhaaS | Multiple | Minimal infrastructure |7980### Detection Indicators81- Authentication from unusual IP not matching user profile82- Session cookie reuse from different IP/device than authentication83- Login page served from non-Microsoft/non-Google infrastructure84- CDN requests to legitimate auth providers from phishing domains85- Impossible travel between authentication and session usage8687## Workflow8889```python90# Example: IOC detection91import re9293IOC_PATTERNS = {94 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",95 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",96 "hash_md5": r"\b[a-f0-9]{32}\b",97 "hash_sha256": r"\b[a-f0-9]{64}\b",98}99100def extract_iocs(text: str) -> dict:101 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}102```1031041. **Isolate the sample** — ensure the malware is in a sandboxed environment with no network access1052. **Record file metadata** — hash the sample and note file type, size, and compile timestamp1063. **Static analysis** — examine strings, imports, and disassembled code without execution1074. **Dynamic analysis** — execute in a monitored sandbox and record behavior (file, registry, network)1085. **Document IOCs** — extract indicators of compromise and write the analysis report109### Step 1: Deploy Phishing-Resistant MFA110- Implement FIDO2 security keys or Windows Hello for Business for high-value accounts111- Configure Conditional Access to require phishing-resistant MFA for admins112- Enable certificate-based authentication where possible113- Disable SMS and voice MFA for privileged accounts114- AiTM cannot intercept FIDO2 because authentication is bound to origin domain115116### Step 2: Configure Conditional Access Policies117- Require compliant/managed device for sensitive application access118- Block authentication from anonymous proxies and Tor exit nodes119- Enforce token binding to limit session cookie replay120- Configure continuous access evaluation (CAE) for real-time token revocation121- Implement sign-in risk policies that require re-authentication for risky sign-ins122123### Step 3: Build AiTM Detection Rules124- Alert on sign-in followed by session from different IP within 10 minutes125- Detect authentication where proxy IP does not match user's expected location126- Monitor for impossible travel patterns in session usage127- Alert on inbox rules created immediately after authentication (common post-compromise)128- Detect new MFA method registration from suspicious sign-in129130### Step 4: Monitor Web Proxy for AiTM Infrastructure131- Log and analyze DNS queries to newly registered domains132- Detect connections to known PhaaS infrastructure IPs133- Alert on authentication page backgrounds loaded from legitimate CDNs through proxy domains134- Monitor for SSL certificates issued to domains mimicking corporate login pages135- Block access to known EvilProxy/Evilginx infrastructure via threat intelligence136137### Step 5: Implement Post-Compromise Detection138- Alert on mailbox forwarding rules created after suspicious authentication139- Detect OAuth app consent after AiTM sign-in140- Monitor for email sending patterns indicating BEC follow-up141- Alert on SharePoint/OneDrive mass download after session hijack142- Track lateral movement from compromised account143144## When NOT to Use145146- You don't have explicit written authorization to test147- Task is about defense/detection, not offense (use detection skills)148- You need to implement security controls (use implementing-* skills)149- Task requires compliance auditing (use auditing-* skills)150- You're investigating an incident (use incident response skills)151- Target is out of scope for your engagement152- Task is about vulnerability scanning only (use scanning tools)153154155## Red Flags156157- Performing actions without explicit written authorization from the asset owner158- Testing against production systems without a defined scope and rules of engagement159- Analyzing malware on a machine connected to the production network160- Failing to isolate the analysis environment from the internet161- Executing samples without proper containment (VM, sandbox)162163## Verification164165- All steps executed successfully against a test environment before production use166- Output documented with screenshots or logs demonstrating expected behavior167- Sample hash recorded and verified (MD5, SHA-1, SHA-256)168- Analysis environment confirmed isolated from production network169- Indicators of compromise (IOCs) extracted and documented170171## Tools & Resources172- **Microsoft Entra ID Protection**: Risk-based Conditional Access173- **Azure AD Sign-in Logs**: Authentication event analysis174- **Okta ThreatInsight**: AiTM proxy detection at IdP level175- **Sekoia TDR**: AiTM campaign tracking and intelligence176- **Evilginx (defensive)**: Understanding attack mechanics for detection177178## Validation179- Phishing-resistant MFA blocks AiTM session capture in test scenario180- Conditional Access denies session replay from different device/IP181- SIEM alerts fire on simulated AiTM sign-in patterns182- Web proxy blocks connections to known PhaaS infrastructure183- Post-compromise rules detect inbox rule creation after suspicious auth184185## Process1861871. Analyze the task requirements1882. Apply domain expertise1893. Verify output quality190191## Anti-Rationalization Table192193| Rationalization | Reality |194|---|---|195| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |196| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |197| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |