SlideShare a Scribd company logo
Click to edit Master title style
1
Cracking the Crypto
Click to edit Master title style
2
$whoami
MIHIR SHAH | SHAHENSHAH
Github: github.com/shahenshah99
Blog: shahenshah99.blogspot.com
2
Click to edit Master title style
3
What is Cryptography?
Cryptography is a funny topic in penetration
testing: it's such a fundamental part of the
entire science of information security, but also
often neglected in security testing.
3
Click to edit Master title style
4
What do we plan on doing
today?
• Bit-flipping attacks against cipher block
chaining algorithms
• Sneaking in malicious requests by calculating
a hash that will pass verification; we'll see
how cryptographic padding helps us
• Padding oracle attack; as the name suggests,
we continue to look at the padding concept
• Installation of two deliberately vulnerable web
applications for testing in your home lab
4
Click to edit Master title style
5
When we consider attacks against
cryptographic ciphers, we usually think
about those attacks against the cipher
itself that allow us to break the code and
recover plaintext. It's important to
remember that the message can be
attacked, even when the cipher remains
unbroken and, indeed, even the full
message is unknown.
5
What are we attacking
exactly, again?
Click to edit Master title style
6
B lock ciphers – A s t he name implies, it encrypt s
dat a in f ixed lengt hs of blocks. From a securit y
st andpoint , t his concept implies t hat secure
encrypt ion is easily achieved f or a single block
of data; you could have high - entropy key
mat erial w it h t he same lengt h as t he block.
H ow w e repeat edly encrypt block af t er block and
link everyt hing t oget her is called a mode of
operat ion . 6
Block Ciphers and mode
of Operations
Click to edit Master title style
7
Rather than me filling up this
slide, to explain how this
works. Let me show you a demo
for the same
7
Electronic Codebook(ECB)
Click to edit Master title style
8
You still don't know what the message is . In the
realm of cryptanalysis, this is a major breakthrough.
A simple rule of thumb about good encryption is: the
cipher text should have no relationship w hatsoever
w ith the plaintext. In this case, w e already know
something is repeating. The effort to attack the
message is already underw ay
8
Ok, we found a Pattern, So
what?
Click to edit Master title style
9
Enter Cipher Block Chaining (CBC),
where we encrypt a block just like
before – except before we encrypt
the next block, we XOR the plaintext
of the next block with the encrypted
output of the previous block,
creating a logical chain of blocks. 9
Introducing Block Chaining
Click to edit Master title style
1010
Click to edit Master title style
11
If we XOR the plaintext block with
the encrypted output of the previous
block, what's the XOR input for
the first block?
11
Hang on!!
Click to edit Master title style
12
B e f o r e m o v i n g o n l e t s j u s t l o o k a t a D e m o o n t h e C B C b a s e d
e n c r y p t i o n f o r t h e s a m e t e x t
12
we need an initial value
appropriately called
the initialization vector
(IV)
Click to edit Master title style
1313
Setting and attacking our
Bit-Flipping Lab
Click to edit Master title style
1414
Manipulating the IV to
generate predictable
results
Click to edit Master title style
1515
Click to edit Master title style
1616
Busting the Oracle Padding
Click to edit Master title style
17
What is padding and Why
should I care?
messages that need to be
encrypted are not of a fixed
length; they may be as short
as Hello World! or as long as
the Zimmermann Telegram. This
is where padding comes in.
PKCS#5/PKCS#7 uses padding
bytes, which are nothing more
than a hexadecimal number
Click to edit Master title style
1818
The number is equal to the
number of padding bytes. For
example, if there are five padding
bytes, they'll all be 0x05.
Click to edit Master title style
19
The purpose of this is to provide the
error-checking mechanism inherent
to this design. So if I come along and
decrypt a message only to find five
padding bytes with the value 0x07,
then guess what prophecy this wise
oracle is telling? Padding error.
Click to edit Master title style
20
• The encrypted data w as padded correctly, and contains
valid server data once decrypted. Basically, a
completely normal operation. The server responds w ith
HTTP 200 OK.
• The encrypted data w as padded
correctly, and contains invalid server data once
decrypted. This is just like sending something
unexpected to a server w ithout encryption, for
example, a file request for a non -existent file. This is
technically an HTTP 200, but typically w ith a custom
error (for example, File Not Found).
• The encrypted data w as padded incorrectly, w hich
breaks the decryption process and hence, nothing gets
actually passed to the server. This causes a
cryptographic exception and the response is an HTTP
500 Internal Server Error.
20
The oracle can tell us one of three things
when we pass encrypted data to the
target:
Click to edit Master title style
2121
The other half is the concept we introduced at the beginning of
the chapter: when you know two out of three binary values that
have an XOR relationship to each other, you can easily solve for
the missing field. So, we tweak the enciphered bits and
repeatedly submit our modified requests, chatting with the oracle
for state feedback, until we stop breaking decryption and the
oracle tells us the padding looks good. With the oracle confirming
the correct padding, this attack becomes a form of known-
plaintext cryptanalysis, allowing us to decrypt the message.
Click to edit Master title style
22
PadBuster can work with this via the -noiv flag
and thus uses the first bytes as an IV; the number
of bytes used as an IV is defined in the block size
parameter. We also know that CBC mode ciphers
XOR the intermediary bits (that is, the bits after
the encryption process) with the corresponding
bits from the previous block (block chaining), so
once decryption has begun, PadBuster works
backwards.
Click to edit Master title style
2323
Q&A
Click to edit Master title style
24
Thank You

More Related Content

PPT
Traditional symmetric-key cipher
KEY
Cryptography for developers
PPTX
presentation based on data encryption standards
PPTX
Php training in chandigarh
PPTX
PHPDoc
PPTX
Encrypted message transmitter on public network
PDF
Pertemuan 4 information hiding (cryptography)
PPT
vertexdb
Traditional symmetric-key cipher
Cryptography for developers
presentation based on data encryption standards
Php training in chandigarh
PHPDoc
Encrypted message transmitter on public network
Pertemuan 4 information hiding (cryptography)
vertexdb

Similar to Cracking the crypto (20)

PPTX
The Cryptography has YOU
PPTX
SSL/POODLE: History repeats itself
PDF
Brief introduction into Padding Oracle attack vector
PPTX
Padding oracle [opkoko2011]
PPTX
Block Cipher Modes Of Operation | Computer Networking and Security | Simplilearn
PDF
Cryptography for Penetration Testers (PDF version)
PPTX
Daniel Crowley - Speaking with Cryptographic Oracles
PPTX
Networking Advance Concepts with handson experience
PDF
SymmetricCryptography-Part3 - Tagged.pdf
PPT
padding oracle attack
PPT
symet.crypto.hill.cipher.2023.ppt
PDF
CNIT 141: 4. Block Ciphers
PDF
CNIT 141: 4. Block Ciphers
PDF
CNIT 125 Ch 4. Security Engineering (Part 2)
PDF
CISSP Prep: Ch 4. Security Engineering (Part 2)
PDF
CNIT 141: 1. Encryption
PDF
CNIT 141: 4. Block Ciphers
PDF
CNIT 141: 1. Encryption
PDF
CNIT 141: 4. Block Ciphers
PPT
CISSP EXAM PREPARATION FOR A PASSED SCORE
The Cryptography has YOU
SSL/POODLE: History repeats itself
Brief introduction into Padding Oracle attack vector
Padding oracle [opkoko2011]
Block Cipher Modes Of Operation | Computer Networking and Security | Simplilearn
Cryptography for Penetration Testers (PDF version)
Daniel Crowley - Speaking with Cryptographic Oracles
Networking Advance Concepts with handson experience
SymmetricCryptography-Part3 - Tagged.pdf
padding oracle attack
symet.crypto.hill.cipher.2023.ppt
CNIT 141: 4. Block Ciphers
CNIT 141: 4. Block Ciphers
CNIT 125 Ch 4. Security Engineering (Part 2)
CISSP Prep: Ch 4. Security Engineering (Part 2)
CNIT 141: 1. Encryption
CNIT 141: 4. Block Ciphers
CNIT 141: 1. Encryption
CNIT 141: 4. Block Ciphers
CISSP EXAM PREPARATION FOR A PASSED SCORE
Ad

More from Mihir Shah (13)

PPTX
Windows custom shellcoding
PPTX
Seh based attack
PPTX
Kubernetes
PPTX
Post exploitation using powershell
PPTX
Securing docker containers
PPTX
Buffer overflow
PPTX
Stego.ppt
PDF
Wi fi pentesting
PPTX
Reversing with gdb
PPTX
PDF
Return Oriented Programming - ROP
PPTX
PMKID ATTACK!!
PPTX
OAuth 2.0
Windows custom shellcoding
Seh based attack
Kubernetes
Post exploitation using powershell
Securing docker containers
Buffer overflow
Stego.ppt
Wi fi pentesting
Reversing with gdb
Return Oriented Programming - ROP
PMKID ATTACK!!
OAuth 2.0
Ad

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
Empathic Computing: Creating Shared Understanding
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Modernizing your data center with Dell and AMD
Empathic Computing: Creating Shared Understanding
Diabetes mellitus diagnosis method based random forest with bat algorithm
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Reach Out and Touch Someone: Haptics and Empathic Computing
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Spectral efficient network and resource selection model in 5G networks
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

Cracking the crypto

  • 1. Click to edit Master title style 1 Cracking the Crypto
  • 2. Click to edit Master title style 2 $whoami MIHIR SHAH | SHAHENSHAH Github: github.com/shahenshah99 Blog: shahenshah99.blogspot.com 2
  • 3. Click to edit Master title style 3 What is Cryptography? Cryptography is a funny topic in penetration testing: it's such a fundamental part of the entire science of information security, but also often neglected in security testing. 3
  • 4. Click to edit Master title style 4 What do we plan on doing today? • Bit-flipping attacks against cipher block chaining algorithms • Sneaking in malicious requests by calculating a hash that will pass verification; we'll see how cryptographic padding helps us • Padding oracle attack; as the name suggests, we continue to look at the padding concept • Installation of two deliberately vulnerable web applications for testing in your home lab 4
  • 5. Click to edit Master title style 5 When we consider attacks against cryptographic ciphers, we usually think about those attacks against the cipher itself that allow us to break the code and recover plaintext. It's important to remember that the message can be attacked, even when the cipher remains unbroken and, indeed, even the full message is unknown. 5 What are we attacking exactly, again?
  • 6. Click to edit Master title style 6 B lock ciphers – A s t he name implies, it encrypt s dat a in f ixed lengt hs of blocks. From a securit y st andpoint , t his concept implies t hat secure encrypt ion is easily achieved f or a single block of data; you could have high - entropy key mat erial w it h t he same lengt h as t he block. H ow w e repeat edly encrypt block af t er block and link everyt hing t oget her is called a mode of operat ion . 6 Block Ciphers and mode of Operations
  • 7. Click to edit Master title style 7 Rather than me filling up this slide, to explain how this works. Let me show you a demo for the same 7 Electronic Codebook(ECB)
  • 8. Click to edit Master title style 8 You still don't know what the message is . In the realm of cryptanalysis, this is a major breakthrough. A simple rule of thumb about good encryption is: the cipher text should have no relationship w hatsoever w ith the plaintext. In this case, w e already know something is repeating. The effort to attack the message is already underw ay 8 Ok, we found a Pattern, So what?
  • 9. Click to edit Master title style 9 Enter Cipher Block Chaining (CBC), where we encrypt a block just like before – except before we encrypt the next block, we XOR the plaintext of the next block with the encrypted output of the previous block, creating a logical chain of blocks. 9 Introducing Block Chaining
  • 10. Click to edit Master title style 1010
  • 11. Click to edit Master title style 11 If we XOR the plaintext block with the encrypted output of the previous block, what's the XOR input for the first block? 11 Hang on!!
  • 12. Click to edit Master title style 12 B e f o r e m o v i n g o n l e t s j u s t l o o k a t a D e m o o n t h e C B C b a s e d e n c r y p t i o n f o r t h e s a m e t e x t 12 we need an initial value appropriately called the initialization vector (IV)
  • 13. Click to edit Master title style 1313 Setting and attacking our Bit-Flipping Lab
  • 14. Click to edit Master title style 1414 Manipulating the IV to generate predictable results
  • 15. Click to edit Master title style 1515
  • 16. Click to edit Master title style 1616 Busting the Oracle Padding
  • 17. Click to edit Master title style 17 What is padding and Why should I care? messages that need to be encrypted are not of a fixed length; they may be as short as Hello World! or as long as the Zimmermann Telegram. This is where padding comes in. PKCS#5/PKCS#7 uses padding bytes, which are nothing more than a hexadecimal number
  • 18. Click to edit Master title style 1818 The number is equal to the number of padding bytes. For example, if there are five padding bytes, they'll all be 0x05.
  • 19. Click to edit Master title style 19 The purpose of this is to provide the error-checking mechanism inherent to this design. So if I come along and decrypt a message only to find five padding bytes with the value 0x07, then guess what prophecy this wise oracle is telling? Padding error.
  • 20. Click to edit Master title style 20 • The encrypted data w as padded correctly, and contains valid server data once decrypted. Basically, a completely normal operation. The server responds w ith HTTP 200 OK. • The encrypted data w as padded correctly, and contains invalid server data once decrypted. This is just like sending something unexpected to a server w ithout encryption, for example, a file request for a non -existent file. This is technically an HTTP 200, but typically w ith a custom error (for example, File Not Found). • The encrypted data w as padded incorrectly, w hich breaks the decryption process and hence, nothing gets actually passed to the server. This causes a cryptographic exception and the response is an HTTP 500 Internal Server Error. 20 The oracle can tell us one of three things when we pass encrypted data to the target:
  • 21. Click to edit Master title style 2121 The other half is the concept we introduced at the beginning of the chapter: when you know two out of three binary values that have an XOR relationship to each other, you can easily solve for the missing field. So, we tweak the enciphered bits and repeatedly submit our modified requests, chatting with the oracle for state feedback, until we stop breaking decryption and the oracle tells us the padding looks good. With the oracle confirming the correct padding, this attack becomes a form of known- plaintext cryptanalysis, allowing us to decrypt the message.
  • 22. Click to edit Master title style 22 PadBuster can work with this via the -noiv flag and thus uses the first bytes as an IV; the number of bytes used as an IV is defined in the block size parameter. We also know that CBC mode ciphers XOR the intermediary bits (that is, the bits after the encryption process) with the corresponding bits from the previous block (block chaining), so once decryption has begun, PadBuster works backwards.
  • 23. Click to edit Master title style 2323 Q&A
  • 24. Click to edit Master title style 24 Thank You