42
COPYRIGHT TRUSTWAVE 2011 Presented by: No-Knowledge Crypto Attacks Daniel Crowley

No-Knowledge Crypto Attacks

Embed Size (px)

DESCRIPTION

Attacks against badly implemented cryptography that don't require in-depth knowledge of cryptography.

Citation preview

Page 1: No-Knowledge Crypto Attacks

COPYRIGHT TRUSTWAVE 2011

Presented by:

No-Knowledge Crypto Attacks

Daniel Crowley

Page 2: No-Knowledge Crypto Attacks

Structure› Background› Attack!› Potential Win

Page 3: No-Knowledge Crypto Attacks

IDENTIFYING CIPHERTEXT“Yep, it’s wood”

Page 4: No-Knowledge Crypto Attacks

Properties of ciphertext› Appears random› Generally encoded› Decoded length often multiple of

8/16/32–Block ciphers

Page 5: No-Knowledge Crypto Attacks

Example

› Base64 encoded› Decodes to 80 bytes› Ent shows strong signs of randomness

› Probably ciphertext (okay, it is, I generated it)

Page 6: No-Knowledge Crypto Attacks

REPLAY ATTACKBait and switch

Page 7: No-Knowledge Crypto Attacks

Background› Reuse of cryptovariables› Trust in decrypted data

Page 8: No-Knowledge Crypto Attacks

Attack!› Reuse ciphertext

OR

› Find two places where ciphertext is being accepted

› Swap them around

Page 9: No-Knowledge Crypto Attacks

Potential Win› Ciphertext from “article.php?

id=(ciphertext)”› Placed in “doPasswordReset.php?

userid=(ciphertext)”› Reset password for another user

Page 10: No-Knowledge Crypto Attacks

DECRYPTION ORACLEDecrypt ALL the things!

Page 11: No-Knowledge Crypto Attacks

Background› Application takes encrypted input› Application decrypts input› Application gives you decrypted

output

Page 12: No-Knowledge Crypto Attacks

Identifying Decryption Oracles› Look for encrypted input› Modify input and look for garbled

response

Page 13: No-Knowledge Crypto Attacks

Attack!› Take ciphertext from another

location› Plug into decryption oracle

Page 14: No-Knowledge Crypto Attacks

Potential Win› “Password” cookie with encrypted

value› Plug cookie into decryption oracle› PASSWORDS!

Page 15: No-Knowledge Crypto Attacks

ENCRYPTION ORACLEEncrypt ALL the things!

Page 16: No-Knowledge Crypto Attacks

Background› Application takes plaintext input› Application encrypts input› Application gives you encrypted

output

Page 17: No-Knowledge Crypto Attacks

Identifying Encryption Oracles› Look for ciphertext in responses› Modify input and look for modified

ciphertext› Length is often the giveaway

Page 18: No-Knowledge Crypto Attacks

Attack!› Encrypt strings like ‘ or 1=1#› Plug encrypted string into any

encrypted input› Cross your fingers

Page 19: No-Knowledge Crypto Attacks

Potential Win› resetpass.php?id=(ciphertext)

› resetpass.php?id=( ENC(‘ or 1=1 #) )

› SQLi!

Page 20: No-Knowledge Crypto Attacks

STREAM CIPHER BIT FLIPPING

Flipping easy

Page 21: No-Knowledge Crypto Attacks

Background› Construction is simple› Same key & IV means same keystream› Reusing cryptovariables means

catastrophic failure

Page 22: No-Knowledge Crypto Attacks

0 1 1 0 0 1 0 0

1 0 1 0 1 0 1 0

1 1 0 0 1 1 1 0

Page 23: No-Knowledge Crypto Attacks

0 1 1 0 0 1 0 1

1 0 1 0 1 0 1 0

1 1 0 0 1 1 1 1

Page 24: No-Knowledge Crypto Attacks

Attack!› Flip bits in ciphertext input› Same bits in plaintext are flipped› No modification to other parts of

message

Page 25: No-Knowledge Crypto Attacks

Potential Win› Plaintext

–username=fred&admin=0

› Flip lots of bits until…–username=fred&admin=1

Page 26: No-Knowledge Crypto Attacks

STREAM CIPHER KEYSTREAM RECOVERY

I couldn’t think of anything funny for this one

Page 27: No-Knowledge Crypto Attacks

Attack!› Guess plaintext of an encrypted

message› XOR plaintext and ciphertext to get

suspected keystream› XOR suspected keystream with

unknown ciphertext–Attempt to read message

Page 28: No-Knowledge Crypto Attacks

Definite Win› Ability to encrypt and decrypt anything

– In byte positions where known plaintext resides

Page 29: No-Knowledge Crypto Attacks

ECB BLOCK SHUFFLINGEvery day I’m shufflin’

Page 30: No-Knowledge Crypto Attacks

Background› ECB is a block cipher mode› Each block is encrypted independent of

others› Blocks can be reordered, removed,

duplicated

Page 31: No-Knowledge Crypto Attacks

BLOCK 1

CIPHER

BLOCK 1

BLOCK 2

CIPHER

BLOCK 2

BLOCK 3

CIPHER

BLOCK 3

PLAINTEXT

CIPHERTEXT

Page 32: No-Knowledge Crypto Attacks

Attack!› Shuffle blocks around randomly in

encrypted messages› Cross your fingers!

Page 33: No-Knowledge Crypto Attacks

Plaintext before modification

0 1 2 3 4 5 6 7

L A S T V I S I

T E D = / E N /

H O M E . J S P

& U S E R I D =

1 2 3 4 \x04 \x04 \x04 \x04

lastVisited=/en/home.jsp&userId=1234

Page 34: No-Knowledge Crypto Attacks

Plaintext after modification

0 1 2 3 4 5 6 7

L A S T V I S I

T E D = / E N /

H O M E . J S P

& U S E R I D =

1 & F O O = B A

1 2 3 4 \x04 \x04 \x04 \x04

lastVisited=/en/home.jsp&userId=1&foo=ba1234

Page 35: No-Knowledge Crypto Attacks

CBC BIT FLIPPINGFlipping awesome

Page 36: No-Knowledge Crypto Attacks

Background› CBC is a block cipher mode› When decrypting, each block affects

next block› Flipping bits in ciphertext block n

– Garbles plaintext block n– Flips same bits in plaintext block n+1

Page 37: No-Knowledge Crypto Attacks

BLOCK A

IV

CIPHER

BLOCK A

BLOCK B

CIPHER

BLOCK B

BLOCK C

CIPHER

BLOCK C

PLAINTEXT

CIPHERTEXT

Page 38: No-Knowledge Crypto Attacks

BLOCK A

IV

CIPHER

BLOCK A

BLOCK B

CIPHER

BLOCK B

BLOCK C

CIPHER

BLOCK C

PLAINTEXT

CIPHERTEXT

Page 39: No-Knowledge Crypto Attacks

Attack!› Submit ciphertext multiple times

› Flip a different bit each time› Cross your fingers!

Page 40: No-Knowledge Crypto Attacks

Potential Win› Plaintext is:

– lastVisited=http://example.com/home.jsp&uid=124%01

– (lastVisited=http)(://example.com/h)(ome.jsp&uid=124%01)• Split into 16 byte blocks

› Flip bits in bytes 13-15 in block 2–Block 2 becomes garbage–“124” in block 3 has bits flipped in

plaintext

Page 41: No-Knowledge Crypto Attacks

MISCELLANEOUSBonus round!

Page 42: No-Knowledge Crypto Attacks

Other Fun Attacks› Padding Oracles

– padBuster.pl

› Hash length extension attacks– Hash_extender