28
Password Cracking AKA how to be a real hackerman Husnain

Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Password CrackingAKA how to be a real hackerman

Husnain

Page 2: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Have you ever gotten an email like this?

Page 3: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How did they get the password in the first place?Password dumps.

https://haveibeenpwned.com/Passwords

Page 4: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do hackers get these dumps?

Page 5: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do websites store passwords?

Website Database

requests password

sends back if password is in database

Page 6: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do websites store passwords?

Page 7: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do websites store passwords?

{“username” : “user”, “password”: “password”}

Page 8: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do websites store passwords?

{“username” : “user”, “password”: “password”}

Database

SELECT * FROM users WHERE username == “user” AND password == “password”

Page 9: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do websites store passwords?

Database

user found!

Page 10: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How do websites store passwords?

Database

user found!redirect to actual page

Page 11: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

SQL - language that databases speak

SELECT

username, bio FROM users

WHERE username LIKE "%a%"

input

Page 12: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

SQL Injectionwe don’t sanitize user input...

SELECT

username, bio FROM

users

WHERE username LIKE

"%%%"

matches any string

Page 13: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

SQL Injectionso we can get arbitrary code execution!

SELECT

username, bio FROM

users

WHERE username LIKE

"%" UNION SELECT

1,2;--%"

Page 14: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Table Enumerationso we can get arbitrary code execution!

SELECT username, bio FROM users WHERE username LIKE "%" UNION

SELECT 1,sql FROM sqlite_master WHERE type='table';--%"

Page 15: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

CREATE TABLE users ( username text primary key not null, password_hash text not null, hint text not null, bio text not null)

table name

column names

Page 16: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How to leak passwords?Left as exercise

Page 17: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

HashingIf things go wrong, an attacker can leak all passwords on a server

Therefore, most websites don’t store raw passwords, but hashed ones

From Wikipedia: “A hash function is any function that can be used to map data of arbitrary size to fixed-size values.”

Basically, a function that is easy to calculate one way but hard to go back the other way*

Page 18: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Example: MD5

md5(“password”) = 5f4dcc3b5aa765d61d8327deb882cf99

md5(“Password”) = dc647eb65e6711e155375218212b3964

Page 19: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Don’t use MD5● Hashcat - open source software designed to crack hashes● To use Hashcat, it’s best to have a faster computer with a GPU, or just use

Google Colab and use their free GPUs ¯\_(ツ)_/¯

https://github.com/mxrch/penglab

Page 20: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

* Computers are very fast

We can crack 21 billion hashes per second!

Page 21: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Brute-force attackAssuming your password contains just uppercase characters, lowercase characters, and numbers ([A-Z],[a-z],[0-9]), we have:

Number of Characters Number of Possible Passwords

Time to Crack

3 238328 nearly instantly

4 ~14 million nearly instantly

5 ~900 million 43 milliseconds

6 ~56 billion 2.7 seconds

7 ~3.5*10^12 2 minutes

8 ~2.2*10^14 3 hours

9 ~1.4*10^16 7.5 days

Page 22: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Live demo (brute force)

Page 23: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Dictionary attackIf people use a password on a compromised site, they probably have used it on another website

Page 24: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Live demo (dictionary attack)

Page 25: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Rule attackpassword

password123password00p@sswordpa$$wordPasswordP@$$wordPa$$w0rdP@$$w0rd123Password123123password123...

Page 26: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Live demo (rule attack)

Page 27: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

How to protect yourself● Sanitize input in web apps● Make good passwords● Don’t reuse passwords● Use a password manager

Obligatory XKCD reference

Page 28: Password Cracking · 2021. 4. 23. · Hashing If things go wrong, an attacker can leak all passwords on a server Therefore, most websites don’t store raw passwords, but hashed ones

Questions?