64
“Hollywood Style Decryption” on Block Cipher-CBC Rizki Wicaksono / ilmuHacking.com

Hollywood style decryption

Embed Size (px)

DESCRIPTION

Hollywood style decryption - Rizki Wicaksono

Citation preview

Page 1: Hollywood style decryption

“Hollywood Style Decryption”

on Block Cipher-CBC Rizki Wicaksono / ilmuHacking.com

Page 2: Hollywood style decryption

Rizki Wicaksono

•  Penetration tester

•  Programming, application security, cryptography

•  S1 Teknik Informatika ITB, ECSP, OSWP, ITIL-F

•  ilmuHacking.com , facebook.com/ilmuHacking

Page 3: Hollywood style decryption

Hollywood Style Password Cracking

Page 4: Hollywood style decryption

Lets Watch Some Movies

Page 5: Hollywood style decryption

Resident Evil Breaking Door Key Scene

Page 6: Hollywood style decryption

Terminator 2 ATM PIN Cracking Scene

Page 7: Hollywood style decryption

Wargame Launch Code Hacking Scene

Page 8: Hollywood style decryption

The Matrix Beginning Scene

Page 9: Hollywood style decryption

Bloodfist IV Passcode Breaking Scene

Page 10: Hollywood style decryption

Hollywood Style Decryption with

Padding Oracle Attack

Page 11: Hollywood style decryption

Sample Real Attack

Page 12: Hollywood style decryption

Morpheus: Let’s Go See the Oracle

Page 13: Hollywood style decryption

The Oracle

Page 14: Hollywood style decryption

Padding Oracle: Valid/Invalid Pad

Page 15: Hollywood style decryption

1 Bit Information Leakage

Page 16: Hollywood style decryption

PKCS#7 Valid Padding

Page 17: Hollywood style decryption

PKCS#7 Invalid Padding

Page 18: Hollywood style decryption

Cipher Block Chaining

Page 19: Hollywood style decryption

CBC Mode Encryption

Page 20: Hollywood style decryption

CBC Mode Decryption

Page 21: Hollywood style decryption

Malleability

Page 22: Hollywood style decryption

Enough Talking, Start Cracking!

Page 23: Hollywood style decryption

Sample Case

•  Decrypt this: 2D7850F447A90B87123B36A038A8682F

•  Split into two 8 byte blocks: •  C1 = 2D7850F447A90B87

•  C2 = 123B36A038A8682F

•  Decrypt C2 first, send two block to oracle: •  One block + 123B36A038A8682F

•  Decrypt one byte at a time (“hollywood style”) starting from the last byte

Page 24: Hollywood style decryption

Decrypt Last Byte

Page 25: Hollywood style decryption

Ask the Oracle

•  A xor B = 01. Find A and B!

•  Ask the Oracle: •  A xor 0 = 01 ?

•  A xor 1 = 01 ?

•  ….

•  A xor 255 = 01 ?

•  Oracle answer: •  Valid pad = Yes

•  Invalid pad = No

Page 26: Hollywood style decryption

Look for Valid Single Byte Pad

Page 27: Hollywood style decryption

Valid Single Byte Pad Found!

Page 28: Hollywood style decryption

Last Byte Decrypted

Page 29: Hollywood style decryption

Last Byte = 0x86

•  A xor B = 01. Find A and B!

•  Ask the Oracle: •  A xor 0x85 = 01 ?

•  Oracle answer: •  Valid pad = Yes

•  A must be 0x86

Page 30: Hollywood style decryption

Decrypt 7th Byte

Page 31: Hollywood style decryption

Decrypt 7th Byte

Page 32: Hollywood style decryption

Look for Valid 2 Byte Pad

Page 33: Hollywood style decryption

Valid 2 Byte Pad Found!

Page 34: Hollywood style decryption

7th Byte Decrypted

Page 35: Hollywood style decryption

Decrypt 6th Byte

Page 36: Hollywood style decryption

Decrypt 6th Byte

Page 37: Hollywood style decryption

Valid 3 Byte Pad Found

Page 38: Hollywood style decryption

6th Byte Decrypted

Page 39: Hollywood style decryption

Decrypt 5th Byte

Page 40: Hollywood style decryption

Decrypt 5th Byte

Page 41: Hollywood style decryption

Valid 4 Byte Pad Found

Page 42: Hollywood style decryption

5th Byte Decrypted

Page 43: Hollywood style decryption

Decrypt 4th Byte

Page 44: Hollywood style decryption

Decrypt 4th Byte

Page 45: Hollywood style decryption

Look for Valid 5 Byte Pad

Page 46: Hollywood style decryption

Valid 5 Byte Pad Found

Page 47: Hollywood style decryption

4th Byte Decrypted

Page 48: Hollywood style decryption

Full Block Decrypted

Page 49: Hollywood style decryption

C2 Block Decrypted

Page 50: Hollywood style decryption

Case

Page 51: Hollywood style decryption

The Oracle

Page 52: Hollywood style decryption

Decryptor

Page 53: Hollywood style decryption

Decryption Demo

Page 54: Hollywood style decryption

Encrypt Fake Message

Page 55: Hollywood style decryption

Encrypt without Knowing the Key

•  You can make cipher text say whatever you want when decrypted

•  Property of CBC mode

Page 56: Hollywood style decryption

P2 depends on C1

Page 57: Hollywood style decryption

“KILL IT”

Page 58: Hollywood style decryption

“KILL IT”

Page 59: Hollywood style decryption

Encryption Procedure

•  Encrypt: “BESOK PAGI SERANGAN UMUM IWO JIMA”

•  Split plaintext into blocks: •  P1 = ‘BESOK PA’

•  P2 = ‘GI SERAN’

•  P3 = ‘GAN UMUM’

•  P4 = ‘ IWO JIM’

•  P5 = ‘A’+07+07+07+07+07+07+07

Page 60: Hollywood style decryption

Encryption Procedure

•  Choose C5 all-zeros

•  Use padding oracle attack to find Decrypt(Ci)

•  C4 = Decrypt(C5) XOR P5

•  C3 = Decrypt(C4) XOR P4

•  C2 = Decrypt(C3) XOR P3

•  C1 = Decrypt(C2) XOR P2

•  IV = Decrypt(C1) XOR P1

Page 61: Hollywood style decryption

Encryption Demo

Page 62: Hollywood style decryption

Authenticated Encryption

Page 63: Hollywood style decryption

Authenticate before Decrypt

•  Why we need to authenticate/verify encrypted message before decrypting it ? It’s already encrypted with shared secret key, after all.

•  Imagine that only Alice and Bob know the key. If Bob could decrypt a cipher text with the secret key and get a clean and understandable plain text, then Bob know it only could be encrypted by Alice

•  Many people have thought that, but they were wrong

•  Without message authentication, active attacker could use padding oracle attack to decrypt and also encrypt without knowing the key

Page 64: Hollywood style decryption

Encryption and MAC

•  Encryption provides confidentiality, it doesn’t provide integrity and authenticity

•  Don’t use encryption without message authentication

•  Encrypt your message then calculate MAC

•  Never decrypt message without checking MAC

•  Decrypt only when ciphertext is MAC-authenticated