#!/bin/bash
TARGET="https://target.com"
response=$(curl -s "$TARGET/nonexistent")
if echo "$response" | grep -q "Using the URLconf defined in"; then
echo "[VULN] Django DEBUG=True detected"
fi
if echo "$response" | grep -q "Werkzeug Debugger"; then
echo "[VULN] Flask debug mode detected"
fi
if echo "$response" | grep -q "Stack Trace:"; then
echo "[VULN] ASP.NET detailed errors enabled"
fi
if echo "$response" | grep -qiE "Fatal error:|Parse error:|Warning:.*on line"; then
echo "[VULN] PHP errors displayed"
fi
if echo "$response" | grep -q "at Layer.handle"; then
echo "[VULN] Express.js stack trace exposed"
fi
import requests
import re
class StackTraceTester:
def __init__(self, base_url):
self.base_url = base_url
self.findings = []
STACK_TRACE_PATTERNS = {
'java': r'at\s+[\w.]+\([\w.]+:\d+\)',
'python': r'File\s+"[^"]+",\s+line\s+\d+',
'dotnet': r'at\s+[\w.]+\s+in\s+[^:]+:\d+',
'php': r'in\s+/[\w/]+\.php\s+on\s+line\s+\d+',
'nodejs': r'at\s+[\w.]+\s+\([^)]+:\d+:\d+\)',
'ruby': r'from\s+[\w/]+\.rb:\d+',
}
FRAMEWORK_PATTERNS = {
'django': r'Using the URLconf defined in|Django Version:',
'flask': r'Werkzeug Debugger|werkzeug\.exceptions',
'rails': r'ActionController::RoutingError|Rails\.root:',
'spring': r'org\.springframework\.|Whitelabel Error Page',
'express': r'at Layer\.handle|at Route\.dispatch',
'laravel': r'Illuminate\\|app/Exceptions/Handler',
}
def test_endpoints(self, endpoints):
"""Test multiple endpoints for stack traces"""
print("[*] Testing for stack trace exposure...")
for endpoint in endpoints:
self._test_endpoint(endpoint)
return self.findings
def _test_endpoint(self, endpoint):
"""Test single endpoint"""
payloads = ["'", "null", "0", "{{7*7}}", "../"]
for payload in payloads:
try:
url = f"{self.base_url}{endpoint}?id={payload}"
response = requests.get(url, timeout=10)
self._analyze_response(url, response.text)
except requests.exceptions.RequestException:
pass
def _analyze_response(self, url, content):
"""Analyze response for stack traces"""
for lang, pattern in self.STACK_TRACE_PATTERNS.items():
if re.search(pattern, content):
print(f"[VULN] {lang.upper()} stack trace at: {url}")
self.findings.append({
"url": url,
"type": f"{lang}_stack_trace",
"severity": "Medium"
})
for framework, pattern in self.FRAMEWORK_PATTERNS.items():
if re.search(pattern, content, re.IGNORECASE):
print(f"[VULN] {framework.upper()} debug mode at: {url}")
self.findings.append({
"url": url,
"type": f"{framework}_debug",
"severity": "High"
})
def generate_report(self):
"""Generate findings report"""
print("\n" + "="*50)
print("STACK TRACE EXPOSURE REPORT")
print("="*50)
if not self.findings:
print("\nNo stack traces found.")
return
print(f"\nFindings: {len(self.findings)}")
for f in self.findings:
print(f"\n [{f['severity']}] {f['type']}")
print(f" URL: {f['url']}")
tester = StackTraceTester("https://target.com")
tester.test_endpoints(["/api/user", "/api/search", "/api/product"])
tester.generate_report()