mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-21 20:18:06 +02:00
[pitboss] phase 02: M2 — Python end-to-end excellence with all hardening baked in
This commit is contained in:
parent
894f587b60
commit
0bf39047b9
50 changed files with 4167 additions and 170 deletions
27
tests/dynamic_fixtures/python/sqli_positive.py
Normal file
27
tests/dynamic_fixtures/python/sqli_positive.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""SQL injection — positive fixture.
|
||||
|
||||
Vulnerable function: directly concatenates user input into SQL.
|
||||
Expected verdict: Confirmed (SQLI corpus UNION payload causes "NYX_SQL_CONFIRMED"
|
||||
to appear in output when the fixture prints query results).
|
||||
"""
|
||||
import sqlite3
|
||||
|
||||
|
||||
def login(username):
|
||||
"""Vulnerable login: direct string concatenation in SQL query."""
|
||||
conn = sqlite3.connect(":memory:")
|
||||
conn.execute("CREATE TABLE users (id INTEGER, name TEXT)")
|
||||
conn.execute("INSERT INTO users VALUES (1, 'alice')")
|
||||
conn.execute("INSERT INTO users VALUES (2, 'bob')")
|
||||
# Vulnerable: user input directly concatenated
|
||||
query = "SELECT name FROM users WHERE name='" + username + "'"
|
||||
try:
|
||||
rows = conn.execute(query).fetchall()
|
||||
for row in rows:
|
||||
print(row[0])
|
||||
except sqlite3.OperationalError as e:
|
||||
# Error-based: print query on failure (common in debug mode)
|
||||
print(f"DB query: {query}")
|
||||
print(f"DB error: {e}", end="")
|
||||
finally:
|
||||
conn.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue