Class: Relevance::Tarantula::AttackHandler

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/relevance/tarantula/attack_handler.rb

Instance Method Summary collapse

Instance Method Details

#attacksObject



6
7
8
# File 'lib/relevance/tarantula/attack_handler.rb', line 6

def attacks
  Relevance::Tarantula::AttackFormSubmission.attacks.select(&:output)
end

#handle(result) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/relevance/tarantula/attack_handler.rb', line 10

def handle(result)
  return unless attacks.size > 0
  regexp = '(' + attacks.map {|a| Regexp.escape a.output}.join('|') + ')'
  response = result.response
  return unless response.html?
  if n = (response.body =~ /#{regexp}/)
    error_result = result.dup
    error_result.success = false
    error_result.description = "XSS error found, match was: #{h($1)}"
    error_result.data = <<-STR
      ########################################################################
      # Text around unescaped string: #{$1}
      ########################################################################
      #{response.body[[0, n - 200].max , 400]}
      
      
      
      
      
      ########################################################################
      # Attack information:
      ########################################################################
      #{attacks.select {|a| a.output == $1}[0].to_yaml}
    STR
    error_result
  end
end