Class: Relevance::Tarantula::BasicAttack

Inherits:
Object
  • Object
show all
Defined in:
lib/relevance/tarantula/basic_attack.rb

Constant Summary collapse

ATTRS =
[:name, :output, :description]

Instance Method Summary collapse

Constructor Details

#initializeBasicAttack

Returns a new instance of BasicAttack.



9
10
11
12
13
# File 'lib/relevance/tarantula/basic_attack.rb', line 9

def initialize
  @name = "Tarantula Basic Fuzzer"
  @output = nil
  @description = "Supplies purely random but simplistically generated form input."
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/relevance/tarantula/basic_attack.rb', line 15

def ==(other)
  Relevance::Tarantula::BasicAttack === other && ATTRS.all? { |attr| send(attr) == other.send(attr)}
end

#big_numberObject



32
33
34
# File 'lib/relevance/tarantula/basic_attack.rb', line 32

def big_number
  10000   # arbitrary
end

#input(input_field) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/relevance/tarantula/basic_attack.rb', line 19

def input(input_field)
  return input_field['value'] if input_field['type'] == 'hidden'

  case input_field['name']
  when /amount/         then random_int
  when /_id$/           then random_whole_number
  when /uploaded_data/  then nil
  when nil              then input_field['value']
  else
    random_int
  end
end

#random_intObject



36
37
38
# File 'lib/relevance/tarantula/basic_attack.rb', line 36

def random_int
  rand(big_number) - (big_number/2)
end

#random_whole_numberObject



40
41
42
# File 'lib/relevance/tarantula/basic_attack.rb', line 40

def random_whole_number
  rand(big_number)
end