Skip to content

Commit

Permalink
xss-stored-html in pwnshop
Browse files Browse the repository at this point in the history
  • Loading branch information
zardus committed Dec 22, 2024
1 parent c2dfba7 commit af56848
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions web-security/pwnshop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ challenges:
challenge: SQLInjectionSchema
- id: sqli-blind
challenge: SQLInjectionBlind
- id: xss-stored-html
challenge: XSSStoredHTML
14 changes: 11 additions & 3 deletions web-security/xss-stored-html/server
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/opt/pwn.college/python

import tempfile
import sqlite3
import flask
import os

app = flask.Flask(__name__)


import sqlite3
import tempfile


class TemporaryDB:
def __init__(self):
self.db_file = tempfile.NamedTemporaryFile("x", suffix=".db")
Expand All @@ -19,16 +22,20 @@ class TemporaryDB:
connection.commit()
return result


db = TemporaryDB()

# https://www.sqlite.org/lang_createtable.html
db.execute("""CREATE TABLE posts AS SELECT "First Post!" AS content""")


@app.route("/", methods=["POST"])
def challenge_post():
content = flask.request.form.get("content", "")
db.execute("INSERT INTO posts VALUES (?)", [content])
return flask.redirect(flask.request.path)


@app.route("/", methods=["GET"])
def challenge_get():
page = "<html><body>\nWelcome to pwnpost, the anonymous posting service. Post away!\n"
Expand All @@ -39,6 +46,7 @@ def challenge_get():

return page + "</body></html>"


app.secret_key = os.urandom(8)
app.config['SERVER_NAME'] = f"challenge.localhost:80"
app.config["SERVER_NAME"] = f"challenge.localhost:80"
app.run("challenge.localhost", 80)
2 changes: 1 addition & 1 deletion web-security/xss-stored-html/victim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import psutil
import sys
import re

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
open_ports = {s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == "LISTEN"}
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
Expand Down

0 comments on commit af56848

Please sign in to comment.