Class: CryptoToolbox::Analyzers::CbcMutatingEncryption
- Inherits:
-
Object
- Object
- CryptoToolbox::Analyzers::CbcMutatingEncryption
- Defined in:
- lib/crypto-toolbox/analyzers/cbc_mutating_encryption.rb
Instance Attribute Summary collapse
-
#oracle ⇒ Object
readonly
Returns the value of attribute oracle.
Instance Method Summary collapse
- #assemble_attack_message ⇒ Object
-
#initialize(oracle) ⇒ CbcMutatingEncryption
constructor
A new instance of CbcMutatingEncryption.
Constructor Details
#initialize(oracle) ⇒ CbcMutatingEncryption
Returns a new instance of CbcMutatingEncryption.
5 6 7 |
# File 'lib/crypto-toolbox/analyzers/cbc_mutating_encryption.rb', line 5 def initialize(oracle) @oracle = oracle end |
Instance Attribute Details
#oracle ⇒ Object (readonly)
Returns the value of attribute oracle.
4 5 6 |
# File 'lib/crypto-toolbox/analyzers/cbc_mutating_encryption.rb', line 4 def oracle @oracle end |
Instance Method Details
#assemble_attack_message ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/crypto-toolbox/analyzers/cbc_mutating_encryption.rb', line 9 def # we are lazy thus we use 0 as a byte which is neutral to xor, # thus we dont have to cancel it before adding admin=true. input = "\0" * 32 blocks = @oracle.(input).chunks_of(16) fake = blocks[2].xor(";admin=true;",expand_input: false ) blocks[2] = fake ciphertext = blocks.map(&:str).join end |