Class: CryptoToolchain::BlackBoxes::NetcatCbcPaddingOracle
- Defined in:
- lib/crypto_toolchain/black_boxes/netcat_cbc_padding_oracle.rb
Instance Attribute Summary collapse
-
#ciphertext ⇒ Object
readonly
Returns the value of attribute ciphertext.
Instance Method Summary collapse
- #execute(str) ⇒ Object
-
#initialize(key: Random.new.bytes(16), iv: Random.new.bytes(16)) ⇒ NetcatCbcPaddingOracle
constructor
A new instance of NetcatCbcPaddingOracle.
Constructor Details
#initialize(key: Random.new.bytes(16), iv: Random.new.bytes(16)) ⇒ NetcatCbcPaddingOracle
Returns a new instance of NetcatCbcPaddingOracle.
7 8 9 10 11 |
# File 'lib/crypto_toolchain/black_boxes/netcat_cbc_padding_oracle.rb', line 7 def initialize(key: Random.new.bytes(16), iv: Random.new.bytes(16)) @key = key @iv = iv @ciphertext = Base64.strict_decode64('SNXIDUFQW0Ul6GXI4NyU/LMHl+vRlVIYp4pvFstfpP1n1C9Xhbl/bNip6mK5l7TMPS+vw247XTYK3LKIGT4AZVh6zUB97fN3fOamkLvzpmA=') end |
Instance Attribute Details
#ciphertext ⇒ Object (readonly)
Returns the value of attribute ciphertext.
5 6 7 |
# File 'lib/crypto_toolchain/black_boxes/netcat_cbc_padding_oracle.rb', line 5 def ciphertext @ciphertext end |
Instance Method Details
#execute(str) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/crypto_toolchain/black_boxes/netcat_cbc_padding_oracle.rb', line 13 def execute(str) handle = IO.popen(["nc", "bufferoverflow.disappointedmama.com", '6767'], "r+") handle.puts(Base64.strict_encode64(str)) resp = handle.readpartial(1024).strip handle.close case resp when "Failed to decrypt the message" false when "Successfully received and decrypted the message" true else raise StandardError.new, "Unknown response `#{res}`" end end |