Class: Arachni::Data::Framework
- Defined in:
- lib/arachni/data/framework.rb,
lib/arachni/data/framework/rpc.rb
Overview
Data for Framework.
Defined Under Namespace
Instance Attribute Summary collapse
- #page_queue ⇒ Support::Database::Queue readonly
- #page_queue_total_size ⇒ Integer
- #rpc ⇒ RPC
-
#sitemap ⇒ Hash<String, Integer>
readonly
List of crawled URLs with their HTTP codes.
- #url_queue ⇒ Support::Database::Queue readonly
- #url_queue_total_size ⇒ Integer
Class Method Summary collapse
Instance Method Summary collapse
- #add_page_to_sitemap(page) ⇒ Object
- #clear ⇒ Object
- #dump(directory) ⇒ Object
-
#initialize ⇒ Framework
constructor
A new instance of Framework.
- #push_to_page_queue(page) ⇒ Object
- #push_to_url_queue(url) ⇒ Object
- #statistics ⇒ Object
Constructor Details
#initialize ⇒ Framework
Returns a new instance of Framework.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/arachni/data/framework.rb', line 46 def initialize @rpc = RPC.new @sitemap = {} @page_queue = Support::Database::Queue.new @page_queue_total_size = 0 @url_queue = Support::Database::Queue.new @url_queue.max_buffer_size = Float::INFINITY @url_queue_total_size = 0 end |
Instance Attribute Details
#page_queue ⇒ Support::Database::Queue (readonly)
35 36 37 |
# File 'lib/arachni/data/framework.rb', line 35 def page_queue @page_queue end |
#page_queue_total_size ⇒ Integer
38 39 40 |
# File 'lib/arachni/data/framework.rb', line 38 def page_queue_total_size @page_queue_total_size end |
#sitemap ⇒ Hash<String, Integer> (readonly)
Returns List of crawled URLs with their HTTP codes.
32 33 34 |
# File 'lib/arachni/data/framework.rb', line 32 def sitemap @sitemap end |
#url_queue ⇒ Support::Database::Queue (readonly)
41 42 43 |
# File 'lib/arachni/data/framework.rb', line 41 def url_queue @url_queue end |
#url_queue_total_size ⇒ Integer
44 45 46 |
# File 'lib/arachni/data/framework.rb', line 44 def url_queue_total_size @url_queue_total_size end |
Class Method Details
.load(directory) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/arachni/data/framework.rb', line 123 def self.load( directory ) framework = new framework.rpc = RPC.load( "#{directory}/rpc/" ) framework.sitemap.merge! Marshal.load( IO.binread( "#{directory}/sitemap" ) ) Dir["#{directory}/page_queue/*"].each do |page_file| framework.page_queue.disk << page_file end Marshal.load( IO.binread( "#{directory}/url_queue" ) ).each do |url| framework.url_queue.buffer << url end framework.page_queue_total_size = Marshal.load( IO.binread( "#{directory}/page_queue_total_size" ) ) framework.url_queue_total_size = Marshal.load( IO.binread( "#{directory}/url_queue_total_size" ) ) framework end |
Instance Method Details
#add_page_to_sitemap(page) ⇒ Object
91 92 93 |
# File 'lib/arachni/data/framework.rb', line 91 def add_page_to_sitemap( page ) sitemap[page.dom.url] = page.code end |
#clear ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/arachni/data/framework.rb', line 145 def clear rpc.clear @sitemap.clear @page_queue.clear @page_queue_total_size = 0 @url_queue.clear @url_queue_total_size = 0 end |
#dump(directory) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/arachni/data/framework.rb', line 95 def dump( directory ) FileUtils.mkdir_p( directory ) rpc.dump( "#{directory}/rpc/" ) page_queue_directory = "#{directory}/page_queue/" FileUtils.rm_rf( page_queue_directory ) FileUtils.mkdir_p( page_queue_directory ) page_queue.buffer.each do |page| IO.binwrite( "#{page_queue_directory}/#{page.persistent_hash}", Marshal.dump( page ) ) end page_queue.disk.each do |filepath| FileUtils.cp filepath, "#{page_queue_directory}/" end IO.binwrite( "#{directory}/url_queue", Marshal.dump( @url_queue.buffer ) ) %w(sitemap page_queue_total_size url_queue_total_size).each do |attribute| IO.binwrite( "#{directory}/#{attribute}", Marshal.dump( send(attribute) ) ) end end |
#push_to_page_queue(page) ⇒ Object
Note:
Increases the #page_queue_total_size.
74 75 76 77 78 |
# File 'lib/arachni/data/framework.rb', line 74 def push_to_page_queue( page ) @page_queue << page.clear_cache add_page_to_sitemap( page ) @page_queue_total_size += 1 end |
#push_to_url_queue(url) ⇒ Object
Note:
Increases the #url_queue_total_size.
84 85 86 87 |
# File 'lib/arachni/data/framework.rb', line 84 def push_to_url_queue( url ) @url_queue << url @url_queue_total_size += 1 end |
#statistics ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/arachni/data/framework.rb', line 59 def statistics { rpc: @rpc.statistics, sitemap: @sitemap.size, page_queue: @page_queue.size, page_queue_total_size: @page_queue_total_size, url_queue: @url_queue.size, url_queue_total_size: @url_queue_total_size } end |