diff options
author | Marcin Zelent <zelent.marcin@gmail.com> | 2018-05-30 16:53:50 +0200 |
---|---|---|
committer | Marcin Zelent <zelent.marcin@gmail.com> | 2018-05-30 16:53:50 +0200 |
commit | bf3c141f3c318b45b1f43d962623587ac26a92a2 (patch) | |
tree | 0972fb5aa6b4f1c4ae43331b106b3c4afaa63421 /sql-injection | |
parent | aceb07718aa45bb994e595fa23308bcb07d01c2b (diff) |
Added SQL injection example
Diffstat (limited to 'sql-injection')
-rw-r--r-- | sql-injection/index.html | 25 | ||||
-rw-r--r-- | sql-injection/login.php | 23 | ||||
-rw-r--r-- | sql-injection/users.db | bin | 0 -> 8192 bytes |
3 files changed, 48 insertions, 0 deletions
diff --git a/sql-injection/index.html b/sql-injection/index.html new file mode 100644 index 0000000..d3e760b --- /dev/null +++ b/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/sql-injection/login.php b/sql-injection/login.php new file mode 100644 index 0000000..826c38c --- /dev/null +++ b/sql-injection/login.php @@ -0,0 +1,23 @@ +<?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 = 'SELECT * FROM Users WHERE email=\''.$email.'\' AND password=\''.$pass.'\''; + + $ret = $db->query($sql); + while($row = $ret->fetchArray(SQLITE3_ASSOC)) { + echo 'Logged in as '.$row['email'].'<br>'; + } + $db->close(); + } +?> diff --git a/sql-injection/users.db b/sql-injection/users.db Binary files differnew file mode 100644 index 0000000..9ddf64e --- /dev/null +++ b/sql-injection/users.db |