# Create the HTML code for DOM-based XSS
html_code = """
<!DOCTYPE html>
<html>
<head>
<title>DOM Based XSS Demonstration</title>
</head>
<body>
<h2>University Course Portal</h2>
<div id="result"></div>
<script>
// Read the URL parameters
const params = new URLSearchParams(window.location.search);
// Get the course value from the URL
const course = params.get("course");
// Insert the URL value into the webpage
// Vulnerable DOM operation
document.getElementById("result").innerHTML = course;
</script>
</body>
</html>
"""
# Create an HTML file
with open("dom_xss.html", "w") as file:
file.write(html_code)
# Display a completion message
print("DOM-based XSS HTML file created successfully!")
print("Open dom_xss.html in a web browser to test it.")
To embed this project on your website, copy the following code and paste it into your website's HTML: