Class: Arachni::Checks::XssScriptContext::SAX

Inherits:
Object
  • Object
show all
Defined in:
components/checks/active/xss_script_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seed) ⇒ SAX

Returns a new instance of SAX.


48
49
50
51
# File 'components/checks/active/xss_script_context.rb', line 48

def initialize( seed )
    @seed       = seed
    @attributes = Set.new( ATTRIBUTES )
end

Instance Attribute Details

#taintedObject (readonly)

Returns the value of attribute tainted


46
47
48
# File 'components/checks/active/xss_script_context.rb', line 46

def tainted
  @tainted
end

Instance Method Details

#attr(name, value) ⇒ Object


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'components/checks/active/xss_script_context.rb', line 68

def attr( name, value )
    name  = name.to_s.downcase
    value = value.downcase

    return if !@attributes.include?( name )

    if name == 'src'
        if @seed.start_with?( 'javascript:' ) && value == @seed
            @tainted = true
            fail Arachni::Parser::SAX::Stop
        end
    else
        if value == @seed
            @tainted = true
            fail Arachni::Parser::SAX::Stop
        end
    end

    if value.include?( @seed )
        @tainted = true
        fail Arachni::Parser::SAX::Stop
    end
end

#documentObject


53
54
# File 'components/checks/active/xss_script_context.rb', line 53

def document
end

#end_element(name) ⇒ Object


64
65
66
# File 'components/checks/active/xss_script_context.rb', line 64

def end_element( name )
    @in_script = false
end

#start_element(name) ⇒ Object


60
61
62
# File 'components/checks/active/xss_script_context.rb', line 60

def start_element( name )
    @in_script = (name.to_s.downcase == 'script')
end

#tainted?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'components/checks/active/xss_script_context.rb', line 56

def tainted?
    !!@tainted
end

#text(value) ⇒ Object


92
93
94
95
96
97
# File 'components/checks/active/xss_script_context.rb', line 92

def text( value )
    return if !@in_script || value !~ /#{Regexp.escape( @seed )}/i

    @tainted = true
    fail Arachni::Parser::SAX::Stop
end