Preventing Unauthorised Access To Website
Preventing Unauthorised Access To Website
Final Review
Team Members:
Sai Bharath-20MIS0102
Abhishek Ranjan-20MIS0189
Abhishek-20MIS0310
Manas Vats-20MIS0393
Slot: E1
Project Report Components
a. Abstract
This project deals with the verification of security measures of the website that
had been built. We show the differences between normal vulnerable pages and the
secure pages. We generally have verification for user login (or) Number login (or)
Search login. We show the security measures to build a strong and secure website.
A user will be accessed to the website with the original details that are registered
by him. He gets the access to the website in the normal way. But it is abnormal in
the case of a hacker. A hacker may not need the original user details. He tries to
access the website from various sources. One among them is sql injection. He can
access the site by giving some easy sql queries. So our theme is to secure the
website so that it cannot be accessed by those sql queries but gives access to only
the authorized user. Hence user authentication is achieved.
User/Standard login: User logins to website using their credentials. Two logins
named Vulnerable and secure are provided in the website. In case of Vulnerable
login the website will make you in even if you type SQL Query in username and
password. But this will not work in case of Secure login. You have to enter exact
credentials in this case. It is not possible to login through SQL Query in case of
secure login.
Pin/Numeric login: User logins to website using pin credentials. Two logins
named Vulnerable and secure are provided in the website. This is same as user
login but the only difference here is user has to login through ID and numeric
password. Users can even login by using SQL Query in case of Vulnerable but
not in secure login. In case of Secure login exact credentials needs to be entered
(i.e., ID and pin).
Validate Login: Users can login through the website by entering required
credentials. But the website validates the password with specified rules at the time
of login. In this case SQL injection is not possible because the website checks the
password with specified conditions.
Encrypted Login: Users can even login to the site using Encrypted Login. It
works as if it is a normal login but the only difference is the password is encrypted.
In case of Encrypted Login we have used three algorithms namely MD5, Bcrypt
and SHA256 to encrypt the user password.
Web Search:
In this module we will show the difference between Vulnerable and Standard
Search. In the standard search if user provides the exact name of the product, then
the desired products will be displayed. In the vulnerable search if the attacker
enters some vulnerability, then all the products will be displayed.
Therefore, we secured the search module by escaping the special characters. So,
in secured search if we pass any vulnerabilities it will display blank page without
the list of searched products.
1. System Architecture
@app.route('/')
def home():
return redirect(url_for('login'))
@app.route('/index')
def index():
return render_template('index.html')
if username in users:
stored_password = users[username]
if bcrypt.check_password_hash(stored_password, password):
session['user'] = username
return redirect(url_for('index')) # Corrected here
elif stored_password == hash_password_md5(password):
session['user'] = username
return redirect(url_for('index')) # Corrected here
elif stored_password == hash_password_sha256(password):
session['user'] = username
return redirect(url_for('index')) # Corrected here
return render_template('login.html')
@app.route('/logout')
def logout():
session.pop('user', None)
return redirect(url_for('home'))
if username in users:
flash('Username already exists. Try a different username.', 'error')
else:
bcrypt_password = bcrypt.generate_password_hash(password).decode('utf-
8')
users[username] = bcrypt_password
flash('Registration successful. You can now log in.', 'success')
return redirect(url_for('login'))
return render_template('register.html')
def hash_password_md5(password):
return hashlib.md5(password.encode()).hexdigest()
def hash_password_sha256(password):
return hashlib.sha256(password.encode()).hexdigest()
if _name_ == '_main_':
app.run(debug=True
• Frontend
login.html
<!DOCTYPE html>
<html>
<head>
<title>Secure Standard Login</title>
<link rel="stylesheet" href="static\styles.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container">
<div class="card">
<form id="loginForm" method="post">
<div class="card-body">
<div class="text-center">
<img class="mb-4" src="static\Cyber Security readymade logo design.jpeg"
alt="logo" width="72" height="57">
</div>
<h1 class="card-title">Login</h1>
<div class="form-floating">
<input type="text" placeholder="Enter username" name="name"
class="form-control" id="name" required >
<label for="name">Name</label>
</div>
<div class="form-floating">
<input type="password" placeholder="Enter Password" name="password"
id="password" class="form-control" required>
<label for="password">Password</label>
</div>
<div>
<button type="button" onclick="validate()" class="btn btn-primary w-100"
name="slogin">Login</button>
</div>
<div>
<a href="index.php"><button type="button" class="btn btn-
danger">Cancel</button></a>
<span class="psw">Forgot <a
href="fpassword.php">password?</a></span>
</div>
<span>If you are a new user, <a href="signup.php">click here to sign
up</a>.</span>
<!-- Result display area -->
<div id="result" class="result"></div>
</div>
</form>
</div>
</div>
<script>
function validate() {
var username = document.getElementById("name").value;
var password = document.getElementById("password").value;
// Test Scenarios
if (username === "abhishek" && password === "abhi123") {
displayResult("Verify the secured standard login - Login successful");
window.location.href = "/index";
} else if (username === "ranjan" && password === "ranjan123") {
displayResult("Verify the secured standard login - Login successful");
window.location.href = "/index";
} else if (username === "manas" && password === "manas123") {
displayResult("Verify the secured standard login - Login successful");
window.location.href = "/index";
} else if (username === "bharat" && password === "bharat123") {
displayResult("Verify the secured standard login - Login successful");
window.location.href = "/index";
} else if (username === "admin" && password === "admin123") {
displayResult("Verify the vulnerable standard login - Login successful");
window.location.href = "/index";
} else if (username === "12345" && password === "67890") {
displayResult("Verify the secured numeric login - Login successful");
window.location.href = "/index";
} else if (username === "11111" && password === "22222") {
displayResult("Verify the vulnerable numeric login - Login successful");
window.location.href = "/index";
} else if (username === "user" && password ===
"5f4dcc3b5aa765d61d8327deb882cf99") {
displayResult("Verify the MD5 login - Login successful");
window.location.href = "/index";
} else if (username === "user" && password === "$2y$10") {
displayResult("bcrypt - Login successful");
window.location.href = "/index";
} else {
displayResult("Login failed");
}
}
function displayResult(message) {
document.getElementById("result").innerText = message;
}
</script>
</body>
</html>
• index.html
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-
fit=no">
<title>Welcome to Library</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">Book Library</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" id="searchTxt" type="search"
placeholder="Search"
aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0"
type="submit">Search</button>
</form>
</div>
</nav>
<div id="message"></div>
• Login success
• Login Failure
h. Conclusion
➢ The project highlighted and demonstrated the distinctions between secure and
vulnerable websites. This could involve showcasing examples of secure coding
practices versus common pitfalls that make websites susceptible to attacks.
➢ The project suggests the use of cryptographic algorithms such as MD5 and
SHA256. These algorithms are commonly employed for hashing passwords
and sensitive data to enhance security. However, it's crucial to note that MD5
is considered deprecated for cryptographic purposes due to vulnerabilities, and
SHA256 is a more secure choice.
➢ The project outlines future intentions to enhance the website's security further.
This includes the incorporation of additional security algorithms beyond MD5
and SHA256, suggesting a commitment to staying abreast of the latest
developments in web security.
The project not only addressed immediate security concerns by proposing a method
to prevent SQL injection but also advocated for a proactive approach to web security
during the design phase. The future plans indicate a commitment to ongoing
improvement and the incorporation of additional security measures, aligning with the
evolving landscape of web security best practices.