forked from advanced-security-demo/demo-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvulnerable_xss.py
More file actions
67 lines (50 loc) · 1.44 KB
/
Copy pathvulnerable_xss.py
File metadata and controls
67 lines (50 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from flask import Flask, request, render_template_string, make_response
app = Flask(__name__)
@app.route('/hello')
def hello():
name = request.args.get('name', 'Guest')
return f"<h1>Hello, {name}!</h1>"
@app.route('/comment', methods=['POST'])
def post_comment():
comment = request.form.get('comment', '')
html = f"""
<html>
<body>
<h2>Your comment:</h2>
<p>{comment}</p>
</body>
</html>
"""
return html
@app.route('/search')
def search():
query = request.args.get('q', '')
template = f"<h1>Search results for: {query}</h1>"
return render_template_string(template)
@app.route('/profile')
def profile():
username = request.args.get('user', 'Anonymous')
bio = request.args.get('bio', '')
page = f"""
<html>
<head><title>User Profile</title></head>
<body>
<h1>{username}</h1>
<div>{bio}</div>
</body>
</html>
"""
return page
@app.route('/error')
def error_page():
error_msg = request.args.get('msg')
return f"<div class='error'>{error_msg}</div>"
@app.route('/dashboard')
def dashboard():
user_input = request.args.get('data', '')
response = make_response(f"<p>Dashboard data: {user_input}</p>")
return response
def render_user_content(content):
return f"<div class='user-content'>{content}</div>"
if __name__ == '__main__':
app.run(debug=True)