Method: Arachni::Module::Base#initialize

Defined in:
lib/module/base.rb

#initialize(page) ⇒ Base

Initializes the module attributes, HTTP client and Trainer

Parameters:

  • page (Page)

See Also:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/module/base.rb', line 62

def initialize( page )

    @page  = page
    @http  = Arachni::HTTP.instance
    @http.trainer.page = @page.dup

    # update the cookies
    if( !@page.cookiejar.empty? )
        @http.update_cookies( @page.cookiejar )
    end

    #
    # This is slightly tricky...
    #
    # Each loaded module is instantiated for each page,
    # however modules share the elements of each page and access them
    # via the ElementsDB.
    #
    # Since the ElementDB is dynamically updated by the Trainer
    # during the audit, is should only be initialized *once*
    # for each page and not overwritten every single time a module is instantiated.
    #
    @@__last_url ||= ''
    if( @@__last_url != @page.url )
        @http.trainer.page = @page.dup
        @http.trainer.init_forms( @page.forms )
        @http.trainer.init_links( @page.links )
        @http.trainer.init_cookies( @page.cookies )
        @@__last_url = @page.url
    end
end