Sha256: e49ea85b35f7e627b8ce0d50c7c43b9626a1fe48fa5ef375bf8600ded0682ef9

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require 'sinatra'

@@erratic = 0

def handler_response_1
    "Random #{rand( 999 ).to_s} bits #{rand( 999 ).to_s} go #{rand( 999 ).to_s} here #{rand( 999 ).to_s}"
end

def handler_response_2
    "Other #{rand( 999 ).to_s} stuff #{rand( 999 ).to_s} are #{rand( 999 ).to_s} here #{rand( 999 ).to_s}"
end

def handler_response_3
    'This is a custom 404, try to catch it. ;)<br/> Random bit: ' + rand( 999 ).to_s +
        '<br/>You asked for "' + params[:splat].first.to_s + '", which could not be found.'
end

get '/not' do
    'This is not a custom 404, watch out.'
end

get '/static/*' do
    'This is a custom 404, try to catch it. ;)'
end

get '/dynamic/erratic/*' do
    if @@erratic > 3
        return 500
    end

    @@erratic += 1

    'This is a custom 404 which includes the requested resource, try to catch it. ;)' +
        '<br/>You asked for "' + params[:splat].first.to_s + '", which could not be found.'
end

get '/dynamic/*' do
    'This is a custom 404 which includes the requested resource, try to catch it. ;)' +
        '<br/>You asked for "' + params[:splat].first.to_s + '", which could not be found.'
end

get '/random/*' do
    'This is a custom 404, try to catch it. ;)<br/> Random bit: ' + rand( 999 ).to_s
end

get '/combo/*' do
    handler_response_1
end

get '/advanced/sensitive-ext/:filename' do |filename|
    name, ext = filename.split( '.', 2 )

    if filename == 'blah.html'
        'Found, all good!'
    elsif name == 'blah' && ext != 'html'
        handler_response_1
    else
        handler_response_2
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
arachni-1.3.2 spec/support/servers/arachni/http/client/dynamic_404_handler.rb
arachni-1.3.1 spec/support/servers/arachni/http/client/dynamic_404_handler.rb
arachni-1.3 spec/support/servers/arachni/http/client/dynamic_404_handler.rb
arachni-1.2.1 spec/support/servers/arachni/http/client/dynamic_404_handler.rb
arachni-1.2 spec/support/servers/arachni/http/client/dynamic_404_handler.rb