module CryptoToolchain::Tools
Attributes
message_prefix[R]
target[R]
Public Class Methods
detect_single_character_xor(bytestring, non_printable: true)
click to toggle source
# File lib/crypto_toolchain/tools.rb, line 25 def self.detect_single_character_xor(bytestring, non_printable: true) arr = non_printable ? (0..255).map(&:chr).to_a : CryptoToolchain::PRINTABLE_CHARACTERS arr.sort_by do |chr| (chr.repeat_to(bytestring.length) ^ bytestring).score end.last end
Public Instance Methods
execute()
click to toggle source
# File lib/crypto_toolchain/tools/cbc_iv_equals_key_attack.rb, line 12 def execute initial = ("A" * CryptoToolchain::AES_BLOCK_SIZE * 3) blocks = target.encrypt(initial).in_blocks(CryptoToolchain::AES_BLOCK_SIZE) mal = blocks[0] + (0.chr * 16) + blocks[0] begin target.is_admin?(mal) rescue RuntimeError => e blocks = e.message[(message_prefix.length)..-1].in_blocks(CryptoToolchain::AES_BLOCK_SIZE) blocks[0] ^ blocks[2] end end