-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
tests/cli/sql_injection/sql_injection_sqlite_dollar_placeholder.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--TEST-- | ||
Test SQLite database operations | ||
|
||
--ENV-- | ||
AIKIDO_LOG_LEVEL=INFO | ||
AIKIDO_BLOCK=1 | ||
|
||
--FILE-- | ||
<?php | ||
try { | ||
$pdo = new PDO('sqlite::memory:'); | ||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
$pdo->exec("CREATE TABLE IF NOT EXISTS users ( | ||
id INTEGER PRIMARY KEY, | ||
name TEXT, | ||
email TEXT)"); | ||
|
||
$pdo->exec("INSERT INTO users (name, email) VALUES ('John Doe', '[email protected]')"); | ||
|
||
// Simulate user input | ||
$unsafeInput = "1' OR $$ IS NULL -- "; | ||
$_SERVER['HTTP_USER'] = $unsafeInput; | ||
|
||
// Vulnerable query | ||
$result = $pdo->query("SELECT * FROM users WHERE id = $unsafeInput"); | ||
|
||
foreach ($result as $row) { | ||
echo "ID: " . $row['id'] . "\n"; | ||
echo "Name: " . $row['name'] . "\n"; | ||
echo "Email: " . $row['email'] . "\n\n"; | ||
} | ||
} catch (PDOException $e) { | ||
echo "Connection failed: " . $e->getMessage(); | ||
} | ||
|
||
// Close the database connection | ||
$pdo = null; | ||
|
||
?> | ||
|
||
--EXPECTREGEX-- | ||
.*Fatal error: Uncaught Exception: Aikido firewall has blocked an SQL injection.* |