Class: Analyzers::PaddingOracle::Analyzer
- Inherits:
-
Object
- Object
- Analyzers::PaddingOracle::Analyzer
- Includes:
- Utils::Reporting::Console
- Defined in:
- lib/crypto-toolbox/analyzers/padding_oracle/analyzer.rb
Defined Under Namespace
Classes: FailedAnalysis
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#analyze(cipher) ⇒ Object
start with the second to last block to manipulate the final block ( cbc xor behaviour ) from there on we move to the left until we have used the first block (iv) to decrypt the second blick ( first plain text block ).
-
#initialize(oracle = CryptoToolbox::Oracles::PaddingOracle::TcpOracle.new) ⇒ Analyzer
constructor
A new instance of Analyzer.
Methods included from Utils::Reporting::Console
#jot, #print_delimiter_line, #print_nice, #print_raw
Constructor Details
#initialize(oracle = CryptoToolbox::Oracles::PaddingOracle::TcpOracle.new) ⇒ Analyzer
Returns a new instance of Analyzer.
10 11 12 13 |
# File 'lib/crypto-toolbox/analyzers/padding_oracle/analyzer.rb', line 10 def initialize(oracle = CryptoToolbox::Oracles::PaddingOracle::TcpOracle.new) @result = [ ] @oracle = oracle end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/crypto-toolbox/analyzers/padding_oracle/analyzer.rb', line 7 def result @result end |
Instance Method Details
#analyze(cipher) ⇒ Object
start with the second to last block to manipulate the final block ( cbc xor behaviour ) from there on we move to the left until we have used the first block (iv) to decrypt the second blick ( first plain text block )
we have to manipulate the block before the one we want to change xxxxxxxxx xxxxxxxxx xxxxxxxxxx changing this byte ^- will change ^- this byte at decryption
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/crypto-toolbox/analyzers/padding_oracle/analyzer.rb', line 22 def analyze(cipher) blocks = CryptBuffer.from_hex(cipher).chunks_of(16) # ranges cant be from high to low (1..(blocks.length() -1)).reverse_each do |block_index| result.unshift analyse_block(blocks,block_index) end plaintext = CryptBuffer(result.flatten) report_result(plaintext) plaintext.strip_padding end |