Class: Arachni::Support::KeyFiller

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/support/key_filler.rb

Overview

Tries to fill in input parameters with values of proper type based on their name.

Author:

Class Method Summary collapse

Class Method Details

.fill(parameters, default = '1') ⇒ Hash

Tries to fill a hash with values of appropriate type based on the key of the parameter.

Parameters:

  • parameters (Hash)

    Parameters hash.

  • default (String) (defaults to: '1')

    Default value to use if no match was found.

Returns:



49
50
51
52
53
54
55
56
57
58
# File 'lib/arachni/support/key_filler.rb', line 49

def fill( parameters, default = '1' )
    parameters = parameters.dup
    parameters.each do |k, v|
        next if !v.to_s.empty?
        # moronic default value...
        # will figure  out something better in the future...
        parameters[k] = name_to_value( k, default )
    end
    parameters
end

.name_to_value(name, default = nil) ⇒ Object



60
61
62
63
# File 'lib/arachni/support/key_filler.rb', line 60

def name_to_value( name, default = nil )
    regexps.each { |k, v| return v if name =~ k }
    default.to_s
end

.regexpsHash<Regexp, String>

Returns Patterns for parameter names and the values to to fill in.

Returns:

  • (Hash<Regexp, String>)

    Patterns for parameter names and the values to to fill in.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/arachni/support/key_filler.rb', line 27

def regexps
    @regexps ||= {
        /name/i    => 'arachni_name',
        /user/i    => 'arachni_user',
        /usr/i     => 'arachni_user',
        /pass/i    => '5543!%arachni_secret',
        /txt/i     => 'arachni_text',
        /num/i     => '132',
        /amount/i  => '100',
        /mail/i    => '[email protected]',
        /account/i => '12',
        /id/i      => '1'
    }
end