Class: Arachni::Platform::Manager
- Extended by:
- UI::Output, Utilities
- Includes:
- UI::Output, Utilities, Enumerable
- Defined in:
- lib/arachni/platform/manager.rb
Overview
Represents a collection of platform lists.
It also holds a DB of all fingerprints per URI as a class variable and provides helper method for accessing and manipulating it.
Constant Summary collapse
- TYPES =
{ os: 'Operating systems', db: 'Databases', servers: 'Web servers', languages: 'Programming languages', frameworks: 'Frameworks' }
- OS =
{ # Generic *nix, flavor couldn't be identified. unix: { linux: {}, # Generic BSD, flavor couldn't be identified. bsd: {}, solaris: {} }, windows: {} }
- DB =
[ :mysql, :pgsql, :mssql, :oracle, :sqlite, :emc, :db2, :coldfusion, :interbase, :informix, :firebird, :maxdb, :sybase, :frontbase, :ingres, :hsqldb, :access ]
- SERVERS =
[ :apache, :nginx, :tomcat, :iis, :jetty ]
- LANGUAGES =
[ :php, :jsp, :python, :ruby, :asp, :aspx, :perl ]
- FRAMEWORKS =
WebApp frameworks.
[ :rack ]
- PLATFORM_NAMES =
{ # Operating systems unix: 'Generic Unix family', linux: 'Linux', bsd: 'Generic BSD family', solaris: 'Solaris', windows: 'MS Windows', # Databases mysql: 'MySQL', pgsql: 'Postgresql', mssql: 'MSSQL', oracle: 'Oracle', sqlite: 'SQLite', emc: 'EMC', db2: 'DB2', coldfusion: 'ColdFusion', interbase: 'InterBase', informix: 'Informix', firebird: 'Firebird', maxdb: 'SaP Max DB', sybase: 'Sybase', frontbase: 'Frontbase', ingres: 'IngresDB', hsqldb: 'HSQLDB', access: 'MS Access', # Web servers apache: 'Apache', nginx: 'Nginx', tomcat: 'TomCat', iis: 'IIS', jetty: 'Jetty', # Programming languages php: 'PHP', jsp: 'JSP', python: 'Python', ruby: 'Ruby', asp: 'ASP', aspx: 'ASP.NET', perl: 'Perl', # Web frameworks rack: 'Rack' }
Class Method Summary collapse
-
.[](uri) ⇒ Manager
Platform for the given ‘uri`.
-
.[]=(uri, platforms) ⇒ Manager
Sets platform manager for the given ‘uri`.
-
.all ⇒ Hash<Integer, Platform>
Platform per hashed URL.
-
.any? ⇒ Boolean
‘true` if there are platforms fingerprints, `false` otherwise.
-
.clear ⇒ Object
Clears global platforms DB.
-
.empty? ⇒ Boolean
‘true` if there are no platforms fingerprints, `false` otherwise.
- .find_type(platform) ⇒ Object
-
.fingerprint(page) ⇒ Manager
Runs all fingerprinters against the given ‘page`.
- .fingerprinters ⇒ Object
-
.light ⇒ Hash{Integer=>Array<Symbol>}
Light representation of the fingerprint DB with URL hashes as keys and arrays of symbols for platforms as values.
-
.reset ⇒ Object
Empties the global platform fingerprints.
-
.set(platforms) ⇒ Object
Sets global platforms fingerprints.
-
.update(uri, platforms) ⇒ Manager
Updates the ‘platforms` for the given `uri`.
- .update_light(light_platforms) ⇒ Manager
- .valid ⇒ Object
Instance Method Summary collapse
-
#<<(platform) ⇒ Manager
‘self`.
-
#any? ⇒ Boolean
‘true` if there are applicable platforms, `false` otherwise.
-
#db ⇒ List
Platform list for databases.
-
#each(&block) ⇒ Enumerator, Manager
‘Enumerator` if no `block` is given, `self` otherwise.
-
#empty? ⇒ Boolean
‘true` if there are no applicable platforms, `false` otherwise.
-
#find_list(platform) ⇒ List
Platform list.
-
#find_type(platform) ⇒ Symbol
Platform type.
-
#frameworks ⇒ List
Platform list for frameworks.
-
#fullname(platform) ⇒ String
Converts a platform shortname to a full name.
-
#include?(platform) ⇒ Boolean
‘true` if one of the lists contains the `platform`, `false` otherwise.
-
#initialize(platforms = []) ⇒ Manager
constructor
A new instance of Manager.
-
#invalid?(platform) ⇒ Boolean
‘true` if platform is invalid (i.e. not in #valid), `false` otherwise.
-
#languages ⇒ List
Platform list for languages.
-
#os ⇒ List
Platform list for operating systems.
-
#pick(data_per_platform) ⇒ Hash
Selects appropriate data, depending on the applicable platforms, from ‘data_per_platform`.
-
#servers ⇒ List
Platform list for web servers.
-
#update(enum) ⇒ Manager
Updated ‘self`.
-
#valid ⇒ Set<Symbol>
List of valid platforms.
-
#valid?(platform) ⇒ Boolean
‘true` if platform is valid (i.e. in #valid), `false` otherwise.
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
Methods included from UI::Output
debug?, debug_off, debug_on, disable_only_positives, error_logfile, flush_buffer, log_error, mute, muted?, old_reset_output_options, only_positives, only_positives?, print_bad, print_debug, print_debug_backtrace, print_debug_pp, print_error, print_error_backtrace, print_info, print_line, print_ok, print_status, print_verbose, reroute_to_file, reroute_to_file?, reset_output_options, set_buffer_cap, set_error_logfile, uncap_buffer, unmute, verbose, verbose?
Methods included from Enumerable
Constructor Details
#initialize(platforms = []) ⇒ Manager
Returns a new instance of Manager.
297 298 299 300 301 302 303 304 305 |
# File 'lib/arachni/platform/manager.rb', line 297 def initialize( platforms = [] ) @platforms = {} TYPES.keys.each do |type| @platforms[type] = List.new( self.class.const_get( type.to_s.upcase.to_sym ) ) end update [platforms | Options.platforms].flatten.compact end |
Class Method Details
.[](uri) ⇒ Manager
Returns Platform for the given ‘uri`.
255 256 257 258 |
# File 'lib/arachni/platform/manager.rb', line 255 def self.[]( uri ) return new if !(key = make_key( uri )) @platforms[key] ||= new end |
.[]=(uri, platforms) ⇒ Manager
Sets platform manager for the given ‘uri`.
235 236 237 238 239 |
# File 'lib/arachni/platform/manager.rb', line 235 def self.[]=( uri, platforms ) return new( platforms ) if !(key = make_key( uri )) @platforms[key] = platforms.is_a?( self ) ? platforms : new( platforms ) end |
.all ⇒ Hash<Integer, Platform>
Returns Platform per hashed URL.
274 275 276 |
# File 'lib/arachni/platform/manager.rb', line 274 def self.all @platforms end |
.any? ⇒ Boolean
Returns ‘true` if there are platforms fingerprints, `false` otherwise.
268 269 270 |
# File 'lib/arachni/platform/manager.rb', line 268 def self.any? !empty? end |
.clear ⇒ Object
Clears global platforms DB.
194 195 196 |
# File 'lib/arachni/platform/manager.rb', line 194 def self.clear @platforms.clear end |
.empty? ⇒ Boolean
Returns ‘true` if there are no platforms fingerprints, `false` otherwise.
262 263 264 |
# File 'lib/arachni/platform/manager.rb', line 262 def self.empty? @platforms.empty? end |
.find_type(platform) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/arachni/platform/manager.rb', line 165 def self.find_type( platform ) @find_type ||= {} if @find_type.empty? TYPES.keys.each do |type| platforms = const_get( type.to_s.upcase.to_sym ) platforms = platforms.find_symbol_keys_recursively if platforms.is_a?( Hash ) platforms.each do |p| @find_type[p] = type end end end @find_type[platform] end |
.fingerprint(page) ⇒ Manager
Runs all fingerprinters against the given ‘page`.
218 219 220 221 222 223 224 225 |
# File 'lib/arachni/platform/manager.rb', line 218 def self.fingerprint( page ) fingerprinters.available.each do |name| exception_jail( false ) do fingerprinters[name].new( page ).run end end page end |
.fingerprinters ⇒ Object
207 208 209 210 211 |
# File 'lib/arachni/platform/manager.rb', line 207 def self.fingerprinters @manager ||= Component::Manager.new( Options.dir['fingerprinters'], Platform::Fingerprinters ) end |
.light ⇒ Hash{Integer=>Array<Symbol>}
Returns Light representation of the fingerprint DB with URL hashes as keys and arrays of symbols for platforms as values.
281 282 283 |
# File 'lib/arachni/platform/manager.rb', line 281 def self.light all.inject({}) { |h, (k, v)| h[k] = v.to_a; h } end |
.reset ⇒ Object
Empties the global platform fingerprints.
199 200 201 202 203 204 |
# File 'lib/arachni/platform/manager.rb', line 199 def self.reset set Hash.new @manager.clear if @manager @manager = nil self end |
.set(platforms) ⇒ Object
Sets global platforms fingerprints
189 190 191 |
# File 'lib/arachni/platform/manager.rb', line 189 def self.set( platforms ) @platforms = platforms end |
.update(uri, platforms) ⇒ Manager
Updates the ‘platforms` for the given `uri`.
249 250 251 |
# File 'lib/arachni/platform/manager.rb', line 249 def self.update( uri, platforms ) self[uri].update platforms end |
.update_light(light_platforms) ⇒ Manager
288 289 290 291 292 293 |
# File 'lib/arachni/platform/manager.rb', line 288 def self.update_light( light_platforms ) light_platforms.each do |url, platforms| @platforms[url] ||= new( platforms ) end self end |
.valid ⇒ Object
183 184 185 |
# File 'lib/arachni/platform/manager.rb', line 183 def self.valid @valid ||= Set.new( PLATFORM_NAMES.keys ) end |
Instance Method Details
#<<(platform) ⇒ Manager
Returns ‘self`.
439 440 441 442 |
# File 'lib/arachni/platform/manager.rb', line 439 def <<( platform ) find_list( platform ) << platform self end |
#any? ⇒ Boolean
Returns ‘true` if there are applicable platforms, `false` otherwise.
423 424 425 |
# File 'lib/arachni/platform/manager.rb', line 423 def any? !empty? end |
#each(&block) ⇒ Enumerator, Manager
Returns ‘Enumerator` if no `block` is given, `self` otherwise.
401 402 403 404 405 |
# File 'lib/arachni/platform/manager.rb', line 401 def each( &block ) return enum_for( __method__ ) if !block_given? @platforms.map { |_, p| p.to_a }.flatten.each( &block ) self end |
#empty? ⇒ Boolean
Returns ‘true` if there are no applicable platforms, `false` otherwise.
417 418 419 |
# File 'lib/arachni/platform/manager.rb', line 417 def empty? !@platforms.map { |_, p| p.empty? }.include?( false ) end |
#find_list(platform) ⇒ List
Returns Platform list.
453 454 455 |
# File 'lib/arachni/platform/manager.rb', line 453 def find_list( platform ) @platforms[find_type( normalize( platform ) )] end |
#find_type(platform) ⇒ Symbol
Returns Platform type.
447 448 449 |
# File 'lib/arachni/platform/manager.rb', line 447 def find_type( platform ) self.class.find_type( platform ) end |
#frameworks ⇒ List
Returns Platform list for frameworks.
327 328 329 330 331 |
# File 'lib/arachni/platform/manager.rb', line 327 [:os, :db, :servers, :languages, :frameworks].each do |type| define_method type do @platforms[type] end end |
#fullname(platform) ⇒ String
Converts a platform shortname to a full name.
340 341 342 |
# File 'lib/arachni/platform/manager.rb', line 340 def fullname( platform ) PLATFORM_NAMES[normalize( platform )] end |
#include?(platform) ⇒ Boolean
Returns ‘true` if one of the lists contains the `platform`, `false` otherwise.
411 412 413 |
# File 'lib/arachni/platform/manager.rb', line 411 def include?( platform ) find_list( platform ).include?( platform ) end |
#invalid?(platform) ⇒ Boolean
Returns ‘true` if platform is invalid (i.e. not in #valid), `false` otherwise.
394 395 396 |
# File 'lib/arachni/platform/manager.rb', line 394 def invalid?( platform ) !valid?( platform ) end |
#languages ⇒ List
Returns Platform list for languages.
|
# File 'lib/arachni/platform/manager.rb', line 319
|
#os ⇒ List
Returns Platform list for operating systems.
|
# File 'lib/arachni/platform/manager.rb', line 307
|
#pick(data_per_platform) ⇒ Hash
Selects appropriate data, depending on the applicable platforms, from ‘data_per_platform`.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/arachni/platform/manager.rb', line 354 def pick( data_per_platform ) data_per_list = {} data_per_platform.each do |platform, value| list = find_list( platform ) data_per_list[list] ||= {} data_per_list[list][platform] = value end picked = {} data_per_list.each do |list, data| # If a platform list is empty pass the given data without picking... if list.empty? picked.merge! data next end # ...otherwise enforce its platform restrictions. picked.merge! list.pick( data ) end picked end |
#servers ⇒ List
Returns Platform list for web servers.
|
# File 'lib/arachni/platform/manager.rb', line 315
|
#update(enum) ⇒ Manager
Returns Updated ‘self`.
430 431 432 433 |
# File 'lib/arachni/platform/manager.rb', line 430 def update( enum ) enum.each { |p| self << p } self end |
#valid ⇒ Set<Symbol>
Returns List of valid platforms.
378 379 380 |
# File 'lib/arachni/platform/manager.rb', line 378 def valid self.class.valid end |
#valid?(platform) ⇒ Boolean
Returns ‘true` if platform is valid (i.e. in #valid), `false` otherwise.
386 387 388 |
# File 'lib/arachni/platform/manager.rb', line 386 def valid?( platform ) valid.include? platform end |