Split Tag
+
+
+Null Byte
+
+
+%253Ch1%253EDouble%2520Encoded%253C%252Fh1%253E
+
+
+\u003ch1\u003eUnicode\u003c/h1\u003e
+
+
+Hover me
+
+```
+
+### Phase 9: Automated Testing
+
+#### Using Burp Suite
+
+```
+1. Capture request with potential injection point
+2. Send to Intruder
+3. Mark parameter value as payload position
+4. Load HTML injection wordlist
+5. Start attack
+6. Filter responses for rendered HTML
+7. Manually verify successful injections
+```
+
+#### Using OWASP ZAP
+
+```
+1. Spider the target application
+2. Active Scan with HTML injection rules
+3. Review Alerts for injection findings
+4. Validate findings manually
+```
+
+#### Custom Fuzzing Script
+
+```python
+#!/usr/bin/env python3
+import requests
+import urllib.parse
+
+target = "http://target.com/search"
+param = "q"
+
+payloads = [
+ "Test
",
+ "Bold",
+ "",
+ "
",
+ "Click",
+ "Styled
",
+ "",
+ "",
+]
+
+for payload in payloads:
+ encoded = urllib.parse.quote(payload)
+ url = f"{target}?{param}={encoded}"
+
+ try:
+ response = requests.get(url, timeout=5)
+ if payload.lower() in response.text.lower():
+ print(f"[+] Possible injection: {payload}")
+ elif "" in response.text or "" in response.text:
+ print(f"[?] Partial reflection: {payload}")
+ except Exception as e:
+ print(f"[-] Error: {e}")
+```
+
+### Phase 10: Prevention and Remediation
+
+Secure coding practices:
+
+```php
+// PHP: Escape output
+echo htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');
+
+// PHP: Strip tags
+echo strip_tags($user_input);
+
+// PHP: Allow specific tags only
+echo strip_tags($user_input, '
');
+```
+
+```python
+# Python: HTML escape
+from html import escape
+safe_output = escape(user_input)
+
+# Python Flask: Auto-escaping
+{{ user_input }} # Jinja2 escapes by default
+{{ user_input | safe }} # Marks as safe (dangerous!)
+```
+
+```javascript
+// JavaScript: Text content (safe)
+element.textContent = userInput;
+
+// JavaScript: innerHTML (dangerous!)
+element.innerHTML = userInput; // Vulnerable!
+
+// JavaScript: Sanitize
+const clean = DOMPurify.sanitize(userInput);
+element.innerHTML = clean;
+```
+
+Server-side protections:
+- Input validation (whitelist allowed characters)
+- Output encoding (context-aware escaping)
+- Content Security Policy (CSP) headers
+- Web Application Firewall (WAF) rules
+
+## Quick Reference
+
+### Common Test Payloads
+
+| Payload | Purpose |
+|---------|---------|
+| `Test
` | Basic rendering test |
+| `Bold` | Simple formatting |
+| `Link` | Link injection |
+| `
` | Image tag test |
+| `` | Style injection |
+| `