Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqli done #1

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added attack.html
Empty file.
67 changes: 0 additions & 67 deletions extra_ashu/ashu.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="form">
<h2>User Login</h2>
<form action="/" method="POST">
<input type="email" name="username" class="input-field" placeholder="Username" />
<input type="text" name="username" class="input-field" placeholder="Username" />
<input type="password" name="password" class="input-field" placeholder="Password" />
<input type="submit" class="btn" value="LOGIN">
</form>
Expand Down
38 changes: 25 additions & 13 deletions login.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@



const mysql = require("mysql");
const express = require("express");
var path = require('path')
Expand All @@ -9,8 +6,6 @@ const encoder = bodyParser.urlencoded();

const app = express();
app.use("assests",express.static("assests"));
// app.use()
// app.use(express.static(path.join(__dirname, 'assets')));

const connection = mysql.createConnection({
host: "localhost",
Expand All @@ -33,19 +28,33 @@ app.get("/",function(req,res){
app.post("/",encoder, function(req,res){
var username = req.body.username;
var password = req.body.password;
var sql = "inesrt into credentials values ?";
connection.query("select * from credentials where user_name = ? and user_pass = ?",[username,password],function(error,results,fields){

var sql = "select * from credentials where user_name ='"+username+"' and user_pass ='"+password+"'";


// var sql = "inesrt into credentials values ?";
console.log(sql);

connection.query(sql,[username,password],function(error,results,fields){
if (results.length > 0) {
console.log("old user");
console.log(sql);
console.log(results);
console.log(results.length);
res.redirect("/welcome");
// console.log("new user");
} else {
// res.redirect("/");
console.log("new user");
connection.query(sql,['null', username, password], function(err){
if (err) throw err
})
res.redirect("/welcome")
res.redirect("/wrong_pswd");

// var newsql="insert into credentials values('null','"+username+"','"+password+"')"
// var newsql="insert into credentials values( null,' "+username+"','"+password+"')"
// console.log("new user");
// console.log(newsql);

// connection.query(newsql,[username, password], function(err){
// if (err) throw err
// })
// res.redirect("/welcome")
}
res.end();
})
Expand All @@ -55,6 +64,9 @@ app.post("/",encoder, function(req,res){
app.get("/welcome",function(req,res){
res.sendFile(__dirname + "/welcome.html")
})
app.get("/wrong_pswd",function(req,res){
res.sendFile(__dirname + "/wrong_pswd.html")
})


// set app port
Expand Down
3 changes: 0 additions & 3 deletions tempCodeRunnerFile.js

This file was deleted.

12 changes: 12 additions & 0 deletions wrong_pswd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>wrong</title>
</head>
<body>
<h1>WRONG - PASSWORD</h1>
</body>
</html>