Initial commit: obfuscator script with original and obfuscated sample sets

This commit is contained in:
Joren committed 2026-11-10 02:16:11 +01:00
commit ae4729b142
402 files changed
+19099

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
__pycache__/
*.py[cod]
.venv/
venv/
+65
View File
@@ -0,0 +1,65 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00002', methods=['GET'])
def BenchmarkTest00002_get():
response = make_response(render_template('web/pathtraver-00/BenchmarkTest00002.html'))
response.set_cookie('BenchmarkTest00002', 'Filename',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00002_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00002', methods=['POST'])
def BenchmarkTest00002_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00002", "noCookieValueSupplied"))
bar = "This should never happen"
if 'should' in bar:
bar = param
import codecs
import helpers.utils
try:
fileTarget = codecs.open(f'{helpers.utils.TESTFILES_DIR}/{bar}','r','utf-8')
RESPONSE += (
f"Access to file: \'{escape_for_html(fileTarget.name)}\' created."
)
RESPONSE += (
" And file already exists."
)
except FileNotFoundError:
RESPONSE += (
" But file doesn't exist yet."
)
return RESPONSE
+73
View File
@@ -0,0 +1,73 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00007', methods=['GET'])
def BenchmarkTest00007_get():
response = make_response(render_template('web/pathtraver-00/BenchmarkTest00007.html'))
response.set_cookie('BenchmarkTest00007', 'FileName',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00007_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00007', methods=['POST'])
def BenchmarkTest00007_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00007", "noCookieValueSupplied"))
string22532 = 'help'
string22532 += param
string22532 += 'snapes on a plane'
bar = string22532[4:-17]
import helpers.utils
if '../' in bar:
RESPONSE += (
'File name must not contain \'../\''
)
return RESPONSE
try:
fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}'
fd = open(fileName, 'wb')
RESPONSE += (
f'Now ready to write to file: {escape_for_html(fileName)}'
)
except IOError as e:
RESPONSE += (
f'Problem reading from file \'{escape_for_html(fileName)}\': '
f'{escape_for_html(e.strerror)}'
)
finally:
try:
if fd is not None:
fd.close()
except IOError:
pass # "// we tried..."
return RESPONSE
+72
View File
@@ -0,0 +1,72 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00014', methods=['GET'])
def BenchmarkTest00014_get():
response = make_response(render_template('web/xpathi-00/BenchmarkTest00014.html'))
response.set_cookie('BenchmarkTest00014', '2222',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00014_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00014', methods=['POST'])
def BenchmarkTest00014_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00014", "noCookieValueSupplied"))
import base64
tmp = base64.b64encode(param.encode('utf-8'))
bar = base64.b64decode(tmp).decode('utf-8')
import elementpath
import xml.etree.ElementTree as ET
import helpers.utils
if '\'' in bar:
RESPONSE += (
"Employee ID must not contain apostrophes"
)
return RESPONSE
try:
root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml')
query = f"/Employees/Employee[@emplid=\'{bar}\']"
nodes = elementpath.select(root, query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+72
View File
@@ -0,0 +1,72 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00015', methods=['GET'])
def BenchmarkTest00015_get():
response = make_response(render_template('web/xpathi-00/BenchmarkTest00015.html'))
response.set_cookie('BenchmarkTest00015', '2222',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00015_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00015', methods=['POST'])
def BenchmarkTest00015_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00015", "noCookieValueSupplied"))
bar = "This should never happen"
if 'should' in bar:
bar = param
import elementpath
import xml.etree.ElementTree as ET
import helpers.utils
if '\'' in bar:
RESPONSE += (
"Employee ID must not contain apostrophes"
)
return RESPONSE
try:
root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml')
query = f"/Employees/Employee[@emplid=\'{bar}\']"
nodes = elementpath.select(root, query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+77
View File
@@ -0,0 +1,77 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00024', methods=['GET'])
def BenchmarkTest00024_get():
response = make_response(render_template('web/xpathi-00/BenchmarkTest00024.html'))
response.set_cookie('BenchmarkTest00024', '2222',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00024_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00024', methods=['POST'])
def BenchmarkTest00024_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00024", "noCookieValueSupplied"))
import configparser
bar = 'safe!'
conf57764 = configparser.ConfigParser()
conf57764.add_section('section57764')
conf57764.set('section57764', 'keyA-57764', 'a_Value')
conf57764.set('section57764', 'keyB-57764', param)
bar = conf57764.get('section57764', 'keyA-57764')
import lxml.etree
import helpers.utils
import io
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
strIO = io.StringIO()
strIO.write('/Employees/Employee[@emplid=\'')
strIO.write(bar)
strIO.write('\']')
query = strIO.getvalue()
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+67
View File
@@ -0,0 +1,67 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00040', methods=['GET'])
def BenchmarkTest00040_get():
response = make_response(render_template('web/weakrand-00/BenchmarkTest00040.html'))
response.set_cookie('BenchmarkTest00040', 'whatever',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00040_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00040', methods=['POST'])
def BenchmarkTest00040_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00040", "noCookieValueSupplied"))
string47148 = 'help'
string47148 += param
string47148 += 'snapes on a plane'
bar = string47148[4:-17]
import base64
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00040'[13:]
user = f'SafeToby{num}'
cookie = f'rememberMe{num}'
value = base64.b64encode(secrets.token_bytes(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+65
View File
@@ -0,0 +1,65 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00044', methods=['GET'])
def BenchmarkTest00044_get():
response = make_response(render_template('web/weakrand-00/BenchmarkTest00044.html'))
response.set_cookie('BenchmarkTest00044', 'whatever',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00044_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00044', methods=['POST'])
def BenchmarkTest00044_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00044", "noCookieValueSupplied"))
import base64
tmp = base64.b64encode(param.encode('utf-8'))
bar = base64.b64decode(tmp).decode('utf-8')
import random
from helpers.utils import mysession
num = 'BenchmarkTest00044'[13:]
user = f'SafeRandy{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().getrandbits(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+70
View File
@@ -0,0 +1,70 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00052', methods=['GET'])
def BenchmarkTest00052_get():
response = make_response(render_template('web/weakrand-00/BenchmarkTest00052.html'))
response.set_cookie('BenchmarkTest00052', 'whatever',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00052_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00052', methods=['POST'])
def BenchmarkTest00052_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00052", "noCookieValueSupplied"))
bar = ""
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[0]
import random
from helpers.utils import mysession
num = 'BenchmarkTest00052'[13:]
user = f'SafeRandall{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().random())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+72
View File
@@ -0,0 +1,72 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00055', methods=['GET'])
def BenchmarkTest00055_get():
response = make_response(render_template('web/hash-00/BenchmarkTest00055.html'))
response.set_cookie('BenchmarkTest00055', 'someSecret',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00055_post()
@app.route('/benchmark/hash-00/BenchmarkTest00055', methods=['POST'])
def BenchmarkTest00055_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00055", "noCookieValueSupplied"))
num = 106
bar = "This should never happen" if (7*42) - num > 200 else param
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.new('sha384')
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+74
View File
@@ -0,0 +1,74 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00062', methods=['GET'])
def BenchmarkTest00062_get():
response = make_response(render_template('web/hash-00/BenchmarkTest00062.html'))
response.set_cookie('BenchmarkTest00062', 'someSecret',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00062_post()
@app.route('/benchmark/hash-00/BenchmarkTest00062', methods=['POST'])
def BenchmarkTest00062_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00062", "noCookieValueSupplied"))
TestParam = "This should never happen"
if 'should' not in TestParam:
bar = "Ifnot case passed"
else:
bar = param
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha512()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+69
View File
@@ -0,0 +1,69 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/securecookie-00/BenchmarkTest00065', methods=['GET'])
def BenchmarkTest00065_get():
response = make_response(render_template('web/securecookie-00/BenchmarkTest00065.html'))
response.set_cookie('BenchmarkTest00065', 'whatever',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00065_post()
@app.route('/benchmark/securecookie-00/BenchmarkTest00065', methods=['POST'])
def BenchmarkTest00065_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00065", "noCookieValueSupplied"))
import html
bar = html.escape(param)
from flask import make_response
import io
import helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
cookie = 'SomeCookie'
value = input.decode('utf-8')
RESPONSE += (
f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.'
)
RESPONSE = make_response(RESPONSE)
RESPONSE.set_cookie(cookie, value,
path=request.path,
secure=False,
httponly=True)
return RESPONSE
+69
View File
@@ -0,0 +1,69 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/securecookie-00/BenchmarkTest00066', methods=['GET'])
def BenchmarkTest00066_get():
response = make_response(render_template('web/securecookie-00/BenchmarkTest00066.html'))
response.set_cookie('BenchmarkTest00066', 'whatever',
max_age=60*3,
secure=True,
path=request.path,
domain='localhost')
return response
return BenchmarkTest00066_post()
@app.route('/benchmark/securecookie-00/BenchmarkTest00066', methods=['POST'])
def BenchmarkTest00066_post():
RESPONSE = ""
import urllib.parse
param = urllib.parse.unquote_plus(request.cookies.get("BenchmarkTest00066", "noCookieValueSupplied"))
bar = "This should never happen"
if 'should' in bar:
bar = param
from flask import make_response
import io
import helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
cookie = 'SomeCookie'
value = input.decode('utf-8')
RESPONSE += (
f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.'
)
RESPONSE = make_response(RESPONSE)
RESPONSE.set_cookie(cookie, value,
path=request.path,
secure=False,
httponly=True)
return RESPONSE
+52
View File
@@ -0,0 +1,52 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00089', methods=['GET'])
def BenchmarkTest00089_get():
return BenchmarkTest00089_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00089', methods=['POST'])
def BenchmarkTest00089_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00089")
if not param:
param = ""
map83150 = {}
map83150['keyA-83150'] = 'a-Value'
map83150['keyB-83150'] = param
map83150['keyC'] = 'another-Value'
bar = map83150['keyB-83150']
import pathlib
import helpers.utils
testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR)
p = testfiles / bar
if p.exists():
RESPONSE += ( f"File \'{escape_for_html(str(p))}\' exists." )
else:
RESPONSE += ( f"File \'{escape_for_html(str(p))}\' does not exist." )
return RESPONSE
+63
View File
@@ -0,0 +1,63 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00094', methods=['GET'])
def BenchmarkTest00094_get():
return BenchmarkTest00094_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00094', methods=['POST'])
def BenchmarkTest00094_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00094")
if not param:
param = ""
num = 106
bar = "This_should_always_happen" if 7 * 18 + num > 200 else param
import pathlib
import helpers.utils
try:
testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR)
p = (testfiles / bar).resolve()
if not str(p).startswith(str(testfiles)):
RESPONSE += (
"Invalid Path."
)
return RESPONSE
RESPONSE += (
f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n'
f'{escape_for_html(p.read_text()[:1000])}'
)
except OSError:
RESPONSE += (
f'Problem reading from file \'{{escape_for_html(fileName)}}\': '
f'{escape_for_html(e.strerror)}'
)
return RESPONSE
+46
View File
@@ -0,0 +1,46 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00097', methods=['GET'])
def BenchmarkTest00097_get():
return BenchmarkTest00097_post()
@app.route('/benchmark/xss-00/BenchmarkTest00097', methods=['POST'])
def BenchmarkTest00097_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00097")
if not param:
param = ""
bar = ''
if param:
bar = param.split(' ')[0]
otherarg = "static text"
RESPONSE += (
f'bar is \'{bar}\' and otherarg is \'{otherarg}\''
)
return RESPONSE
+60
View File
@@ -0,0 +1,60 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00111', methods=['GET'])
def BenchmarkTest00111_get():
return BenchmarkTest00111_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00111', methods=['POST'])
def BenchmarkTest00111_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00111")
if not param:
param = ""
bar = "This should never happen"
if 'should' in bar:
bar = param
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=$name]'
nodes = root.xpath(query, name=bar)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00115', methods=['GET'])
def BenchmarkTest00115_get():
return BenchmarkTest00115_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00115', methods=['POST'])
def BenchmarkTest00115_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00115")
if not param:
param = ""
bar = ''
if param:
bar = param.split(' ')[0]
import random
from helpers.utils import mysession
num = 'BenchmarkTest00115'[13:]
user = f'Randy{num}'
cookie = f'rememberMe{num}'
value = str(random.getrandbits(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+68
View File
@@ -0,0 +1,68 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00119', methods=['GET'])
def BenchmarkTest00119_get():
return BenchmarkTest00119_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00119', methods=['POST'])
def BenchmarkTest00119_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00119")
if not param:
param = ""
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00119'[13:]
user = f'SafeRobbie{num}'
cookie = f'rememberMe{num}'
value = str(secrets.randbelow(2**32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+65
View File
@@ -0,0 +1,65 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00121', methods=['GET'])
def BenchmarkTest00121_get():
return BenchmarkTest00121_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00121', methods=['POST'])
def BenchmarkTest00121_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00121")
if not param:
param = ""
import configparser
bar = 'safe!'
conf68097 = configparser.ConfigParser()
conf68097.add_section('section68097')
conf68097.set('section68097', 'keyA-68097', 'a-Value')
conf68097.set('section68097', 'keyB-68097', param)
bar = conf68097.get('section68097', 'keyB-68097')
import base64
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00121'[13:]
user = f'SafeToby{num}'
cookie = f'rememberMe{num}'
value = base64.b64encode(secrets.token_bytes(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00125', methods=['GET'])
def BenchmarkTest00125_get():
return BenchmarkTest00125_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00125', methods=['POST'])
def BenchmarkTest00125_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00125")
if not param:
param = ""
superstring = f'94919{param}abcd'
bar = superstring[len('94919'):len(superstring)-5]
import base64
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00125'[13:]
user = f'SafeToby{num}'
cookie = f'rememberMe{num}'
value = base64.b64encode(secrets.token_bytes(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+57
View File
@@ -0,0 +1,57 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00131', methods=['GET'])
def BenchmarkTest00131_get():
return BenchmarkTest00131_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00131', methods=['POST'])
def BenchmarkTest00131_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00131")
if not param:
param = ""
bar = param + '_SafeStuff'
import random
from helpers.utils import mysession
num = 'BenchmarkTest00131'[13:]
user = f'SafeRandy{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().getrandbits(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+58
View File
@@ -0,0 +1,58 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00132', methods=['GET'])
def BenchmarkTest00132_get():
return BenchmarkTest00132_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00132', methods=['POST'])
def BenchmarkTest00132_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00132")
if not param:
param = ""
import helpers.utils
bar = helpers.utils.escape_for_html(param)
import random
from helpers.utils import mysession
num = 'BenchmarkTest00132'[13:]
user = f'SafeNancy{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().normalvariate())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+64
View File
@@ -0,0 +1,64 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00136', methods=['GET'])
def BenchmarkTest00136_get():
return BenchmarkTest00136_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00136', methods=['POST'])
def BenchmarkTest00136_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00136")
if not param:
param = ""
string14469 = ''
data12 = ''
copy = string14469
string14469 = ''
string14469 += param
copy += 'SomeOKString'
bar = copy
import random
import base64
from helpers.utils import mysession
num = 'BenchmarkTest00136'[13:]
user = f'SafeBarbara{num}'
cookie = f'rememberMe{num}'
value = str(base64.b64encode(random.SystemRandom().randbytes(32)))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+64
View File
@@ -0,0 +1,64 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00139', methods=['GET'])
def BenchmarkTest00139_get():
return BenchmarkTest00139_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00139', methods=['POST'])
def BenchmarkTest00139_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00139")
if not param:
param = ""
bar = ""
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[0]
import random
from helpers.utils import mysession
num = 'BenchmarkTest00139'[13:]
user = f'SafeRandall{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().random())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+70
View File
@@ -0,0 +1,70 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00142', methods=['GET'])
def BenchmarkTest00142_get():
return BenchmarkTest00142_post()
@app.route('/benchmark/hash-00/BenchmarkTest00142', methods=['POST'])
def BenchmarkTest00142_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00142")
if not param:
param = ""
map71621 = {}
map71621['keyA-71621'] = 'a-Value'
map71621['keyB-71621'] = param
map71621['keyC'] = 'another-Value'
bar = "safe!"
bar = map71621['keyB-71621']
bar = map71621['keyA-71621']
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha1()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+66
View File
@@ -0,0 +1,66 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00143', methods=['GET'])
def BenchmarkTest00143_get():
return BenchmarkTest00143_post()
@app.route('/benchmark/hash-00/BenchmarkTest00143', methods=['POST'])
def BenchmarkTest00143_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00143")
if not param:
param = ""
import html
bar = html.escape(param)
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha1()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+64
View File
@@ -0,0 +1,64 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00146', methods=['GET'])
def BenchmarkTest00146_get():
return BenchmarkTest00146_post()
@app.route('/benchmark/hash-00/BenchmarkTest00146', methods=['POST'])
def BenchmarkTest00146_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00146")
if not param:
param = ""
bar = param + '_SafeStuff'
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha384()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+64
View File
@@ -0,0 +1,64 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00147', methods=['GET'])
def BenchmarkTest00147_get():
return BenchmarkTest00147_post()
@app.route('/benchmark/hash-00/BenchmarkTest00147', methods=['POST'])
def BenchmarkTest00147_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00147")
if not param:
param = ""
bar = param
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha512()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+62
View File
@@ -0,0 +1,62 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/codeinj-00/BenchmarkTest00162', methods=['GET'])
def BenchmarkTest00162_get():
return BenchmarkTest00162_post()
@app.route('/benchmark/codeinj-00/BenchmarkTest00162', methods=['POST'])
def BenchmarkTest00162_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00162")
if not param:
param = ""
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
if not bar.startswith('\'') or not bar.endswith('\'') or '\'' in bar[1:-1]:
RESPONSE += (
"Exec argument must be a plain string literal."
)
return RESPONSE
try:
exec(bar)
except:
RESPONSE += (
f'Error executing statement \'{escape_for_html(bar)}\''
)
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/deserialization-00/BenchmarkTest00164', methods=['GET'])
def BenchmarkTest00164_get():
return BenchmarkTest00164_post()
@app.route('/benchmark/deserialization-00/BenchmarkTest00164', methods=['POST'])
def BenchmarkTest00164_post():
RESPONSE = ""
param = request.form.get("BenchmarkTest00164")
if not param:
param = ""
string6880 = 'help'
string6880 += param
string6880 += 'snapes on a plane'
bar = string6880[4:-17]
import pickle
import base64
import helpers.utils
helpers.utils.sharedstr = "no pickles to be seen here"
try:
unpickled = pickle.loads(base64.urlsafe_b64decode(bar))
except:
RESPONSE += (
'Unpickling failed!'
)
return RESPONSE
RESPONSE += (
f'shared string is {helpers.utils.sharedstr}'
)
return RESPONSE
+70
View File
@@ -0,0 +1,70 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00176', methods=['GET'])
def BenchmarkTest00176_get():
return BenchmarkTest00176_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00176', methods=['POST'])
def BenchmarkTest00176_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00176")
param = ""
if values:
param = values[0]
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import helpers.utils
try:
fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}'
fd = open(fileName, 'wb')
RESPONSE += (
f'Now ready to write to file: {escape_for_html(fileName)}'
)
except IOError as e:
RESPONSE += (
f'Problem reading from file \'{escape_for_html(fileName)}\': '
f'{escape_for_html(e.strerror)}'
)
finally:
try:
if fd is not None:
fd.close()
except IOError:
pass # "// we tried..."
return RESPONSE
+55
View File
@@ -0,0 +1,55 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00179', methods=['GET'])
def BenchmarkTest00179_get():
return BenchmarkTest00179_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00179', methods=['POST'])
def BenchmarkTest00179_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00179")
param = ""
if values:
param = values[0]
bar = "alsosafe"
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[1]
import os
import helpers.utils
fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}'
if os.path.exists(fileName):
RESPONSE += ( f"File \'{escape_for_html(fileName)}\' exists." )
else:
RESPONSE += ( f"File \'{escape_for_html(fileName)}\' does not exist." )
return RESPONSE
+47
View File
@@ -0,0 +1,47 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00187', methods=['GET'])
def BenchmarkTest00187_get():
return BenchmarkTest00187_post()
@app.route('/benchmark/xss-00/BenchmarkTest00187', methods=['POST'])
def BenchmarkTest00187_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00187")
param = ""
if values:
param = values[0]
import base64
tmp = base64.b64encode(param.encode('utf-8'))
bar = base64.b64decode(tmp).decode('utf-8')
otherarg = "static text"
RESPONSE += (
'bar is \'{0}\' and otherarg is \'{1}\''.format(bar, otherarg)
)
return RESPONSE
+47
View File
@@ -0,0 +1,47 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00190', methods=['GET'])
def BenchmarkTest00190_get():
return BenchmarkTest00190_post()
@app.route('/benchmark/xss-00/BenchmarkTest00190', methods=['POST'])
def BenchmarkTest00190_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00190")
param = ""
if values:
param = values[0]
import html
bar = html.escape(param)
otherarg = "static text"
RESPONSE += (
'bar is \'%s\' and otherarg is \'%s\'' % (bar, otherarg)
)
return RESPONSE
+61
View File
@@ -0,0 +1,61 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/sqli-00/BenchmarkTest00192', methods=['GET'])
def BenchmarkTest00192_get():
return BenchmarkTest00192_post()
@app.route('/benchmark/sqli-00/BenchmarkTest00192', methods=['POST'])
def BenchmarkTest00192_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00192")
param = ""
if values:
param = values[0]
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import helpers.db_sqlite
sql = f'SELECT username from USERS where password = ?'
con = helpers.db_sqlite.get_connection()
cur = con.cursor()
cur.execute(sql, (bar,))
RESPONSE += (
helpers.db_sqlite.results(cur, sql)
)
con.close()
return RESPONSE
+64
View File
@@ -0,0 +1,64 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00194', methods=['GET'])
def BenchmarkTest00194_get():
return BenchmarkTest00194_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00194', methods=['POST'])
def BenchmarkTest00194_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00194")
param = ""
if values:
param = values[0]
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
import elementpath
import xml.etree.ElementTree as ET
import helpers.utils
try:
root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml')
query = f"/Employees/Employee[@emplid=\'{bar}\']"
nodes = elementpath.select(root, query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00199', methods=['GET'])
def BenchmarkTest00199_get():
return BenchmarkTest00199_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00199', methods=['POST'])
def BenchmarkTest00199_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00199")
param = ""
if values:
param = values[0]
bar = param
import elementpath
import xml.etree.ElementTree as ET
import helpers.utils
try:
root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml')
nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', '&apos;')}\']")
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+61
View File
@@ -0,0 +1,61 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00202', methods=['GET'])
def BenchmarkTest00202_get():
return BenchmarkTest00202_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00202', methods=['POST'])
def BenchmarkTest00202_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00202")
param = ""
if values:
param = values[0]
num = 106
bar = "This should never happen" if (7*42) - num > 200 else param
import elementpath
import xml.etree.ElementTree as ET
import helpers.utils
try:
root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml')
nodes = elementpath.select(root, f"/Employees/Employee[@emplid=\'{bar.replace('\'', '&apos;')}\']")
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+70
View File
@@ -0,0 +1,70 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00207', methods=['GET'])
def BenchmarkTest00207_get():
return BenchmarkTest00207_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00207', methods=['POST'])
def BenchmarkTest00207_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00207")
param = ""
if values:
param = values[0]
possible = "ABC"
guess = possible[0]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=\'{bar}\']'
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+64
View File
@@ -0,0 +1,64 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00210', methods=['GET'])
def BenchmarkTest00210_get():
return BenchmarkTest00210_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00210', methods=['POST'])
def BenchmarkTest00210_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00210")
param = ""
if values:
param = values[0]
TestParam = "This should never happen"
if 'should' not in TestParam:
bar = "Ifnot case passed"
else:
bar = param
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = '/Employees/Employee[@emplid=\'' + bar + '\']'
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+69
View File
@@ -0,0 +1,69 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00218', methods=['GET'])
def BenchmarkTest00218_get():
return BenchmarkTest00218_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00218', methods=['POST'])
def BenchmarkTest00218_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00218")
param = ""
if values:
param = values[0]
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import random
from helpers.utils import mysession
num = 'BenchmarkTest00218'[13:]
user = f'Nancy{num}'
cookie = f'rememberMe{num}'
value = str(random.normalvariate())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+58
View File
@@ -0,0 +1,58 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00224', methods=['GET'])
def BenchmarkTest00224_get():
return BenchmarkTest00224_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00224', methods=['POST'])
def BenchmarkTest00224_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00224")
param = ""
if values:
param = values[0]
bar = param
import random
from helpers.utils import mysession
num = 'BenchmarkTest00224'[13:]
user = f'Randall{num}'
cookie = f'rememberMe{num}'
value = str(random.random())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+65
View File
@@ -0,0 +1,65 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00225', methods=['GET'])
def BenchmarkTest00225_get():
return BenchmarkTest00225_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00225', methods=['POST'])
def BenchmarkTest00225_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00225")
param = ""
if values:
param = values[0]
import configparser
bar = 'safe!'
conf54571 = configparser.ConfigParser()
conf54571.add_section('section54571')
conf54571.set('section54571', 'keyA-54571', 'a_Value')
conf54571.set('section54571', 'keyB-54571', param)
bar = conf54571.get('section54571', 'keyA-54571')
import random
from helpers.utils import mysession
num = 'BenchmarkTest00225'[13:]
user = f'Randall{num}'
cookie = f'rememberMe{num}'
value = str(random.random())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+60
View File
@@ -0,0 +1,60 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00229', methods=['GET'])
def BenchmarkTest00229_get():
return BenchmarkTest00229_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00229', methods=['POST'])
def BenchmarkTest00229_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00229")
param = ""
if values:
param = values[0]
bar = "This should never happen"
if 'should' in bar:
bar = param
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00229'[13:]
user = f'SafeRobbie{num}'
cookie = f'rememberMe{num}'
value = str(secrets.randbelow(2**32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+58
View File
@@ -0,0 +1,58 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00230', methods=['GET'])
def BenchmarkTest00230_get():
return BenchmarkTest00230_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00230', methods=['POST'])
def BenchmarkTest00230_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00230")
param = ""
if values:
param = values[0]
bar = param + '_SafeStuff'
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00230'[13:]
user = f'SafeRobbie{num}'
cookie = f'rememberMe{num}'
value = str(secrets.randbelow(2**32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+61
View File
@@ -0,0 +1,61 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-00/BenchmarkTest00235', methods=['GET'])
def BenchmarkTest00235_get():
return BenchmarkTest00235_post()
@app.route('/benchmark/weakrand-00/BenchmarkTest00235', methods=['POST'])
def BenchmarkTest00235_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00235")
param = ""
if values:
param = values[0]
bar = ''
if param:
bar = param.split(' ')[0]
import base64
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00235'[13:]
user = f'SafeTruman{num}'
cookie = f'rememberMe{num}'
value = secrets.token_urlsafe(32)
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+72
View File
@@ -0,0 +1,72 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00248', methods=['GET'])
def BenchmarkTest00248_get():
return BenchmarkTest00248_post()
@app.route('/benchmark/hash-00/BenchmarkTest00248', methods=['POST'])
def BenchmarkTest00248_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00248")
param = ""
if values:
param = values[0]
import configparser
bar = 'safe!'
conf78480 = configparser.ConfigParser()
conf78480.add_section('section78480')
conf78480.set('section78480', 'keyA-78480', 'a_Value')
conf78480.set('section78480', 'keyB-78480', param)
bar = conf78480.get('section78480', 'keyA-78480')
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.md5()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+52
View File
@@ -0,0 +1,52 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00256', methods=['GET'])
def BenchmarkTest00256_get():
return BenchmarkTest00256_post()
@app.route('/benchmark/xss-00/BenchmarkTest00256', methods=['POST'])
def BenchmarkTest00256_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00256")
param = ""
if values:
param = values[0]
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
RESPONSE += (
'The value of the bar parameter is now in a custom header.'
)
RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00256': bar}))
return RESPONSE
+43
View File
@@ -0,0 +1,43 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/redirect-00/BenchmarkTest00258', methods=['GET'])
def BenchmarkTest00258_get():
return BenchmarkTest00258_post()
@app.route('/benchmark/redirect-00/BenchmarkTest00258', methods=['POST'])
def BenchmarkTest00258_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00258")
param = ""
if values:
param = values[0]
bar = param
import flask
return flask.redirect(bar)
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/codeinj-00/BenchmarkTest00263', methods=['GET'])
def BenchmarkTest00263_get():
return BenchmarkTest00263_post()
@app.route('/benchmark/codeinj-00/BenchmarkTest00263', methods=['POST'])
def BenchmarkTest00263_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00263")
param = ""
if values:
param = values[0]
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
try:
RESPONSE += (
eval(bar)
)
except:
RESPONSE += (
f'Error evaluating expression \'{escape_for_html(bar)}\''
)
return RESPONSE
+63
View File
@@ -0,0 +1,63 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/deserialization-00/BenchmarkTest00271', methods=['GET'])
def BenchmarkTest00271_get():
return BenchmarkTest00271_post()
@app.route('/benchmark/deserialization-00/BenchmarkTest00271', methods=['POST'])
def BenchmarkTest00271_post():
RESPONSE = ""
values = request.form.getlist("BenchmarkTest00271")
param = ""
if values:
param = values[0]
possible = "ABC"
guess = possible[0]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import yaml
try:
yobj = yaml.safe_load(bar)
RESPONSE += (
yobj['text']
)
except:
RESPONSE += (
"There was an error loading the configuration"
)
return RESPONSE
+54
View File
@@ -0,0 +1,54 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/sqli-00/BenchmarkTest00284', methods=['GET'])
def BenchmarkTest00284_get():
return BenchmarkTest00284_post()
@app.route('/benchmark/sqli-00/BenchmarkTest00284', methods=['POST'])
def BenchmarkTest00284_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00284")
if not param:
param = ""
bar = "This should never happen"
if 'should' in bar:
bar = param
import helpers.db_sqlite
sql = f'SELECT username from USERS where password = \'{bar}\''
con = helpers.db_sqlite.get_connection()
cur = con.cursor()
cur.execute(sql)
RESPONSE += (
helpers.db_sqlite.results(cur, sql)
)
con.close()
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/sqli-00/BenchmarkTest00286', methods=['GET'])
def BenchmarkTest00286_get():
return BenchmarkTest00286_post()
@app.route('/benchmark/sqli-00/BenchmarkTest00286', methods=['POST'])
def BenchmarkTest00286_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00286")
if not param:
param = ""
import configparser
bar = 'safe!'
conf59255 = configparser.ConfigParser()
conf59255.add_section('section59255')
conf59255.set('section59255', 'keyA-59255', 'a_Value')
conf59255.set('section59255', 'keyB-59255', param)
bar = conf59255.get('section59255', 'keyA-59255')
import helpers.db_sqlite
sql = f'SELECT username from USERS where password = ?'
con = helpers.db_sqlite.get_connection()
cur = con.cursor()
cur.execute(sql, (bar,))
RESPONSE += (
helpers.db_sqlite.results(cur, sql)
)
con.close()
return RESPONSE
+69
View File
@@ -0,0 +1,69 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xxe-00/BenchmarkTest00293', methods=['GET'])
def BenchmarkTest00293_get():
return BenchmarkTest00293_post()
@app.route('/benchmark/xxe-00/BenchmarkTest00293', methods=['POST'])
def BenchmarkTest00293_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00293")
if not param:
param = ""
num = 106
bar = "This should never happen" if (7*42) - num > 200 else param
import xml.dom.minidom
import xml.sax.handler
try:
parser = xml.sax.make_parser()
# all features are disabled by default
doc = xml.dom.minidom.parseString(bar, parser)
out = ''
processing = [doc.documentElement]
while processing:
e = processing.pop(0)
if e.nodeType == xml.dom.Node.TEXT_NODE:
out += e.data
else:
processing[:0] = e.childNodes
RESPONSE += (
f'Your XML doc results are: <br>{escape_for_html(out)}'
)
except:
RESPONSE += (
f'There was an error reading your XML doc:<br>{escape_for_html(bar)}'
)
return RESPONSE
+65
View File
@@ -0,0 +1,65 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-01/BenchmarkTest00314', methods=['GET'])
def BenchmarkTest00314_get():
return BenchmarkTest00314_post()
@app.route('/benchmark/weakrand-01/BenchmarkTest00314', methods=['POST'])
def BenchmarkTest00314_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00314")
if not param:
param = ""
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
import random
from helpers.utils import mysession
num = 'BenchmarkTest00314'[13:]
user = f'SafeRandy{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().getrandbits(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+68
View File
@@ -0,0 +1,68 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00319', methods=['GET'])
def BenchmarkTest00319_get():
return BenchmarkTest00319_post()
@app.route('/benchmark/hash-00/BenchmarkTest00319', methods=['POST'])
def BenchmarkTest00319_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00319")
if not param:
param = ""
import helpers.utils
bar = helpers.utils.escape_for_html(param)
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.new('md5')
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+67
View File
@@ -0,0 +1,67 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00324', methods=['GET'])
def BenchmarkTest00324_get():
return BenchmarkTest00324_post()
@app.route('/benchmark/hash-00/BenchmarkTest00324', methods=['POST'])
def BenchmarkTest00324_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00324")
if not param:
param = ""
bar = param
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.new('sha512')
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+74
View File
@@ -0,0 +1,74 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00327', methods=['GET'])
def BenchmarkTest00327_get():
return BenchmarkTest00327_post()
@app.route('/benchmark/hash-00/BenchmarkTest00327', methods=['POST'])
def BenchmarkTest00327_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00327")
if not param:
param = ""
import configparser
bar = 'safe!'
conf75704 = configparser.ConfigParser()
conf75704.add_section('section75704')
conf75704.set('section75704', 'keyA-75704', 'a_Value')
conf75704.set('section75704', 'keyB-75704', param)
bar = conf75704.get('section75704', 'keyA-75704')
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.md5()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+67
View File
@@ -0,0 +1,67 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00328', methods=['GET'])
def BenchmarkTest00328_get():
return BenchmarkTest00328_post()
@app.route('/benchmark/hash-00/BenchmarkTest00328', methods=['POST'])
def BenchmarkTest00328_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00328")
if not param:
param = ""
bar = param
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha1()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+68
View File
@@ -0,0 +1,68 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00331', methods=['GET'])
def BenchmarkTest00331_get():
return BenchmarkTest00331_post()
@app.route('/benchmark/hash-00/BenchmarkTest00331', methods=['POST'])
def BenchmarkTest00331_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00331")
if not param:
param = ""
import helpers.utils
bar = helpers.utils.escape_for_html(param)
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha512()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+53
View File
@@ -0,0 +1,53 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00334', methods=['GET'])
def BenchmarkTest00334_get():
return BenchmarkTest00334_post()
@app.route('/benchmark/xss-00/BenchmarkTest00334', methods=['POST'])
def BenchmarkTest00334_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00334")
if not param:
param = ""
TestParam = "This should never happen"
if 'should' not in TestParam:
bar = "Ifnot case passed"
else:
bar = param
RESPONSE += (
'The value of the bar parameter is now in a custom header.'
)
RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00334': bar}))
return RESPONSE
+54
View File
@@ -0,0 +1,54 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00335', methods=['GET'])
def BenchmarkTest00335_get():
return BenchmarkTest00335_post()
@app.route('/benchmark/xss-00/BenchmarkTest00335', methods=['POST'])
def BenchmarkTest00335_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00335")
if not param:
param = ""
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
RESPONSE += (
'The value of the bar parameter is now in a custom header.'
)
RESPONSE = make_response((RESPONSE, {'yourBenchmarkTest00335': bar}))
return RESPONSE
+55
View File
@@ -0,0 +1,55 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/trustbound-00/BenchmarkTest00339', methods=['GET'])
def BenchmarkTest00339_get():
return BenchmarkTest00339_post()
@app.route('/benchmark/trustbound-00/BenchmarkTest00339', methods=['POST'])
def BenchmarkTest00339_post():
RESPONSE = ""
import helpers.separate_request
wrapped = helpers.separate_request.request_wrapper(request)
param = wrapped.get_form_parameter("BenchmarkTest00339")
if not param:
param = ""
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
import flask
flask.session['userid'] = bar
RESPONSE += (
f'Item: \'userid\' with value \'{escape_for_html(bar)}'
'\'saved in session.'
)
return RESPONSE
+59
View File
@@ -0,0 +1,59 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00351', methods=['GET'])
def BenchmarkTest00351_get():
return BenchmarkTest00351_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00351', methods=['POST'])
def BenchmarkTest00351_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00351" in request.form.getlist(name):
param = name
break
bar = param
import codecs
import helpers.utils
try:
fileTarget = codecs.open(f'{helpers.utils.TESTFILES_DIR}/{bar}','r','utf-8')
RESPONSE += (
f"Access to file: \'{escape_for_html(fileTarget.name)}\' created."
)
RESPONSE += (
" And file already exists."
)
except FileNotFoundError:
RESPONSE += (
" But file doesn't exist yet."
)
return RESPONSE
+50
View File
@@ -0,0 +1,50 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00366', methods=['GET'])
def BenchmarkTest00366_get():
return BenchmarkTest00366_post()
@app.route('/benchmark/xss-00/BenchmarkTest00366', methods=['POST'])
def BenchmarkTest00366_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00366" in request.form.getlist(name):
param = name
break
map99262 = {}
map99262['keyA-99262'] = 'a-Value'
map99262['keyB-99262'] = param
map99262['keyC'] = 'another-Value'
bar = map99262['keyB-99262']
otherarg = "static text"
RESPONSE += (
'bar is \'%s\' and otherarg is \'%s\'' % (bar, otherarg)
)
return RESPONSE
+62
View File
@@ -0,0 +1,62 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-01/BenchmarkTest00390', methods=['GET'])
def BenchmarkTest00390_get():
return BenchmarkTest00390_post()
@app.route('/benchmark/weakrand-01/BenchmarkTest00390', methods=['POST'])
def BenchmarkTest00390_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00390" in request.form.getlist(name):
param = name
break
num = 106
bar = "This_should_always_happen" if 7 * 18 + num > 200 else param
import base64
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00390'[13:]
user = f'SafeToby{num}'
cookie = f'rememberMe{num}'
value = base64.b64encode(secrets.token_bytes(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+71
View File
@@ -0,0 +1,71 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-01/BenchmarkTest00394', methods=['GET'])
def BenchmarkTest00394_get():
return BenchmarkTest00394_post()
@app.route('/benchmark/weakrand-01/BenchmarkTest00394', methods=['POST'])
def BenchmarkTest00394_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00394" in request.form.getlist(name):
param = name
break
possible = "ABC"
guess = possible[0]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import base64
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00394'[13:]
user = f'SafeTruman{num}'
cookie = f'rememberMe{num}'
value = secrets.token_urlsafe(32)
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+61
View File
@@ -0,0 +1,61 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-01/BenchmarkTest00408', methods=['GET'])
def BenchmarkTest00408_get():
return BenchmarkTest00408_post()
@app.route('/benchmark/weakrand-01/BenchmarkTest00408', methods=['POST'])
def BenchmarkTest00408_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00408" in request.form.getlist(name):
param = name
break
num = 106
bar = "This_should_always_happen" if 7 * 18 + num > 200 else param
import random
from helpers.utils import mysession
num = 'BenchmarkTest00408'[13:]
user = f'SafeRandall{num}'
cookie = f'rememberMe{num}'
value = str(random.SystemRandom().random())[2:]
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie: '
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+73
View File
@@ -0,0 +1,73 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00412', methods=['GET'])
def BenchmarkTest00412_get():
return BenchmarkTest00412_post()
@app.route('/benchmark/hash-00/BenchmarkTest00412', methods=['POST'])
def BenchmarkTest00412_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00412" in request.form.getlist(name):
param = name
break
bar = ""
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[0]
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.md5()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+70
View File
@@ -0,0 +1,70 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/ldapi-00/BenchmarkTest00430', methods=['GET'])
def BenchmarkTest00430_get():
return BenchmarkTest00430_post()
@app.route('/benchmark/ldapi-00/BenchmarkTest00430', methods=['POST'])
def BenchmarkTest00430_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00430" in request.form.getlist(name):
param = name
break
string56477 = 'help'
string56477 += param
string56477 += 'snapes on a plane'
bar = string56477[4:-17]
import helpers.ldap
import ldap3
base = 'ou=users,ou=system'
filter = f'(&(objectclass=person)(uid={bar}))'
try:
conn = helpers.ldap.get_connection()
conn.search(base, filter, attributes=ldap3.ALL_ATTRIBUTES)
found = False
for e in conn.entries:
RESPONSE += (
f'LDAP query results:<br>'
f'Record found with name {e['uid']}<br>'
f'Address: {e['street']}<br>'
)
found = True
conn.unbind()
if not found:
RESPONSE += (
f'LDAP query results: nothing found for query: {helpers.utils.escape_for_html(filter)}'
)
except IOError:
RESPONSE += (
"Error processing LDAP query."
)
return RESPONSE
+57
View File
@@ -0,0 +1,57 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/deserialization-00/BenchmarkTest00433', methods=['GET'])
def BenchmarkTest00433_get():
return BenchmarkTest00433_post()
@app.route('/benchmark/deserialization-00/BenchmarkTest00433', methods=['POST'])
def BenchmarkTest00433_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00433" in request.form.getlist(name):
param = name
break
map74329 = {}
map74329['keyA-74329'] = 'a-Value'
map74329['keyB-74329'] = param
map74329['keyC'] = 'another-Value'
bar = map74329['keyB-74329']
import yaml
try:
yobj = yaml.load(bar, Loader=yaml.Loader)
RESPONSE += (
yobj['text']
)
except:
RESPONSE += (
"There was an error loading the configuration"
)
return RESPONSE
+56
View File
@@ -0,0 +1,56 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/deserialization-00/BenchmarkTest00434', methods=['GET'])
def BenchmarkTest00434_get():
return BenchmarkTest00434_post()
@app.route('/benchmark/deserialization-00/BenchmarkTest00434', methods=['POST'])
def BenchmarkTest00434_post():
RESPONSE = ""
param = ""
for name in request.form.keys():
if "BenchmarkTest00434" in request.form.getlist(name):
param = name
break
import helpers.ThingFactory
thing = helpers.ThingFactory.createThing()
bar = thing.doSomething(param)
import yaml
try:
yobj = yaml.safe_load(bar)
RESPONSE += (
yobj['text']
)
except:
RESPONSE += (
"There was an error loading the configuration"
)
return RESPONSE
+50
View File
@@ -0,0 +1,50 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00436', methods=['GET'])
def BenchmarkTest00436_get():
return BenchmarkTest00436_post()
@app.route('/benchmark/xss-00/BenchmarkTest00436', methods=['POST'])
def BenchmarkTest00436_post():
RESPONSE = ""
param = request.headers.get("Referer")
if not param:
param = ""
bar = "alsosafe"
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[1]
RESPONSE += (
f'Parameter value: {bar}'
)
return RESPONSE
+65
View File
@@ -0,0 +1,65 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00439', methods=['GET'])
def BenchmarkTest00439_get():
return BenchmarkTest00439_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00439', methods=['POST'])
def BenchmarkTest00439_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00439")
if not param:
param = ""
string92030 = 'help'
string92030 += param
string92030 += 'snapes on a plane'
bar = string92030[4:-17]
import helpers.utils
fileName = None
fd = None
try:
fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}'
fd = open(fileName, 'rb')
RESPONSE += (
f'The beginning of file: \'{escape_for_html(fileName)}\' is:\n\n'
f'{escape_for_html(fd.read(1000).decode('utf-8'))}'
)
except IOError as e:
RESPONSE += (
f'Problem reading from file \'{{escape_for_html(fileName)}}\': '
f'{escape_for_html(e.strerror)}'
)
finally:
try:
if fd is not None:
fd.close()
except IOError:
pass # "// we tried..."
return RESPONSE
+60
View File
@@ -0,0 +1,60 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00441', methods=['GET'])
def BenchmarkTest00441_get():
return BenchmarkTest00441_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00441', methods=['POST'])
def BenchmarkTest00441_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00441")
if not param:
param = ""
num = 106
bar = "This_should_always_happen" if 7 * 18 + num > 200 else param
import helpers.utils
try:
fileName = f'{helpers.utils.TESTFILES_DIR}/{bar}'
fd = open(fileName, 'wb')
RESPONSE += (
f'Now ready to write to file: {escape_for_html(fileName)}'
)
except IOError as e:
RESPONSE += (
f'Problem reading from file \'{escape_for_html(fileName)}\': '
f'{escape_for_html(e.strerror)}'
)
finally:
try:
if fd is not None:
fd.close()
except IOError:
pass # "// we tried..."
return RESPONSE
+68
View File
@@ -0,0 +1,68 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/pathtraver-00/BenchmarkTest00448', methods=['GET'])
def BenchmarkTest00448_get():
return BenchmarkTest00448_post()
@app.route('/benchmark/pathtraver-00/BenchmarkTest00448', methods=['POST'])
def BenchmarkTest00448_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00448")
if not param:
param = ""
import configparser
bar = 'safe!'
conf57737 = configparser.ConfigParser()
conf57737.add_section('section57737')
conf57737.set('section57737', 'keyA-57737', 'a_Value')
conf57737.set('section57737', 'keyB-57737', param)
bar = conf57737.get('section57737', 'keyA-57737')
import pathlib
import helpers.utils
try:
testfiles = pathlib.Path(helpers.utils.TESTFILES_DIR)
p = (testfiles / bar).resolve()
if not str(p).startswith(str(testfiles)):
RESPONSE += (
"Invalid Path."
)
return RESPONSE
RESPONSE += (
f'The beginning of file: \'{escape_for_html(str(p))}\' is:\n\n'
f'{escape_for_html(p.read_text()[:1000])}'
)
except OSError:
RESPONSE += (
f'Problem reading from file \'{{escape_for_html(fileName)}}\': '
f'{escape_for_html(e.strerror)}'
)
return RESPONSE
+46
View File
@@ -0,0 +1,46 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00450', methods=['GET'])
def BenchmarkTest00450_get():
return BenchmarkTest00450_post()
@app.route('/benchmark/xss-00/BenchmarkTest00450', methods=['POST'])
def BenchmarkTest00450_post():
RESPONSE = ""
param = request.headers.get("Referer")
if not param:
param = ""
bar = "This should never happen"
if 'should' in bar:
bar = param
otherarg = "static text"
RESPONSE += (
'bar is \'{0}\' and otherarg is \'{1}\''.format(bar, otherarg)
)
return RESPONSE
+48
View File
@@ -0,0 +1,48 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00452', methods=['GET'])
def BenchmarkTest00452_get():
return BenchmarkTest00452_post()
@app.route('/benchmark/xss-00/BenchmarkTest00452', methods=['POST'])
def BenchmarkTest00452_post():
RESPONSE = ""
param = request.headers.get("Referer")
if not param:
param = ""
import html
bar = html.escape(param)
dict = {}
dict['bar'] = bar
dict['otherarg'] = 'this is it'
RESPONSE += (
'bar is \'{0[bar]}\' and otherarg is \'{0[otherarg]}\''.format(dict)
)
return RESPONSE
+66
View File
@@ -0,0 +1,66 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00458', methods=['GET'])
def BenchmarkTest00458_get():
return BenchmarkTest00458_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00458', methods=['POST'])
def BenchmarkTest00458_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00458")
if not param:
param = ""
num = 106
bar = "This_should_always_happen" if 7 * 18 + num > 200 else param
import elementpath
import xml.etree.ElementTree as ET
import helpers.utils
if '\'' in bar:
RESPONSE += (
"Employee ID must not contain apostrophes"
)
return RESPONSE
try:
root = ET.parse(f'{helpers.utils.RES_DIR}/employees.xml')
query = f"/Employees/Employee[@emplid=\'{bar}\']"
nodes = elementpath.select(root, query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+71
View File
@@ -0,0 +1,71 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xxe-00/BenchmarkTest00461', methods=['GET'])
def BenchmarkTest00461_get():
return BenchmarkTest00461_post()
@app.route('/benchmark/xxe-00/BenchmarkTest00461', methods=['POST'])
def BenchmarkTest00461_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00461")
if not param:
param = ""
map63945 = {}
map63945['keyA-63945'] = 'a-Value'
map63945['keyB-63945'] = param
map63945['keyC'] = 'another-Value'
bar = "safe!"
bar = map63945['keyB-63945']
bar = map63945['keyA-63945']
import xml.dom.minidom
import xml.sax.handler
try:
parser = xml.sax.make_parser()
# all features are disabled by default
parser.setFeature(xml.sax.handler.feature_external_ges, True)
doc = xml.dom.minidom.parseString(bar, parser)
out = ''
processing = [doc.documentElement]
while processing:
e = processing.pop(0)
if e.nodeType == xml.dom.Node.TEXT_NODE:
out += e.data
else:
processing[:0] = e.childNodes
RESPONSE += (
f'Your XML doc results are: <br>{escape_for_html(out)}'
)
except:
RESPONSE += (
f'There was an error reading your XML doc:<br>{escape_for_html(bar)}'
)
return RESPONSE
+63
View File
@@ -0,0 +1,63 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-00/BenchmarkTest00467', methods=['GET'])
def BenchmarkTest00467_get():
return BenchmarkTest00467_post()
@app.route('/benchmark/xpathi-00/BenchmarkTest00467', methods=['POST'])
def BenchmarkTest00467_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00467")
if not param:
param = ""
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=\'{bar.replace('\'', '&apos;')}\']'
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+60
View File
@@ -0,0 +1,60 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00469', methods=['GET'])
def BenchmarkTest00469_get():
return BenchmarkTest00469_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00469', methods=['POST'])
def BenchmarkTest00469_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00469")
if not param:
param = ""
import base64
tmp = base64.b64encode(param.encode('utf-8'))
bar = base64.b64decode(tmp).decode('utf-8')
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=$name]'
nodes = root.xpath(query, name=bar)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+69
View File
@@ -0,0 +1,69 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00470', methods=['GET'])
def BenchmarkTest00470_get():
return BenchmarkTest00470_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00470', methods=['POST'])
def BenchmarkTest00470_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00470")
if not param:
param = ""
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=$name]'
nodes = root.xpath(query, name=bar)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+67
View File
@@ -0,0 +1,67 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00472', methods=['GET'])
def BenchmarkTest00472_get():
return BenchmarkTest00472_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00472', methods=['POST'])
def BenchmarkTest00472_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00472")
if not param:
param = ""
import helpers.ThingFactory
thing = helpers.ThingFactory.createThing()
bar = thing.doSomething(param)
import lxml.etree
import helpers.utils
import io
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
strIO = io.StringIO()
strIO.write('/Employees/Employee[@emplid=\'')
strIO.write(bar)
strIO.write('\']')
query = strIO.getvalue()
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+62
View File
@@ -0,0 +1,62 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/weakrand-01/BenchmarkTest00477', methods=['GET'])
def BenchmarkTest00477_get():
return BenchmarkTest00477_post()
@app.route('/benchmark/weakrand-01/BenchmarkTest00477', methods=['POST'])
def BenchmarkTest00477_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00477")
if not param:
param = ""
num = 86
if 7 * 42 - num > 200:
bar = 'This_should_always_happen'
else:
bar = param
import secrets
from helpers.utils import mysession
num = 'BenchmarkTest00477'[13:]
user = f'SafeRicky{num}'
cookie = f'rememberMe{num}'
value = str(secrets.randbits(32))
if cookie in mysession and request.cookies.get(cookie) == mysession[cookie]:
RESPONSE += (
f'Welcome back: {user}<br/>'
)
else:
mysession[cookie] = value
RESPONSE += (
f'{user} has been remembered with cookie:'
f'{cookie} whose value is: {mysession[cookie]}<br/>'
)
return RESPONSE
+71
View File
@@ -0,0 +1,71 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00488', methods=['GET'])
def BenchmarkTest00488_get():
return BenchmarkTest00488_post()
@app.route('/benchmark/hash-00/BenchmarkTest00488', methods=['POST'])
def BenchmarkTest00488_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00488")
if not param:
param = ""
bar = "alsosafe"
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[1]
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.new('sha512')
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+70
View File
@@ -0,0 +1,70 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/hash-00/BenchmarkTest00491', methods=['GET'])
def BenchmarkTest00491_get():
return BenchmarkTest00491_post()
@app.route('/benchmark/hash-00/BenchmarkTest00491', methods=['POST'])
def BenchmarkTest00491_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00491")
if not param:
param = ""
map51084 = {}
map51084['keyA-51084'] = 'a-Value'
map51084['keyB-51084'] = param
map51084['keyC'] = 'another-Value'
bar = "safe!"
bar = map51084['keyB-51084']
bar = map51084['keyA-51084']
import hashlib, base64
import io, helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
if len(input) == 0:
RESPONSE += (
'Cannot generate hash: Input was empty.'
)
return RESPONSE
hash = hashlib.sha512()
hash.update(input)
result = hash.digest()
f = open(f'{helpers.utils.TESTFILES_DIR}/passwordFile.txt', 'a')
f.write(f'hash_value={base64.b64encode(result)}\n')
RESPONSE += (
f'Sensitive value \'{helpers.utils.escape_for_html(input.decode('utf-8'))}\' hashed and stored.'
)
f.close()
return RESPONSE
+63
View File
@@ -0,0 +1,63 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/securecookie-00/BenchmarkTest00494', methods=['GET'])
def BenchmarkTest00494_get():
return BenchmarkTest00494_post()
@app.route('/benchmark/securecookie-00/BenchmarkTest00494', methods=['POST'])
def BenchmarkTest00494_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00494")
if not param:
param = ""
bar = ''
if param:
bar = param.split(' ')[0]
from flask import make_response
import io
import helpers.utils
input = ''
if isinstance(bar, str):
input = bar.encode('utf-8')
elif isinstance(bar, io.IOBase):
input = bar.read(1000)
cookie = 'SomeCookie'
value = input.decode('utf-8')
RESPONSE += (
f'Created cookie: \'{cookie}\' with value \'{helpers.utils.escape_for_html(value)}\' and secure flag set to false.'
)
RESPONSE = make_response(RESPONSE)
RESPONSE.set_cookie(cookie, value,
path=request.path,
secure=False,
httponly=True)
return RESPONSE
+54
View File
@@ -0,0 +1,54 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/trustbound-00/BenchmarkTest00498', methods=['GET'])
def BenchmarkTest00498_get():
return BenchmarkTest00498_post()
@app.route('/benchmark/trustbound-00/BenchmarkTest00498', methods=['POST'])
def BenchmarkTest00498_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00498")
if not param:
param = ""
bar = "alsosafe"
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[1]
import flask
flask.session['userid'] = bar
RESPONSE += (
f'Item: \'userid\' with value \'{escape_for_html(bar)}'
'\'saved in session.'
)
return RESPONSE
+47
View File
@@ -0,0 +1,47 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/trustbound-00/BenchmarkTest00502', methods=['GET'])
def BenchmarkTest00502_get():
return BenchmarkTest00502_post()
@app.route('/benchmark/trustbound-00/BenchmarkTest00502', methods=['POST'])
def BenchmarkTest00502_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00502")
if not param:
param = ""
bar = param + '_SafeStuff'
import flask
flask.session[bar] = '12345'
RESPONSE += (
f'Item: \'{escape_for_html(bar)}'
'\' with value: 12345 saved in session.'
)
return RESPONSE
+72
View File
@@ -0,0 +1,72 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/ldapi-00/BenchmarkTest00506', methods=['GET'])
def BenchmarkTest00506_get():
return BenchmarkTest00506_post()
@app.route('/benchmark/ldapi-00/BenchmarkTest00506', methods=['POST'])
def BenchmarkTest00506_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00506")
if not param:
param = ""
import configparser
bar = 'safe!'
conf42361 = configparser.ConfigParser()
conf42361.add_section('section42361')
conf42361.set('section42361', 'keyA-42361', 'a-Value')
conf42361.set('section42361', 'keyB-42361', param)
bar = conf42361.get('section42361', 'keyB-42361')
import helpers.ldap
import ldap3
base = 'ou=users,ou=system'
filter = f'(&(objectclass=person)(uid={bar}))'
try:
conn = helpers.ldap.get_connection()
conn.search(base, filter, attributes=ldap3.ALL_ATTRIBUTES)
found = False
for e in conn.entries:
RESPONSE += (
f'LDAP query results:<br>'
f'Record found with name {e['uid']}<br>'
f'Address: {e['street']}<br>'
)
found = True
conn.unbind()
if not found:
RESPONSE += (
f'LDAP query results: nothing found for query: {helpers.utils.escape_for_html(filter)}'
)
except IOError:
RESPONSE += (
"Error processing LDAP query."
)
return RESPONSE
+67
View File
@@ -0,0 +1,67 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/deserialization-00/BenchmarkTest00508', methods=['GET'])
def BenchmarkTest00508_get():
return BenchmarkTest00508_post()
@app.route('/benchmark/deserialization-00/BenchmarkTest00508', methods=['POST'])
def BenchmarkTest00508_post():
RESPONSE = ""
param = request.headers.get("BenchmarkTest00508")
if not param:
param = ""
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import pickle
import base64
import helpers.utils
helpers.utils.sharedstr = "no pickles to be seen here"
try:
unpickled = pickle.loads(base64.urlsafe_b64decode(bar))
except:
RESPONSE += (
'Unpickling failed!'
)
return RESPONSE
RESPONSE += (
f'shared string is {helpers.utils.sharedstr}'
)
return RESPONSE
+47
View File
@@ -0,0 +1,47 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xss-00/BenchmarkTest00515', methods=['GET'])
def BenchmarkTest00515_get():
return BenchmarkTest00515_post()
@app.route('/benchmark/xss-00/BenchmarkTest00515', methods=['POST'])
def BenchmarkTest00515_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("Referer")
if headers:
param = headers[0]
num = 106
bar = "This should never happen" if (7*42) - num > 200 else param
RESPONSE += (
f'Parameter value: {bar}'
)
return RESPONSE
+69
View File
@@ -0,0 +1,69 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xxe-00/BenchmarkTest00539', methods=['GET'])
def BenchmarkTest00539_get():
return BenchmarkTest00539_post()
@app.route('/benchmark/xxe-00/BenchmarkTest00539', methods=['POST'])
def BenchmarkTest00539_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00539")
if headers:
param = headers[0]
string25731 = 'help'
string25731 += param
string25731 += 'snapes on a plane'
bar = string25731[4:-17]
import xml.dom.minidom
import xml.sax.handler
try:
parser = xml.sax.make_parser()
# all features are disabled by default
doc = xml.dom.minidom.parseString(bar, parser)
out = ''
processing = [doc.documentElement]
while processing:
e = processing.pop(0)
if e.nodeType == xml.dom.Node.TEXT_NODE:
out += e.data
else:
processing[:0] = e.childNodes
RESPONSE += (
f'Your XML doc results are: <br>{escape_for_html(out)}'
)
except:
RESPONSE += (
f'There was an error reading your XML doc:<br>{escape_for_html(bar)}'
)
return RESPONSE
+78
View File
@@ -0,0 +1,78 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xxe-00/BenchmarkTest00540', methods=['GET'])
def BenchmarkTest00540_get():
return BenchmarkTest00540_post()
@app.route('/benchmark/xxe-00/BenchmarkTest00540', methods=['POST'])
def BenchmarkTest00540_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00540")
if headers:
param = headers[0]
possible = "ABC"
guess = possible[1]
match guess:
case 'A':
bar = param
case 'B':
bar = 'bob'
case 'C' | 'D':
bar = param
case _:
bar = 'bob\'s your uncle'
import xml.dom.minidom
import xml.sax.handler
try:
parser = xml.sax.make_parser()
# all features are disabled by default
parser.setFeature(xml.sax.handler.feature_external_ges, True)
doc = xml.dom.minidom.parseString(bar, parser)
out = ''
processing = [doc.documentElement]
while processing:
e = processing.pop(0)
if e.nodeType == xml.dom.Node.TEXT_NODE:
out += e.data
else:
processing[:0] = e.childNodes
RESPONSE += (
f'Your XML doc results are: <br>{escape_for_html(out)}'
)
except:
RESPONSE += (
f'There was an error reading your XML doc:<br>{escape_for_html(bar)}'
)
return RESPONSE
+66
View File
@@ -0,0 +1,66 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00542', methods=['GET'])
def BenchmarkTest00542_get():
return BenchmarkTest00542_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00542', methods=['POST'])
def BenchmarkTest00542_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00542")
if headers:
param = headers[0]
map29056 = {}
map29056['keyA-29056'] = 'a-Value'
map29056['keyB-29056'] = param
map29056['keyC'] = 'another-Value'
bar = "safe!"
bar = map29056['keyB-29056']
bar = map29056['keyA-29056']
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=\'{bar}\']'
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+63
View File
@@ -0,0 +1,63 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00543', methods=['GET'])
def BenchmarkTest00543_get():
return BenchmarkTest00543_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00543', methods=['POST'])
def BenchmarkTest00543_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00543")
if headers:
param = headers[0]
bar = "This should never happen"
if 'should' in bar:
bar = param
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = "".join(['/Employees/Employee[@emplid=\'', bar, '\']'])
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+68
View File
@@ -0,0 +1,68 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00547', methods=['GET'])
def BenchmarkTest00547_get():
return BenchmarkTest00547_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00547', methods=['POST'])
def BenchmarkTest00547_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00547")
if headers:
param = headers[0]
bar = "alsosafe"
if param:
lst = []
lst.append('safe')
lst.append(param)
lst.append('moresafe')
lst.pop(0)
bar = lst[1]
import lxml.etree
import helpers.utils
try:
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = '/Employees/Employee[@emplid=\'' + bar + '\']'
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
+66
View File
@@ -0,0 +1,66 @@
'''
OWASP Benchmark for Python v0.1
This file is part of the Open Web Application Security Project (OWASP) Benchmark Project.
For details, please see https://owasp.org/www-project-benchmark.
The OWASP Benchmark is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version 3.
The OWASP Benchmark is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
Author: Theo Cartsonis
Created: 2025
'''
from flask import redirect, url_for, request, make_response, render_template
from helpers.utils import escape_for_html
def init(app):
@app.route('/benchmark/xpathi-01/BenchmarkTest00549', methods=['GET'])
def BenchmarkTest00549_get():
return BenchmarkTest00549_post()
@app.route('/benchmark/xpathi-01/BenchmarkTest00549', methods=['POST'])
def BenchmarkTest00549_post():
RESPONSE = ""
param = ""
headers = request.headers.getlist("BenchmarkTest00549")
if headers:
param = headers[0]
bar = param
import lxml.etree
import helpers.utils
try:
if '\'' in bar:
RESPONSE += (
"Employee ID must not contain apostrophes"
)
return RESPONSE
fd = open(f'{helpers.utils.RES_DIR}/employees.xml', 'rb')
root = lxml.etree.parse(fd)
query = f'/Employees/Employee[@emplid=\'{bar}\']'
nodes = root.xpath(query)
node_strings = []
for node in nodes:
node_strings.append(' '.join([e.text for e in node]))
RESPONSE += (
f'Your XPATH query results are: <br>[ {', '.join(node_strings)} ]'
)
except:
RESPONSE += (
f'Error parsing XPath Query: \'{escape_for_html(query)}\''
)
return RESPONSE
Loaded 100 of 402 files, more files were not shown because too many files have changed in this diff. Show more