Module: Arachni::ElementFilter
Overview
Filter for Page elements used to keep track of what elements have already been seen and separate them from new ones.
Mostly used by the Trainer.
Class Method Summary collapse
Instance Method Summary collapse
- #cookie_in_jar?(cookie) ⇒ Boolean
-
#init_cookies(cookies) ⇒ Object
Initializes @@cookies with the cookies found during the crawl/analysis.
- #init_db_from_page(page) ⇒ Object
-
#init_forms(forms) ⇒ Object
Initializes @@forms with the cookies found during the crawl/analysis.
-
#init_links(links) ⇒ Object
Initializes @@links with the links found during the crawl/analysis.
-
#update_cookies(cookies) ⇒ Object
Updates @@cookies wth new cookies that may have dynamically appeared<br/> after analyzing the HTTP responses during the audit.
-
#update_forms(forms) ⇒ Object
Updates @@forms wth new forms that may have dynamically appeared<br/> after analyzing the HTTP responses during the audit.
-
#update_links(links) ⇒ Object
Updates @@links wth new links that may have dynamically appeared<br/> after analyzing the HTTP responses during the audit.
Methods included from Utilities
#available_port, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #extract_domain, #follow_protocol?, #form_decode, #form_encode, #form_parse_request_body, #forms_from_document, #forms_from_response, #generate_token, #get_path, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_query, #parse_set_cookie, #parse_url_vars, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #redundant_path?, #remove_constants, #seed, #skip_page?, #skip_path?, #skip_resource?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parser, #url_sanitize
Class Method Details
.reset ⇒ Object
34 35 36 37 38 |
# File 'lib/arachni/element_filter.rb', line 34 def self.reset @@forms.clear @@links.clear @@cookies.clear end |
Instance Method Details
#cookie_in_jar?(cookie) ⇒ Boolean
139 140 141 142 |
# File 'lib/arachni/element_filter.rb', line 139 def ( ) @@cookies.each { |c| return true if c.raw['name'] == .raw['name'] } false end |
#init_cookies(cookies) ⇒ Object
Initializes @@cookies with the cookies found during the crawl/analysis
63 64 65 |
# File 'lib/arachni/element_filter.rb', line 63 def ( ) @@cookies = end |
#init_db_from_page(page) ⇒ Object
40 41 42 43 44 |
# File 'lib/arachni/element_filter.rb', line 40 def init_db_from_page( page ) init_links page.links init_forms page.forms page. end |
#init_forms(forms) ⇒ Object
Initializes @@forms with the cookies found during the crawl/analysis
49 50 51 |
# File 'lib/arachni/element_filter.rb', line 49 def init_forms( forms ) forms.each { |form| @@forms << form.id } end |
#init_links(links) ⇒ Object
Initializes @@links with the links found during the crawl/analysis
56 57 58 |
# File 'lib/arachni/element_filter.rb', line 56 def init_links( links ) links.each { |link| @@links << link.id } end |
#update_cookies(cookies) ⇒ Object
Updates @@cookies wth new cookies that may have dynamically appeared<br/> after analyzing the HTTP responses during the audit.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/arachni/element_filter.rb', line 116 def ( ) return [], 0 if .size == 0 = 0 @new_cookies ||= [] .reverse.each do || @@cookies.each_with_index do |, i| if .raw['name'] == .raw['name'] @@cookies[i] = elsif !( ) @new_cookies << += 1 end end end @@cookies.flatten! @@cookies |= @new_cookies [@@cookies, ] end |
#update_forms(forms) ⇒ Object
Updates @@forms wth new forms that may have dynamically appeared<br/> after analyzing the HTTP responses during the audit.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/arachni/element_filter.rb', line 73 def update_forms( forms ) return [], 0 if forms.size == 0 form_cnt = 0 new_forms ||= [] forms.each do |form| next if @@forms.include?( form.id ) @@forms << form.id new_forms << form form_cnt += 1 end [new_forms, form_cnt] end |
#update_links(links) ⇒ Object
Updates @@links wth new links that may have dynamically appeared<br/> after analyzing the HTTP responses during the audit.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/arachni/element_filter.rb', line 95 def update_links( links ) return [], 0 if links.size == 0 link_cnt = 0 new_links ||= [] links.each do |link| next if @@links.include?( link.id ) @@links << link.id new_links << link link_cnt += 1 end [new_links, link_cnt] end |