SlideShare a Scribd company logo
1 of 56
Who am I?
Norman Soetbeer
Computer Science Student
Game Developer @ InnoGames
Twitter: @TheBattleRattle
Github: BattleRattle
John Doe
********
submit
LOGIN
743503
submit
Enter your Code
An authenticator is
connected to your account
Welcome
Hey, John Doe!
You successfully logged in
1 2
also known as
TFA, 2FA
Two-Step Authentication
Two-Step Verification (Google)
Two Factor Verification (Dropbox, Twitter)
Login Approvals (Facebook)
Code Generator (Facebook)
three factors
consider two (or more)
knowledge factor
„something only the user knows“
PIN
password
pattern
„What was the name of your first pet?“
possession factor
„something only the user has“
key
smart card
ATM card
mobile phone
hard tokens
USB tokens
inherence factor
„something only the user is“
finger print
iris
voice
DNA
Automatic Teller Machine
ATM card + PIN
=
„something only the user has“
+
„something only the user knows“
requirements for secure factors
strong entropy on secrets
requirements for secure factors
high resistance of a tokens to be cloned
requirements for secure factors
uniqueness and reliability of biometrics
requirements for secure factors
secure transport (tokens, passwords, etc.)
requirements for secure factors
additional management:
disable lost tokens
determine steps for password reset
withdraw credentials, if no longer required
requirements for secure factors
fraud detection:
monitor failed attempts, lock account
what is possible?
knowledge factor
PIN?
knowledge factor
password?
knowledge factor
pattern?
requires javascript / flash, but
knowledge factor
„What was the name of your first pet“?
does not fulfill
„something only the user knows“
possession factor
key?
difficult to check
possession factor
smart card?
requires additional hardware
not usable in web browser (maybe with plugin)
costs (card, card reader, transport of card)
possession factor
USB token?
not usable in web browser (maybe with plugin)
costs (token + transfer)
possession factor
hard token?
costs (token itself, transport)
possession factor
mobile phone?
SMS?
Costs
Give us your phone number?
possession factor
mobile phone?
voice message?
same as SMS
possession factor
mobile phone?
code generator (smart phone)
secret key
secret counter value
public serial
new code on key press
(counter increases)
HMAC-Based One-Time Password
hash = hmac_sha1(key, counter)
offset = last 4 bits of hash
number = 4 bytes from hash, beginning at offset
pad numbers to given length
example
hash = hmac_sha1(„12345“, 1)
20 d4 c6 b0 32 ea 01 da 02 6e
a8 a9 f6 f4 00 41 d0 95 6d 08
offset = last 4 bits of hash
8
number = 4 bytes from hash, beginning at
offset
02 6e a8 a9
pad numbers to given length
40806569
usage
serial key counter uid
FOO-BAR-
BAZ
43A7B66
200DD
7 42456
ABCD-
EFGH-IJKL
AF3A77E
8D638
19 87632
MNOP-
QRST-
UVWX
74DA393
55CB6
2 24572
SERIAL
ABCD-EFGH-IJKL
KEY (secret)
AF3A77E8D638
COUNTER (secret)
19
authenticator web application
generate a new code
serial key counter uid
FOO-BAR-
BAZ
43A7B66
200DD
7 42456
ABCD-
EFGH-IJKL
AF3A77E
8D638
19 87632
MNOP-
QRST-
UVWX
74DA393
55CB6
2 24572
SERIAL
ABCD-EFGH-IJKL
KEY (secret)
AF3A77E8D638
COUNTER (secret)
20
authenticator web application
830429 830429
code was correct
serial key counter uid
FOO-BAR-
BAZ
43A7B66
200DD
7 42456
ABCD-
EFGH-IJKL
AF3A77E
8D638
20 87632
MNOP-
QRST-
UVWX
74DA393
55CB6
2 24572
SERIAL
ABCD-EFGH-IJKL
KEY (secret)
AF3A77E8D638
COUNTER (secret)
20
authenticator web application
830429 830429
code was incorrect (e.g. typo)
serial key counter uid
FOO-BAR-
BAZ
43A7B66
200DD
7 42456
ABCD-
EFGH-IJKL
AF3A77E
8D638
19 87632
MNOP-
QRST-
UVWX
74DA393
55CB6
2 24572
SERIAL
ABCD-EFGH-IJKL
KEY (secret)
AF3A77E8D638
COUNTER (secret)
20
authenticator web application
830428 830429
code was incorrect (e.g. typo)
serial key counter uid
FOO-BAR-
BAZ
43A7B66
200DD
7 42456
ABCD-
EFGH-IJKL
AF3A77E
8D638
19 87632
MNOP-
QRST-
UVWX
74DA393
55CB6
2 24572
SERIAL
ABCD-EFGH-IJKL
KEY (secret)
AF3A77E8D638
COUNTER (secret)
20
authenticator web application
830428 830429
counters out of sync
solution
also check up to 10 upcoming codes
and update counter
secret key
internal clock
new code every 30 seconds
Time-Based One-Time Password
time_frame = floor (unix_timestamp / time_step)
hash = hmac_sha1(key, time_frame)
offset = last 4 bits of hash
number = 4 bytes from hash, beginning at offset
pad numbers to given length
usage
key uid
43A7B66200DD 42456
AF3A77E8D638 87632
74DA39355CB6 24572
KEY (maybe secret)
AF3A77E8D638
UNIX TIMESTAMP
1234567890
authenticator web application
692113 692113
code must be marked as used,
because „one-time password“
wrong code
key uid
43A7B66200DD 42456
AF3A77E8D638 87632
74DA39355CB6 24572
KEY (maybe secret)
AF3A77E8D638
UNIX TIMESTAMP
1234567890
authenticator web application
849372 692113
you should lock the account
for current time frame
what about delays?
clocks out of sync?
simple
just also check one time frame
before and after current one
demo time
// Check Credentials (Step 1)
$username = $_POST['username'];
$password = $_POST['password'];
$user = getUserByCredentials($username, $password);
if (!$user) {
redirect('/login/');
}
if ($user->hasAuthenticator()) {
$session->set('authenticated', false);
} else {
$session->set('authenticated', true);
}
// Check for Authentication
if (!$session->get('authenticated')) {
redirect('/tfa-code/');
}
// Check Code (Step 2)
use BattleRattleDoormanAuthenticationGoogleAuthenticator;
// get the code from user input
$code = $_POST['code'];
// get the associated key for the current user
$key = 'ONETIMEPASSWORDS';
$authenticator = new GoogleAuthenticator();
$result = $authenticator->authenticate($key, $code);
if ($result) {
echo 'Welcome, you successfully logged in';
} else {
echo 'Nope, try again';
}
installation via composer / packagist
“require”: {
“battlerattle/doorman”: “dev-master”
}
questions?
thank you

More Related Content

Similar to Better Security With Two Factor Authentication (PHP Unconference 2013)

3d passwords
3d passwords3d passwords
3d passwordsshwetaag
 
A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeShakacon
 
Cryptomach_En
Cryptomach_EnCryptomach_En
Cryptomach_Ende77
 
BERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery AttackBERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery AttackAlex Matrosov
 
Ron harding projects & figures
Ron harding projects & figuresRon harding projects & figures
Ron harding projects & figuresRon Harding
 
Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)Peter Sabev
 
BalCCon2k18 - Towards the perfect cryptocurrency wallet
BalCCon2k18 - Towards the perfect cryptocurrency walletBalCCon2k18 - Towards the perfect cryptocurrency wallet
BalCCon2k18 - Towards the perfect cryptocurrency walletNemanja Nikodijević
 
Hacking Access Control Systems
Hacking Access Control SystemsHacking Access Control Systems
Hacking Access Control SystemsDennis Maldonado
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Priyanka Aash
 
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2Bhavin Chandarana
 
Hitcon badge 2018
Hitcon badge 2018 Hitcon badge 2018
Hitcon badge 2018 Alan Lee
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -evechiportal
 
Root via sms. 4G security assessment
Root via sms. 4G security assessment Root via sms. 4G security assessment
Root via sms. 4G security assessment Sergey Gordeychik
 
Make the Smartcard great again
Make the Smartcard great againMake the Smartcard great again
Make the Smartcard great againEric Larcheveque
 
Security, Privacy and Trust - Web Technologies (1019888BNR)
Security, Privacy and Trust - Web Technologies (1019888BNR)Security, Privacy and Trust - Web Technologies (1019888BNR)
Security, Privacy and Trust - Web Technologies (1019888BNR)Beat Signer
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Cloudera, Inc.
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Julien Le Dem
 

Similar to Better Security With Two Factor Authentication (PHP Unconference 2013) (20)

amrapali builders@@sub way hacking.pdf
amrapali builders@@sub way hacking.pdfamrapali builders@@sub way hacking.pdf
amrapali builders@@sub way hacking.pdf
 
3d passwords
3d passwords3d passwords
3d passwords
 
A Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts BytecodeA Decompiler for Blackhain-Based Smart Contracts Bytecode
A Decompiler for Blackhain-Based Smart Contracts Bytecode
 
Cryptomach_En
Cryptomach_EnCryptomach_En
Cryptomach_En
 
BERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery AttackBERserk: New RSA Signature Forgery Attack
BERserk: New RSA Signature Forgery Attack
 
Time & Labor Management Brochure
Time & Labor Management BrochureTime & Labor Management Brochure
Time & Labor Management Brochure
 
Ron harding projects & figures
Ron harding projects & figuresRon harding projects & figures
Ron harding projects & figures
 
3 d password
3 d password3 d password
3 d password
 
Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)Secure Software: Action, Comedy or Drama? (2017 edition)
Secure Software: Action, Comedy or Drama? (2017 edition)
 
BalCCon2k18 - Towards the perfect cryptocurrency wallet
BalCCon2k18 - Towards the perfect cryptocurrency walletBalCCon2k18 - Towards the perfect cryptocurrency wallet
BalCCon2k18 - Towards the perfect cryptocurrency wallet
 
Hacking Access Control Systems
Hacking Access Control SystemsHacking Access Control Systems
Hacking Access Control Systems
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.
 
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
Presentation for IoT workshop at Sinhagad University (Feb 4, 2016) - 2/2
 
Hitcon badge 2018
Hitcon badge 2018 Hitcon badge 2018
Hitcon badge 2018
 
Track c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eveTrack c-High speed transaction-based hw-sw coverification -eve
Track c-High speed transaction-based hw-sw coverification -eve
 
Root via sms. 4G security assessment
Root via sms. 4G security assessment Root via sms. 4G security assessment
Root via sms. 4G security assessment
 
Make the Smartcard great again
Make the Smartcard great againMake the Smartcard great again
Make the Smartcard great again
 
Security, Privacy and Trust - Web Technologies (1019888BNR)
Security, Privacy and Trust - Web Technologies (1019888BNR)Security, Privacy and Trust - Web Technologies (1019888BNR)
Security, Privacy and Trust - Web Technologies (1019888BNR)
 
Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0Efficient Data Storage for Analytics with Apache Parquet 2.0
Efficient Data Storage for Analytics with Apache Parquet 2.0
 
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
Efficient Data Storage for Analytics with Parquet 2.0 - Hadoop Summit 2014
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Better Security With Two Factor Authentication (PHP Unconference 2013)