Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ Less than 30 lines of Python + 40 lines HTML template.
As you started the flask app in development mode, any source changes should apply immediately so you can just refresh
the page. If you want to clear the database, just delete the `database.db` file that is (re-)created on first use.

If you are running flask directly and want to run it on all your IP addresses so that others on your LAN can access it (e.g., for a classroom demo -- please do not use this for production on the Internet!), you can do:

```
$ flask run --host=0.0.0.0
```

Again, this should only be used temporarily and in a relatively safe environment.

# Making it vulnerable

To demonstrate XSS flaws you can change
Expand Down
6 changes: 6 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

@app.route('/', methods=['GET', 'POST'])
def index():

name = ''
if request.method == 'GET':
name = request.args.get('name','')

if request.method == 'POST':
db.add_comment(request.form['comment'])

Expand All @@ -14,5 +19,6 @@ def index():
comments = db.get_comments(search_query)

return render_template('index.html',
name=name,
comments=comments,
search_query=search_query)
3 changes: 3 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<!-- Header -->
<header>
<h1>XSS Demo</h1>
{% if name %}
<p>Welcome, {{ name }}!</p>
{% endif %}
<p>Read, search and post comments</p>
</header>

Expand Down