aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examples-secure/sql-injection')
-rw-r--r--examples-secure/sql-injection/index.html25
-rw-r--r--examples-secure/sql-injection/login.php25
-rw-r--r--examples-secure/sql-injection/users.dbbin0 -> 8192 bytes
3 files changed, 50 insertions, 0 deletions
diff --git a/examples-secure/sql-injection/index.html b/examples-secure/sql-injection/index.html
new file mode 100644
index 0000000..d3e760b
--- /dev/null
+++ b/examples-secure/sql-injection/index.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Login page</title>
+ <meta charset="utf-8" />
+<style>
+body {
+ text-align: center;
+}
+
+input {
+ margin-bottom: 5px;
+}
+
+</style>
+ </head>
+ <body>
+ <h1>Login</h1>
+ <form action="login.php" method="post">
+ <input type="text" name="email" placeholder="E-mail"><br>
+ <input type="password" name="pass" placeholder="Password"><br>
+ <input type="submit" value="Log in">
+ </form>
+ </body>
+</html>
diff --git a/examples-secure/sql-injection/login.php b/examples-secure/sql-injection/login.php
new file mode 100644
index 0000000..f0340e3
--- /dev/null
+++ b/examples-secure/sql-injection/login.php
@@ -0,0 +1,25 @@
+<?php
+ class MyDB extends SQLite3 {
+ function __construct() {
+ $this->open('users.db');
+ }
+ }
+
+ if(isset($_POST['email'], $_POST['pass']))
+ {
+ $email = $_POST['email'];
+ $pass = $_POST['pass'];
+
+ $db = new MyDB();
+
+ $sql = $db->prepare('SELECT * FROM Users WHERE email=:email AND password=:pass');
+ $sql->bindValue(':email', $email, SQLITE3_TEXT);
+ $sql->bindValue(':pass', $pass, SQLITE3_TEXT);
+
+ $ret = $sql->execute();
+ while($row = $ret->fetchArray(SQLITE3_ASSOC)) {
+ echo 'Logged in as '.$row['email'].'<br>';
+ }
+ $db->close();
+ }
+?>
diff --git a/examples-secure/sql-injection/users.db b/examples-secure/sql-injection/users.db
new file mode 100644
index 0000000..9ddf64e
--- /dev/null
+++ b/examples-secure/sql-injection/users.db
Binary files differ