Question: You are working on a cybersecurity project, and your task is to create a secure password validation system for a company s employee login portal.

You are working on a cybersecurity project, and your task is to create a secure password validation system for a companys employee login portal. The system must:
1. Validate passwords based on the following rules:
Minimum 10 characters.
Contains at least one uppercase letter, one lowercase letter, one digit, and one special character (!@#$%^&*).
No spaces are allowed.
The password should not be easily guessable (avoid common patterns such as password123 or admin!).
2. Implement rate limiting: After 3 invalid attempts, the system should lock the user out for 5 seconds before allowing another attempt.
3. Track repeated passwords: If a user tries the same invalid password more than once, it should raise a
custom RepeatedPasswordError.
4. Implement multi-layer validation:
First, check if the password meets the structural requirements.
Then, check if the password is secure by consulting a predefined list of common passwords and patterns.
Lastly, ensure that no part of the users previous invalid attempts matches the new password attempt.
You must implement proper error handling for all scenarios.
Tasks
1. Custom Exceptions: Write and use the following custom exception classes:
- RepeatedPasswordError to handle repeated password attempts.
- WeakPasswordError for passwords that are either too short or too weak (common
passwords or easily guessable patterns).
- InvalidStructureError for passwords that do not meet the structural criteria.
2. Password Validation Function: Write a function validate_password(password,
previous_attempts) that:
- Raises InvalidStructureError if the password is shorter than 10 characters, does not
contain uppercase/lowercase letters, or lacks special characters.
- Raises WeakPasswordError if the password is found in the list of common passwords or contains common patterns such as password123 or admin!.
- Raises RepeatedPasswordError if the password has been previously attempted during the same session.
3. Error Handling and Rate Limiting: Write a script that:
- Tracks the number of failed attempts. If there are 3 invalid attempts in a row, locks the user out for 5 seconds before allowing another attempt.
- Uses a try-except block to handle all errors and displays an appropriate message for each.
- After every password attempt, print Attempt completed using the finally block.
4. User Input and Interaction: Implement a loop that continuously prompts the user to enter a valid password. The program should only stop when a valid password is entered or if the user gives up after 5 failed attempts (after applying rate limiting).
5. Exception Handling Without Custom Exceptions: Implement a feature where the user is prompted to input their password twice (for confirmation). Ensure that:
- If the two inputs do not match, an exception is raised and handled (you may use a built- in exception such as ValueError).
- If the passwords match, the system proceeds to the validation process

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!