Class: Analyzers::PaddingOracle::Oracles::HttpOracle

Inherits:
Object
  • Object
show all
Defined in:
lib/crypto-toolbox/analyzers/padding_oracle/oracles/http_oracle.rb

Instance Method Summary collapse

Constructor Details

#initializeHttpOracle

Returns a new instance of HttpOracle.



6
7
8
9
10
11
# File 'lib/crypto-toolbox/analyzers/padding_oracle/oracles/http_oracle.rb', line 6

def initialize
  require 'net/http'
  @domain   = "crypto-class.appspot.com"
  @uri_base = "/po?er="
  @port     = 80
end

Instance Method Details

#connectObject



12
13
14
# File 'lib/crypto-toolbox/analyzers/padding_oracle/oracles/http_oracle.rb', line 12

def connect
  true
end

#disconnectObject



15
16
17
# File 'lib/crypto-toolbox/analyzers/padding_oracle/oracles/http_oracle.rb', line 15

def disconnect
  true
end

#valid_padding?(input, block_amount) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/crypto-toolbox/analyzers/padding_oracle/oracles/http_oracle.rb', line 18

def valid_padding?(input,block_amount)

  uri = @uri_base + input.hex

  Net::HTTP.start(@domain,@port) do |http|
    res   = http.request(Net::HTTP::Get.new(uri))
    code  = res.code.to_i
    sleep 0.001
    
    #   -> howto check this ? (block_index == 3 && pad_index == 9 && code == 200 )
    (code == 404 || code == 200)
  end
end