Demonstration Of Credential Manager Using CSV
[Link]
This project is a simple Credential Management System developed in Python. It uses CSV file
handling to store and manage user credentials. The program allows users to add new usernames and
passwords, search for a specific password to find the associated username, and display all stored
credentials through a menu-driven interface.
The project demonstrates the application of important Python concepts such as functions, loops,
conditional statements, file handling, exception handling, and the CSV module. It is a practical
example of how data can be securely stored and retrieved using text files in tabular format.
.
[Link]
The script consists of two main functions: one for saving credentials to a CSV file and one for
searching (cracking) a password. Users can enter multiple username-password pairs, which are
appended to [Link]. The password cracker function reads through each entry in the file,
comparing the stored passwords against a target password provided by the user. For each attempt,
the script displays the username and the attempted password and stops if a match is found.
[Link]
- Interactive console input for entering and storing multiple username-password pairs.
- Secure storage in a CSV file format for easy management and demonstration.
- Case-insensitive password comparison during search attempts.
- Clear on-screen feedback for every attempt and result.
- Graceful handling of missing or incomplete data and missing files.
[Link]
- Educational tool for demonstrating the risks of weak passwords and plaintext password storage.
- Can be used in cybersecurity training classes as a hands-on exercise.
- Useful for illustrating the mechanics of dictionary attacks to beginners.
- Highlights the need for password hashing and secure authentication practices.
[Link] Enhancements
- Add password hashing (e.g., SHA-256) to demonstrate the di erence between secure and insecure
storage.
- Allow search by username as well as by password.
- Implement support for larger or external wordlists for more realistic attacks.
- Add a graphical user interface (GUI) for better usability.
- Include logging and reporting features for audit and analysis.
- Add multi-threading to simulate faster attack scenarios.
SOURCE CODE
import csv
import time
#to make to text go up so it can’t be seen
def clear_screen():
print('\n' * 100)
#to add and save credentials
def save_credentials():
with open('[Link]', 'a', newline='') as f:
writer = [Link](f)
S=[]
while True:
username = input('Enter your username: ').strip()
password = input('Enter your password: ').strip()
S=[username, password]
[Link](S)
ch = input("Type 'break' to stop, or press Enter to continue: ")
if [Link]() == 'break':
break
#to search the targeted password
def password_search():
search_password = input("Enter the password you want to search for: ").strip()
found = False
attempts=0
try:
with open('[Link]', newline='') as f:
reader = [Link](f)
for row in reader:
if len(row) < 2:
continue
username = row[0].strip()
pw = row[1].strip()
attempts += 1
clear_screen()
[Link](0.2)
if [Link]() == target_password.lower():
print("Password found:", pw)
print("Associated username:", username)
found = True
break
if not found:
print(f"Password not found in '[Link]'")
else:
print("Search finished successfully!")
except FileNotFoundError:
print(f"ERROR: File '[Link]' not found. Please ensure the file is in the samedirectory.")
def show_menu():
while True:
print("== Credential Demo Menu ==")
print("1) Add credentials (append)")
print("2) Search for a password in the CSV")
print("3) Show contents CSV file")
print("4) Exit")
choice = input("Choose (1-4): ").strip()
if choice == "1":
save_credentials()
elif choice == "2":
password_cracker()
elif choice == "3":
try:
with open('[Link]', newline='') as f:
reader = [Link](f)
for data in reader:
print(data)
except FileNotFoundError:
print("No credentials file found.")
elif choice == "4":
print("Bye.")
break
else:
print("Invalid choice — try again.")
save_credentials()
[Link](0.2)
print('showing you the interface menu,please wait!')
show_menu()
Sample Input and Output
Entering and adding credentials
To search the targeted password
To display the contents of CSV file
To exit
Conclusion
The provided Python program serves as a simple demonstration of credential management through
a command-line interface. Designed for educational purposes, the script allows users to store,
search, and display username and password pairs within a CSV file. Upon running the program, users
interact with a menu-driven system that guides them through each available function. The main
menu presents options to add new credentials, search for a password, display the contents of the
credentials file, or exit the application.
To add credentials, users are prompted to enter a username and a corresponding password, which
are then appended to a CSV file named ‘[Link]’. This process can be repeated as needed,
providing a practical example of file writing operations in Python. For searching, the program asks the
user to input a password, then scans the CSV file to find a match, displaying the associated
username if the password is found. The ability to view all stored credentials further helps users
understand how data can be retrieved and presented from a file.
While the program e ectively demonstrates basic concepts such as user input handling, file
operations, and data searching, it is important to recognize its limitations. The storage of passwords
in plain text is inherently insecure, making this approach unsuitable for any real-world application
involving sensitive information. Users are cautioned against employing this script for actual
credential management beyond the classroom or demonstration setting.
There are several areas for potential improvement. Introducing password hashing would significantly
enhance the security aspect, even in educational scenarios. Additionally, implementing input
validation, error handling, and a more user-friendly interface would make the program more robust
and accessible. Teachers and students can also use this foundation to explore more advanced
topics, such as database integration or graphical user interfaces.
In conclusion, this Python script provides a practical learning tool for those new to file handling and
basic menu-driven programming. By experimenting with and extending the code, students can
deepen their understanding of both fundamental and advanced programming concepts, while also
appreciating the importance of security best practices in software development
Bibliography
Books
1. NCERT Computer Science Textbook-Class 11
National Council of Educational Research and Training (NCERT), New Delhi.
2. NCERT Computer Science Textbook-Class 12
National Council of Educational Research and Training (NCERT), New Delhi.
Websites
1. CSV Module Documentation - [Link]
[Link]
2. Github- Python Programming Tools
[Link]