SlideShare ist ein Scribd-Unternehmen logo
1 von 90
Downloaden Sie, um offline zu lesen
Dobrze posól swoje
hasło
Skróty haseł w webie
Leszek Krupiński 4developers 2015
LEAFNODE
Wstęp
User credentials
w web aplikacjach
OWASP Top Ten
#1: Injection
#6: Sensitive Data Exposure
Rule #1:
No Plain Text
Hashing
Funkcja
jednokierunkowa
słoń
żaba
żyrafa
kot
pies
wąż
1
2
3
6
5
4
Skrót to nie
szyfrowanie
Skrót
kryptograficzny
Idealnie: funkcja
różnowartościowa
Wysoka zmienność
>>>	
  sha1('Quick	
  brown	
  fox	
  jumps	
  over	
  the	
  lazy	
  dog')	
  
=>	
  "4ba0c2b764daf33a75f06e4ce4dfdce283aa9a9c"	
  
>>>	
  sha1('Quick	
  brown	
  fox	
  jumps	
  over	
  The	
  lazy	
  dog')	
  
=>	
  “c47983041ddb867c60790f93f681d74fc971ff47"	
  
>>>	
  decbin(ord('T'))	
  
=>	
  "1010100"	
  
>>>	
  decbin(ord('t'))	
  
=>	
  "1110100"
Jak używać w
aplikacji
username = Request->get('username');
password = Request->get('password');
hash = md5(password);
user = Repository->getUser(username, hash);
if (user) {
this->status = LOGGED_IN;
return;
} else {
throw new BadPasswordException();
}
Jak się łamie
skróty?
Brute Force
Zabezpieczenia
aplikacji
95 znaków
6 pozycji
735 091 890 625
Najpierw łatwe hasła
Najpopularniejsze
6-znakowe hasło?
123456
razem: ~900k
user=pass: 5022
user=pass lowercase: 6721
pass zawiera username: 30782
1234: 4172
12345: 3517
123456: 2954
1234567: 161
12345678: 267
123456789: 409
1234567890: 158
same cyfry: 97259
Atak słownikowy
Atak hybrydowy
Reverse Lookup
Tables
czy md5(“jabłko”) jest na liście? …
czy md5(“gruszka”) jest na liście? …
czy md5(“banan”) jest na liście? …
czy md5(“pomarańcza”) jest na liście? …
czy md5(“arbuz”) jest na liście? …
czy md5(“brzoskwinia”) jest na liście? …
nie
tak (użytkownik “janek”)
nie
tak (użytkownicy “zosia”, “franek”)
tak (użytkownik “marek”)
nie
Lookup Table
Wyliczone wcześniej
skróty
password | hash
---------------------------------------------
a | 0cc175b9c0f1b6a831c399e269772661
aa | 4124bc0a9335c27f086f24ba207a4912
aaa | 47bce5c74f589f4867dbd57e9ca9f808
aaaa | 74b87337454200d4d33f80c4663dc5e5
(...)
ab | 187ef4436122d1cc2f40dc2b92f0eba0
aba | 79af87723dc295f95bdb277a61189a2a
abaa | 537964105de1063e88b2fc126750d16e
(...)
cat | d077f244def8a70e5ea758bd8352fcd8
(...)
dog | 06d80eb0c50b49a509b49f2424e8c805
(...)
Minus: rozmiar
7 znaków == 1.5 Pb
Hash chains
Space/time tradeoff
aaaaaa 0b4e7a cdadro 8b8031 umehaoRH H R
PASSWORD CANDIDATE HASH PASSWORD CANDIDATEPASSWORD CANDIDATE HASH
Funkcja redukcyjna
Przeszukiwanie
P1
H1
P2
H2
P3
dog e0d13d cat 4e85aa lion
hawk 867dbd eagle 399e26 pigeon
balltennis basket23dc29b92f0e
party event ball70e5ea33f80c
23dc29
P1
H1
P2
H2
P3
dog e0d13d cat 4e85aa lion
hawk 867dbd eagle 399e26 pigeon
balltennis basket23dc29b92f0e
party event ball70e5ea33f80c
b92f0e
P1
H1
P2
H2
P3
dog e0d13d cat 4e85aa lion
hawk 867dbd eagle 399e26 pigeon
balltennis basket23dc29b92f0e
party event ball70e5ea33f80c
7a68a0
Kolizje
P1
H1
P2
H2
P3
dog e0d13d cat 4e85aa lion
hawk 867dbd eagle 399e26 pigeon
balltennis basket23dc29b92f0e
party event ball70e5ea33f80c
Rainbow Tables
dog e0d13d
cat 4e85aa
lion d023a3
hawk 867dbd
eagle 399e26
pigeon 89f486
balltennis basket23dc29b92f0e 5b9c0f
party
event
ball 23dc29
70e5ea
33f80c tiger d023a3
sparrow 89f486
volley 5b9c0f
venue 23dc29H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
R1
R1
R1
R1
R2
R2
R2
R2
R3
R3
R3
R3
base
foot
room
falconR4
R4
R4
R4
Przeszukiwanie
dog e0d13d
cat 4e85aa
lion d023a3
hawk 867dbd
eagle 399e26
pigeon 89f486
balltennis basket23dc29b92f0e 5b9c0f
party
event
ball 23dc29
70e5ea
33f80c tiger d023a3
sparrow 89f486
volley 5b9c0f
venue 23dc29H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
H
R1
R1
R1
R1
R2
R2
R2
R2
R3
R3
R3
R3
base
foot
room
falconR4
R4
R4
R4
89f486 foot
70e5ea
R4
R4
leg
70e5ea R3
box R4
yellowH
1043da
70e5ea R2
cat H
4e85aa R3
sparrowR3 H
89f486
R4
foot
chain: 71 000
storage: 64GB
Salt
md5(salt+pass)
Unikalny salt
$6dbu$acbd18db4cc2f85cedef
Podstawowa cecha:
unikalność
Minimum 128 bitów
Algorytmy
MD5, SHA-1,SHA-2, SHA-256, SHA-512
Wada: szybkość
50 milionów na sekundę
średniej klasy laptop z poprzedniej generacji (GPU)
6-znakowe: 4 godziny
7-znakowe: 17 dni
8-znakowe: 4,5 roku
180 miliardów na sekundę
Dedykowany do łamania haseł klaster 25 GPU (2012)
6-znakowe: 4 sekundy
7-znakowe: 6 minut
8-znakowe: 10 godzin
Nie wymyślaj
str_rot13(md5(pass
+sha1(salt+pass)))
+md5(sha512(pass))
Lepsze algorytmy
Key stretching
Iteracja skrótu
6-znakowe: 17 minut
7-znakowe: 1 dzień
8-znakowe: 124 dni
n=1000
PBKDF2
Password-Based Key Derivation Function 2
6-znakowe: 28 dni
7-znakowe: 7 lat
8-znakowe: 700 lat
bcrypt
6-znakowe: 120 dni
7-znakowe: 31 lat
8-znakowe: 3000 lat
Strojenie liczby
iteracji
Ile użytkownik
zniesie
Adaptacja do zmian
Alternatywa:
key strengthening
$2y$10$.nIBGM87poP6dbui4ouWNe2dnQUMKFagOz.v1TVDJO63hIZ/XTWWG
Dodatkowe
bezpieczeństwo:
klucz symetryczny
…ale nie jak Adobe
http://bit.ly/adobe-passwords
Timing Safe
Comparison
Przyszłość:
obciążenie pamięci
Dobre rady
Hasła
https://xkcd.com/936/
https://diogomonica.com/posts/password-security-why-the-horse-battery-staple-is-not-correct/
Używaj długich, łatwych do zapamiętania
haseł. Nie przechowuj haseł plain-text.
Używaj salt. Salt ma być indywidualny.
Salt ma być losowy. Salt ma być długi.
Nie używaj dziwnych funkcji skrótu.
Używaj iteracyjnych, dedykowanych
algorytmów skrótu. Używaj bezpiecznego
porównywania ciągów. Wymuszaj politykę
haseł na użytkownikach, ale nie
przesadzaj. Zmieniaj hasła. Nie używaj
tego samego hasła w wielu serwisach.
Rozważ zastosowanie biblioteki do
generowania skrótu. Z czasem zwiększaj
liczbę iteracji. Miej plan awaryjny.
Pytania?
Dziękuję
@leafnode http://speakerdeck.com/leafnode/

Weitere ähnliche Inhalte

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

4Developers 2015: Dobrze posól swoje hasło: skróty haseł w webie - Leszek Krupiński