Skip to main content

Unit 5 · Gotta Catch 'Em All! · Lesson 44 of 57

Project: Leaked!

Project time!

When a website gets hacked, the passwords sometimes end up posted online in giant lists. Attackers then try those passwords on other websites, because people reuse them. (This is called credential stuffing, and it works way more than it should.)

So good websites check new passwords against those leaked lists, and warn you if yours is on one.

Let's build that checker for the CyberAcad team.

What it should do

Make a function called find_leaked that takes two things:

  • users: a dictionary of usernames and their passwords
  • leaked: a list of leaked passwords

It should return a list of usernames whose password is in leaked, in the same order as users.

Then, under the function, use it on the users and leaked you're given, and print a warning for each one:

WARNING: amer is using a leaked password!
WARNING: alex is using a leaked password!

Everything from this unit shows up here: dictionaries, .items(), lists, in, and .append(). Take it one step at a time!

Find the leaked passwords!

Python exercise

Write the program in an editor next to the lesson, run it, and have it checked automatically. Create a free account to do this part.

Nice work!

That's (a tiny version of) a real security feature. Big websites check your new password against billions of leaked ones, using the same idea you just wrote: is this password in the leaked list?

Two takeaways:

  • Never reuse passwords. If one website leaks it, every website you used it on is at risk.
  • Amer, please. We've talked about this.

Do this lesson for real

With a free account you get the terminals, challenges and checks that go with the lessons in Intro to Python, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.