wg-metasploit_data_models 4.1.4.01 → 4.1.4.02
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.github/workflows/verify.yml +68 -0
- data/.gitignore +29 -0
- data/.rspec +3 -0
- data/.simplecov +38 -0
- data/.yardopts +4 -0
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +133 -0
- data/Gemfile +46 -0
- data/LICENSE +27 -0
- data/README.md +65 -0
- data/RELEASING.md +82 -0
- data/Rakefile +72 -0
- data/UPGRADING.md +1 -0
- data/app/models/mdm/api_key.rb +61 -0
- data/app/models/mdm/async_callback.rb +64 -0
- data/app/models/mdm/client.rb +50 -0
- data/app/models/mdm/cred.rb +205 -0
- data/app/models/mdm/event.rb +83 -0
- data/app/models/mdm/exploit_attempt.rb +105 -0
- data/app/models/mdm/exploited_host.rb +42 -0
- data/app/models/mdm/host.rb +619 -0
- data/app/models/mdm/host_detail.rb +62 -0
- data/app/models/mdm/host_tag.rb +49 -0
- data/app/models/mdm/listener.rb +82 -0
- data/app/models/mdm/loot.rb +161 -0
- data/app/models/mdm/macro.rb +62 -0
- data/app/models/mdm/mod_ref.rb +24 -0
- data/app/models/mdm/module/action.rb +33 -0
- data/app/models/mdm/module/arch.rb +28 -0
- data/app/models/mdm/module/author.rb +34 -0
- data/app/models/mdm/module/detail.rb +388 -0
- data/app/models/mdm/module/mixin.rb +31 -0
- data/app/models/mdm/module/platform.rb +29 -0
- data/app/models/mdm/module/ref.rb +42 -0
- data/app/models/mdm/module/target.rb +37 -0
- data/app/models/mdm/nexpose_console.rb +121 -0
- data/app/models/mdm/note.rb +125 -0
- data/app/models/mdm/payload.rb +103 -0
- data/app/models/mdm/profile.rb +45 -0
- data/app/models/mdm/ref.rb +48 -0
- data/app/models/mdm/route.rb +28 -0
- data/app/models/mdm/service.rb +267 -0
- data/app/models/mdm/session.rb +203 -0
- data/app/models/mdm/session_event.rb +44 -0
- data/app/models/mdm/tag.rb +114 -0
- data/app/models/mdm/task.rb +168 -0
- data/app/models/mdm/task_cred.rb +45 -0
- data/app/models/mdm/task_host.rb +41 -0
- data/app/models/mdm/task_service.rb +41 -0
- data/app/models/mdm/task_session.rb +41 -0
- data/app/models/mdm/user.rb +230 -0
- data/app/models/mdm/vuln.rb +204 -0
- data/app/models/mdm/vuln_attempt.rb +76 -0
- data/app/models/mdm/vuln_detail.rb +156 -0
- data/app/models/mdm/vuln_ref.rb +21 -0
- data/app/models/mdm/web_form.rb +53 -0
- data/app/models/mdm/web_page.rb +92 -0
- data/app/models/mdm/web_site.rb +113 -0
- data/app/models/mdm/web_vuln.rb +193 -0
- data/app/models/mdm/wmap_request.rb +101 -0
- data/app/models/mdm/wmap_target.rb +56 -0
- data/app/models/mdm/workspace.rb +286 -0
- data/app/models/metasploit_data_models/automatic_exploitation/match.rb +43 -0
- data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +71 -0
- data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +40 -0
- data/app/models/metasploit_data_models/automatic_exploitation/run.rb +29 -0
- data/app/models/metasploit_data_models/ip_address/v4/cidr.rb +14 -0
- data/app/models/metasploit_data_models/ip_address/v4/nmap.rb +14 -0
- data/app/models/metasploit_data_models/ip_address/v4/range.rb +12 -0
- data/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list.rb +125 -0
- data/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range.rb +12 -0
- data/app/models/metasploit_data_models/ip_address/v4/segment/single.rb +123 -0
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +200 -0
- data/app/models/metasploit_data_models/ip_address/v4/single.rb +53 -0
- data/app/models/metasploit_data_models/module_run.rb +213 -0
- data/app/models/metasploit_data_models/search/operation/ip_address.rb +60 -0
- data/app/models/metasploit_data_models/search/operation/port/number.rb +25 -0
- data/app/models/metasploit_data_models/search/operation/port/range.rb +79 -0
- data/app/models/metasploit_data_models/search/operation/range.rb +56 -0
- data/app/models/metasploit_data_models/search/operator/ip_address.rb +33 -0
- data/app/models/metasploit_data_models/search/operator/multitext.rb +73 -0
- data/app/models/metasploit_data_models/search/operator/port/list.rb +67 -0
- data/app/models/metasploit_data_models/search/visitor/attribute.rb +17 -0
- data/app/models/metasploit_data_models/search/visitor/includes.rb +47 -0
- data/app/models/metasploit_data_models/search/visitor/joins.rb +67 -0
- data/app/models/metasploit_data_models/search/visitor/method.rb +16 -0
- data/app/models/metasploit_data_models/search/visitor/relation.rb +91 -0
- data/app/models/metasploit_data_models/search/visitor/where.rb +128 -0
- data/config/initializers/arel_helper.rb +5 -0
- data/config/initializers/ipaddr.rb +29 -0
- data/config/locales/en.yml +94 -0
- data/console_db.yml +9 -0
- data/db/migrate/000_create_tables.rb +79 -0
- data/db/migrate/001_add_wmap_tables.rb +35 -0
- data/db/migrate/002_add_workspaces.rb +36 -0
- data/db/migrate/003_move_notes.rb +20 -0
- data/db/migrate/004_add_events_table.rb +16 -0
- data/db/migrate/005_expand_info.rb +58 -0
- data/db/migrate/006_add_timestamps.rb +26 -0
- data/db/migrate/007_add_loots.rb +20 -0
- data/db/migrate/008_create_users.rb +16 -0
- data/db/migrate/009_add_loots_ctype.rb +10 -0
- data/db/migrate/010_add_alert_fields.rb +16 -0
- data/db/migrate/011_add_reports.rb +19 -0
- data/db/migrate/012_add_tasks.rb +24 -0
- data/db/migrate/013_add_tasks_result.rb +10 -0
- data/db/migrate/014_add_loots_fields.rb +12 -0
- data/db/migrate/015_rename_user.rb +16 -0
- data/db/migrate/016_add_host_purpose.rb +10 -0
- data/db/migrate/017_expand_info2.rb +58 -0
- data/db/migrate/018_add_workspace_user_info.rb +29 -0
- data/db/migrate/019_add_workspace_desc.rb +23 -0
- data/db/migrate/020_add_user_preferences.rb +11 -0
- data/db/migrate/021_standardize_info_and_data.rb +18 -0
- data/db/migrate/022_enlarge_event_info.rb +10 -0
- data/db/migrate/023_add_report_downloaded_at.rb +10 -0
- data/db/migrate/024_convert_service_info_to_text.rb +12 -0
- data/db/migrate/025_add_user_admin.rb +19 -0
- data/db/migrate/026_add_creds_table.rb +19 -0
- data/db/migrate/20100819123300_migrate_cred_data.rb +154 -0
- data/db/migrate/20100824151500_add_exploited_table.rb +16 -0
- data/db/migrate/20100908001428_add_owner_to_workspaces.rb +9 -0
- data/db/migrate/20100911122000_add_report_templates.rb +18 -0
- data/db/migrate/20100916151530_require_admin_flag.rb +15 -0
- data/db/migrate/20100916175000_add_campaigns_and_templates.rb +61 -0
- data/db/migrate/20100920012100_add_generate_exe_column.rb +8 -0
- data/db/migrate/20100926214000_add_template_prefs.rb +11 -0
- data/db/migrate/20101001000000_add_web_tables.rb +57 -0
- data/db/migrate/20101002000000_add_query.rb +10 -0
- data/db/migrate/20101007000000_add_vuln_info.rb +15 -0
- data/db/migrate/20101008111800_add_clients_to_campaigns.rb +10 -0
- data/db/migrate/20101009023300_add_campaign_attachments.rb +15 -0
- data/db/migrate/20101104135100_add_imported_creds.rb +17 -0
- data/db/migrate/20101203000000_fix_web_tables.rb +34 -0
- data/db/migrate/20101203000001_expand_host_comment.rb +12 -0
- data/db/migrate/20101206212033_add_limit_to_network_to_workspaces.rb +9 -0
- data/db/migrate/20110112154300_add_module_uuid_to_tasks.rb +9 -0
- data/db/migrate/20110204112800_add_host_tags.rb +28 -0
- data/db/migrate/20110317144932_add_session_table.rb +110 -0
- data/db/migrate/20110414180600_add_local_id_to_session_table.rb +11 -0
- data/db/migrate/20110415175705_add_routes_table.rb +18 -0
- data/db/migrate/20110422000000_convert_binary.rb +73 -0
- data/db/migrate/20110425095900_add_last_seen_to_sessions.rb +8 -0
- data/db/migrate/20110513143900_track_successful_exploits.rb +31 -0
- data/db/migrate/20110517160800_rename_and_prune_nessus_vulns.rb +26 -0
- data/db/migrate/20110527000000_add_task_id_to_reports_table.rb +11 -0
- data/db/migrate/20110527000001_add_api_keys_table.rb +12 -0
- data/db/migrate/20110606000001_add_macros_table.rb +16 -0
- data/db/migrate/20110622000000_add_settings_to_tasks_table.rb +12 -0
- data/db/migrate/20110624000001_add_listeners_table.rb +19 -0
- data/db/migrate/20110625000001_add_macro_to_listeners_table.rb +12 -0
- data/db/migrate/20110630000001_add_nexpose_consoles_table.rb +21 -0
- data/db/migrate/20110630000002_add_name_to_nexpose_consoles_table.rb +12 -0
- data/db/migrate/20110717000001_add_profiles_table.rb +15 -0
- data/db/migrate/20110727163801_expand_cred_ptype_column.rb +9 -0
- data/db/migrate/20110730000001_add_initial_indexes.rb +85 -0
- data/db/migrate/20110812000001_prune_indexes.rb +23 -0
- data/db/migrate/20110922000000_expand_notes.rb +9 -0
- data/db/migrate/20110928101300_add_mod_ref_table.rb +17 -0
- data/db/migrate/20111011110000_add_display_name_to_reports_table.rb +24 -0
- data/db/migrate/20111203000000_inet_columns.rb +13 -0
- data/db/migrate/20111204000000_more_inet_columns.rb +17 -0
- data/db/migrate/20111210000000_add_scope_to_hosts.rb +9 -0
- data/db/migrate/20120126110000_add_virtual_host_to_hosts.rb +9 -0
- data/db/migrate/20120411173220_rename_workspace_members.rb +9 -0
- data/db/migrate/20120601152442_add_counter_caches_to_hosts.rb +21 -0
- data/db/migrate/20120625000000_add_vuln_details.rb +34 -0
- data/db/migrate/20120625000001_add_host_details.rb +16 -0
- data/db/migrate/20120625000002_expand_details.rb +16 -0
- data/db/migrate/20120625000003_expand_details2.rb +24 -0
- data/db/migrate/20120625000004_add_vuln_attempts.rb +19 -0
- data/db/migrate/20120625000005_add_vuln_and_host_counter_caches.rb +14 -0
- data/db/migrate/20120625000006_add_module_details.rb +118 -0
- data/db/migrate/20120625000007_add_exploit_attempts.rb +26 -0
- data/db/migrate/20120625000008_add_fail_message.rb +12 -0
- data/db/migrate/20120718202805_add_owner_and_payload_to_web_vulns.rb +13 -0
- data/db/migrate/20130228214900_change_required_columns_to_null_false_in_web_vulns.rb +19 -0
- data/db/migrate/20130412154159_change_foreign_key_in_module_actions.rb +25 -0
- data/db/migrate/20130412171844_change_foreign_key_in_module_archs.rb +25 -0
- data/db/migrate/20130412173121_change_foreign_key_in_module_authors.rb +25 -0
- data/db/migrate/20130412173640_change_foreign_key_in_module_mixins.rb +25 -0
- data/db/migrate/20130412174254_change_foreign_key_in_module_platforms.rb +25 -0
- data/db/migrate/20130412174719_change_foreign_key_in_module_refs.rb +25 -0
- data/db/migrate/20130412175040_change_foreign_key_in_module_targets.rb +25 -0
- data/db/migrate/20130423211152_add_creds_counter_cache.rb +24 -0
- data/db/migrate/20130430151353_change_required_columns_to_null_false_in_hosts.rb +11 -0
- data/db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb +101 -0
- data/db/migrate/20130510021637_remove_campaigns.rb +11 -0
- data/db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb +48 -0
- data/db/migrate/20130515172727_valid_mdm_web_vuln_params.rb +30 -0
- data/db/migrate/20130516204810_making_vulns_refs_a_real_ar_model.rb +5 -0
- data/db/migrate/20130522001343_create_task_creds.rb +9 -0
- data/db/migrate/20130522032517_create_task_hosts.rb +9 -0
- data/db/migrate/20130522041110_create_task_services.rb +9 -0
- data/db/migrate/20130525015035_remove_campaign_id_from_clients.rb +9 -0
- data/db/migrate/20130525212420_drop_table_imported_creds.rb +14 -0
- data/db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb +6 -0
- data/db/migrate/20130604145732_create_task_sessions.rb +9 -0
- data/db/migrate/20130717150737_remove_pname_validation.rb +7 -0
- data/db/migrate/20131002004641_create_automatic_exploitation_matches.rb +13 -0
- data/db/migrate/20131002164449_create_automatic_exploitation_match_sets.rb +12 -0
- data/db/migrate/20131008213344_create_automatic_exploitation_runs.rb +11 -0
- data/db/migrate/20131011184338_module_detail_on_automatic_exploitation_match.rb +10 -0
- data/db/migrate/20131017150735_create_automatic_exploitation_match_results.rb +11 -0
- data/db/migrate/20131021185657_make_match_polymorphic.rb +11 -0
- data/db/migrate/20140905031549_add_detected_arch_to_host.rb +5 -0
- data/db/migrate/20150112203945_remove_duplicate_services.rb +17 -0
- data/db/migrate/20150205192745_drop_service_uniqueness_index.rb +5 -0
- data/db/migrate/20150209195939_add_vuln_id_to_note.rb +6 -0
- data/db/migrate/20150212214222_remove_duplicate_services2.rb +17 -0
- data/db/migrate/20150219173821_create_module_runs.rb +23 -0
- data/db/migrate/20150219215039_add_module_run_to_session.rb +8 -0
- data/db/migrate/20150226151459_add_module_run_fk_to_loot.rb +8 -0
- data/db/migrate/20150312155312_add_module_full_name_to_match.rb +6 -0
- data/db/migrate/20150317145455_rename_module_indices.rb +29 -0
- data/db/migrate/20150326183742_add_missing_ae_indices.rb +13 -0
- data/db/migrate/20150421211719_rename_automatic_exploitation_index.rb +16 -0
- data/db/migrate/20150514182921_add_origin_to_mdm_vuln.rb +13 -0
- data/db/migrate/20160415153312_remove_not_null_from_web_vuln_p_arams.rb +5 -0
- data/db/migrate/20161004165612_add_fingerprinted_to_workspace.rb +5 -0
- data/db/migrate/20161227212223_add_os_family_to_hosts.rb +5 -0
- data/db/migrate/20180904120211_create_payloads.rb +21 -0
- data/db/migrate/20190308134512_create_async_callbacks.rb +13 -0
- data/db/migrate/20190507120211_remove_payload_workspaces.rb +5 -0
- data/lib/mdm/host/operating_system_normalization.rb +942 -0
- data/lib/mdm/module.rb +13 -0
- data/lib/mdm.rb +57 -0
- data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
- data/lib/metasploit_data_models/base64_serializer.rb +99 -0
- data/lib/metasploit_data_models/change_required_columns_to_null_false.rb +21 -0
- data/lib/metasploit_data_models/engine.rb +32 -0
- data/lib/metasploit_data_models/ip_address/cidr.rb +174 -0
- data/lib/metasploit_data_models/ip_address/range.rb +181 -0
- data/lib/metasploit_data_models/ip_address/v4/segment/nmap.rb +7 -0
- data/lib/metasploit_data_models/ip_address/v4/segment.rb +7 -0
- data/lib/metasploit_data_models/ip_address/v4.rb +11 -0
- data/lib/metasploit_data_models/ip_address.rb +9 -0
- data/lib/metasploit_data_models/match/child.rb +48 -0
- data/lib/metasploit_data_models/match/parent.rb +103 -0
- data/lib/metasploit_data_models/match.rb +8 -0
- data/lib/metasploit_data_models/search/operation/port.rb +9 -0
- data/lib/metasploit_data_models/search/operation.rb +9 -0
- data/lib/metasploit_data_models/search/operator/port.rb +6 -0
- data/lib/metasploit_data_models/search/operator.rb +8 -0
- data/lib/metasploit_data_models/search/visitor.rb +11 -0
- data/lib/metasploit_data_models/search.rb +8 -0
- data/lib/metasploit_data_models/serialized_prefs.rb +27 -0
- data/lib/metasploit_data_models/version.rb +13 -0
- data/lib/metasploit_data_models.rb +56 -0
- data/metasploit_data_models.gemspec +65 -0
- data/script/rails +8 -0
- data/spec/app/models/mdm/api_key_spec.rb +3 -0
- data/spec/app/models/mdm/client_spec.rb +43 -0
- data/spec/app/models/mdm/cred_spec.rb +346 -0
- data/spec/app/models/mdm/event_spec.rb +90 -0
- data/spec/app/models/mdm/exploit_attempt_spec.rb +59 -0
- data/spec/app/models/mdm/exploited_host_spec.rb +44 -0
- data/spec/app/models/mdm/host_detail_spec.rb +48 -0
- data/spec/app/models/mdm/host_spec.rb +1139 -0
- data/spec/app/models/mdm/host_tag_spec.rb +69 -0
- data/spec/app/models/mdm/listener_spec.rb +107 -0
- data/spec/app/models/mdm/loot_spec.rb +84 -0
- data/spec/app/models/mdm/macro_spec.rb +3 -0
- data/spec/app/models/mdm/mod_ref_spec.rb +3 -0
- data/spec/app/models/mdm/module/action_spec.rb +34 -0
- data/spec/app/models/mdm/module/arch_spec.rb +34 -0
- data/spec/app/models/mdm/module/author_spec.rb +52 -0
- data/spec/app/models/mdm/module/detail_spec.rb +746 -0
- data/spec/app/models/mdm/module/mixin_spec.rb +34 -0
- data/spec/app/models/mdm/module/platform_spec.rb +34 -0
- data/spec/app/models/mdm/module/ref_spec.rb +58 -0
- data/spec/app/models/mdm/module/target_spec.rb +36 -0
- data/spec/app/models/mdm/nexpose_console_spec.rb +146 -0
- data/spec/app/models/mdm/note_spec.rb +91 -0
- data/spec/app/models/mdm/profile_spec.rb +3 -0
- data/spec/app/models/mdm/ref_spec.rb +71 -0
- data/spec/app/models/mdm/route_spec.rb +35 -0
- data/spec/app/models/mdm/service_spec.rb +232 -0
- data/spec/app/models/mdm/session_event_spec.rb +42 -0
- data/spec/app/models/mdm/session_spec.rb +118 -0
- data/spec/app/models/mdm/tag_spec.rb +116 -0
- data/spec/app/models/mdm/task_cred_spec.rb +51 -0
- data/spec/app/models/mdm/task_host_spec.rb +50 -0
- data/spec/app/models/mdm/task_service_spec.rb +50 -0
- data/spec/app/models/mdm/task_session_spec.rb +46 -0
- data/spec/app/models/mdm/task_spec.rb +71 -0
- data/spec/app/models/mdm/user_spec.rb +50 -0
- data/spec/app/models/mdm/vuln_attempt_spec.rb +53 -0
- data/spec/app/models/mdm/vuln_detail_spec.rb +65 -0
- data/spec/app/models/mdm/vuln_ref_spec.rb +46 -0
- data/spec/app/models/mdm/vuln_spec.rb +299 -0
- data/spec/app/models/mdm/web_form_spec.rb +46 -0
- data/spec/app/models/mdm/web_page_spec.rb +101 -0
- data/spec/app/models/mdm/web_site_spec.rb +85 -0
- data/spec/app/models/mdm/web_vuln_spec.rb +312 -0
- data/spec/app/models/mdm/wmap_request_spec.rb +5 -0
- data/spec/app/models/mdm/wmap_target_spec.rb +5 -0
- data/spec/app/models/mdm/workspace_spec.rb +500 -0
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +86 -0
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +46 -0
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +37 -0
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +38 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +119 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +149 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +298 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +276 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +302 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +27 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +324 -0
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +181 -0
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +134 -0
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +180 -0
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +39 -0
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +138 -0
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +233 -0
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +17 -0
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +160 -0
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +162 -0
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +96 -0
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +175 -0
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +396 -0
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +49 -0
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +925 -0
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +187 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/config/manifest.js +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +61 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/database.yml.example +22 -0
- data/spec/dummy/config/database.yml.github_actions +21 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/active_record_migrations.rb +4 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/structure.sql +3430 -0
- data/spec/dummy/db/structure.sql.from_rails_3 +3403 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/mdm/addresses.rb +12 -0
- data/spec/factories/mdm/clients.rb +8 -0
- data/spec/factories/mdm/creds.rb +17 -0
- data/spec/factories/mdm/events.rb +15 -0
- data/spec/factories/mdm/exploit_attempts.rb +8 -0
- data/spec/factories/mdm/exploited_hosts.rb +7 -0
- data/spec/factories/mdm/fingerprints/nessus_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/nexpose_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/nmap_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/retina_fingerprints.rb +6 -0
- data/spec/factories/mdm/fingerprints/session_fingerprints.rb +6 -0
- data/spec/factories/mdm/host_details.rb +8 -0
- data/spec/factories/mdm/host_tags.rb +9 -0
- data/spec/factories/mdm/hosts.rb +85 -0
- data/spec/factories/mdm/listeners.rb +12 -0
- data/spec/factories/mdm/loots.rb +11 -0
- data/spec/factories/mdm/module/actions.rb +14 -0
- data/spec/factories/mdm/module/archs.rb +14 -0
- data/spec/factories/mdm/module/authors.rb +22 -0
- data/spec/factories/mdm/module/details.rb +73 -0
- data/spec/factories/mdm/module/mixins.rb +14 -0
- data/spec/factories/mdm/module/platforms.rb +14 -0
- data/spec/factories/mdm/module/refs.rb +14 -0
- data/spec/factories/mdm/module/targets.rb +19 -0
- data/spec/factories/mdm/nexpose_consoles.rb +15 -0
- data/spec/factories/mdm/notes.rb +12 -0
- data/spec/factories/mdm/refs.rb +9 -0
- data/spec/factories/mdm/routes.rb +36 -0
- data/spec/factories/mdm/services.rb +41 -0
- data/spec/factories/mdm/session_events.rb +8 -0
- data/spec/factories/mdm/sessions.rb +13 -0
- data/spec/factories/mdm/tags.rb +14 -0
- data/spec/factories/mdm/task.rb +16 -0
- data/spec/factories/mdm/task_creds.rb +9 -0
- data/spec/factories/mdm/task_hosts.rb +9 -0
- data/spec/factories/mdm/task_services.rb +8 -0
- data/spec/factories/mdm/task_sessions.rb +8 -0
- data/spec/factories/mdm/users.rb +22 -0
- data/spec/factories/mdm/vuln_attempts.rb +8 -0
- data/spec/factories/mdm/vuln_details.rb +8 -0
- data/spec/factories/mdm/vuln_refs.rb +4 -0
- data/spec/factories/mdm/vulns.rb +20 -0
- data/spec/factories/mdm/web_forms.rb +33 -0
- data/spec/factories/mdm/web_pages.rb +64 -0
- data/spec/factories/mdm/web_sites.rb +8 -0
- data/spec/factories/mdm/web_vulns.rb +64 -0
- data/spec/factories/mdm/workspaces.rb +23 -0
- data/spec/factories/metasploit_data_models/automatic_exploitation/match_results.rb +7 -0
- data/spec/factories/metasploit_data_models/automatic_exploitation/match_sets.rb +8 -0
- data/spec/factories/metasploit_data_models/automatic_exploitation/matches.rb +7 -0
- data/spec/factories/metasploit_data_models/automatic_exploitation/runs.rb +6 -0
- data/spec/factories/module_runs.rb +40 -0
- data/spec/lib/base64_serializer_spec.rb +172 -0
- data/spec/lib/ipaddr_spec.rb +29 -0
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +356 -0
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +75 -0
- data/spec/lib/metasploit_data_models/match/child_spec.rb +59 -0
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +153 -0
- data/spec/lib/metasploit_data_models_spec.rb +13 -0
- data/spec/spec_helper.rb +148 -0
- data/spec/support/matchers/match_regex_exactly.rb +28 -0
- data/spec/support/shared/contexts/rex/text.rb +15 -0
- data/spec/support/shared/examples/coerces_inet_column_type_to_string.rb +15 -0
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +20 -0
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +36 -0
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +109 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +38 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +26 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record.rb +50 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +34 -0
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +51 -0
- metadata +444 -6
@@ -0,0 +1,125 @@
|
|
1
|
+
# Data gathered or derived from the {#host} or {#service} such as its {#ntype fingerprint}.
|
2
|
+
class Mdm::Note < ApplicationRecord
|
3
|
+
|
4
|
+
#
|
5
|
+
# Associations
|
6
|
+
#
|
7
|
+
|
8
|
+
# @!attribute [rw] host
|
9
|
+
# The host to which this note is attached.
|
10
|
+
#
|
11
|
+
# @return [Mdm::Host] if note is attached to an {Mdm::Host}.
|
12
|
+
# @return [nil] if note is attached to an {Mdm::Service}.
|
13
|
+
belongs_to :host,
|
14
|
+
class_name: 'Mdm::Host',
|
15
|
+
counter_cache: :note_count,
|
16
|
+
inverse_of: :notes
|
17
|
+
|
18
|
+
# @!attribute [rw] service
|
19
|
+
# The service to which this note is attached.
|
20
|
+
#
|
21
|
+
# @return [Mdm::Service] if note is attached to an {Mdm::Service}.
|
22
|
+
# @return [nil] if not is attached to an {Mdm::Host}.
|
23
|
+
belongs_to :service,
|
24
|
+
class_name: 'Mdm::Service',
|
25
|
+
inverse_of: :notes
|
26
|
+
|
27
|
+
# @!attribute [rw] vuln
|
28
|
+
# The vuln to which this note is attached.
|
29
|
+
#
|
30
|
+
# @return [Mdm::Vuln] if note is attached to an {Mdm::Vuln}.
|
31
|
+
# @return [nil] if not is attached to an {Mdm::Host}.
|
32
|
+
belongs_to :vuln,
|
33
|
+
class_name: 'Mdm::Vuln',
|
34
|
+
inverse_of: :notes
|
35
|
+
|
36
|
+
# @!attribute [rw] workspace
|
37
|
+
# The workspace in which the {#host} or {#service} exists.
|
38
|
+
#
|
39
|
+
# @return [Mdm::Workspace]
|
40
|
+
belongs_to :workspace,
|
41
|
+
class_name: 'Mdm::Workspace',
|
42
|
+
inverse_of: :notes
|
43
|
+
|
44
|
+
#
|
45
|
+
# Attributes
|
46
|
+
#
|
47
|
+
|
48
|
+
# @!attribute [rw] created_at
|
49
|
+
# When the note was created.
|
50
|
+
#
|
51
|
+
# @return [DateTime]
|
52
|
+
|
53
|
+
# @!attribute [rw] critical
|
54
|
+
# Whether this note is critical or not.
|
55
|
+
#
|
56
|
+
# @return [Boolean]
|
57
|
+
|
58
|
+
# @!attribute [rw] data
|
59
|
+
# A Hash of data about the {#host} or {#service}.
|
60
|
+
#
|
61
|
+
# @return [Hash]
|
62
|
+
|
63
|
+
# @!attribute [rw] ntype
|
64
|
+
# The type of note. Usually a dot-separateed name like 'host.updated.<foo>'.
|
65
|
+
#
|
66
|
+
# @return [String]
|
67
|
+
|
68
|
+
# @!attribute [rw] seen
|
69
|
+
# Whether any user has seen this note.
|
70
|
+
#
|
71
|
+
# @return [Boolean]
|
72
|
+
|
73
|
+
# @!attribute [rw] updated_at
|
74
|
+
# The last time the note was updated.
|
75
|
+
#
|
76
|
+
# @return [DateTime]
|
77
|
+
|
78
|
+
#
|
79
|
+
# Callbacks
|
80
|
+
#
|
81
|
+
|
82
|
+
after_save :normalize
|
83
|
+
|
84
|
+
#
|
85
|
+
# Scopes
|
86
|
+
#
|
87
|
+
|
88
|
+
scope :flagged, -> { where('critical = true AND seen = false') }
|
89
|
+
|
90
|
+
scope :visible, -> { where(Mdm::Note[:ntype].not_in(['web.form', 'web.url', 'web.vuln'])) }
|
91
|
+
|
92
|
+
scope :search, lambda { |*args|
|
93
|
+
joins(:host).
|
94
|
+
where(
|
95
|
+
"(notes.data NOT ILIKE 'BAh7%' AND notes.data LIKE ?) " +
|
96
|
+
"OR (notes.data ILIKE 'BAh7%' AND decode(notes.data, 'base64') LIKE ?) " +
|
97
|
+
'OR notes.ntype ILIKE ? ' +
|
98
|
+
'OR COALESCE(hosts.name, CAST(hosts.address AS TEXT)) ILIKE ?',
|
99
|
+
"%#{args[0]}%", "%#{args[0]}%", "%#{args[0]}%", "%#{args[0]}%"
|
100
|
+
)
|
101
|
+
}
|
102
|
+
|
103
|
+
#
|
104
|
+
# Serializations
|
105
|
+
#
|
106
|
+
|
107
|
+
serialize :data, ::MetasploitDataModels::Base64Serializer.new
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
# {Mdm::Host::OperatingSystemNormalization#normalize_os Normalizes the host operating system} if the note is a
|
112
|
+
# {#ntype fingerprint}.
|
113
|
+
#
|
114
|
+
# @return [void]
|
115
|
+
def normalize
|
116
|
+
if saved_change_to_data? and ntype =~ /fingerprint/ && host.workspace.present? && !host.workspace.import_fingerprint
|
117
|
+
host.normalize_os
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
public
|
122
|
+
|
123
|
+
Metasploit::Concern.run(self)
|
124
|
+
end
|
125
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# A payload that has been generated by Metasploit and used to establish {Mdm::Session}.
|
2
|
+
class Mdm::Payload < ApplicationRecord
|
3
|
+
extend ActiveSupport::Autoload
|
4
|
+
|
5
|
+
include Metasploit::Model::Search
|
6
|
+
|
7
|
+
#
|
8
|
+
# Associations
|
9
|
+
#
|
10
|
+
|
11
|
+
|
12
|
+
#
|
13
|
+
# Attributes
|
14
|
+
#
|
15
|
+
|
16
|
+
# @!attribute [rw] name
|
17
|
+
# The name of this payload.
|
18
|
+
#
|
19
|
+
# @return [String]
|
20
|
+
|
21
|
+
# @!attribute [rw] uuid
|
22
|
+
# A unique identifier for this payload. The UUID is encoded to include specific information.
|
23
|
+
# See lib/msf/core/payload/uuid.rb in the https://github.com/rapid7/metasploit-framework repo.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
|
27
|
+
# @!attribute [rw] uuid_mask
|
28
|
+
# The number of bytes of the UUID that this payload has embedded within it. This is to support
|
29
|
+
# legacy payloads that limit the UUID to 8 bytes
|
30
|
+
#
|
31
|
+
# @return [Integer]
|
32
|
+
|
33
|
+
# @!attribute [rw] timestamp
|
34
|
+
# The Unix format timestamp when this payload was created.
|
35
|
+
#
|
36
|
+
# @return [Integer]
|
37
|
+
|
38
|
+
# @!attribute [rw] arch
|
39
|
+
# The architecture this payload supports.
|
40
|
+
# Valid values are located at lib/msf/core/payload/uuid.rb in the https://github.com/rapid7/metasploit-framework repo.
|
41
|
+
#
|
42
|
+
# @return [String]
|
43
|
+
|
44
|
+
# @!attribute [rw] platform
|
45
|
+
# The platform this payload supports.
|
46
|
+
# Valid values are located at lib/msf/core/payload/uuid.rb in the https://github.com/rapid7/metasploit-framework repo.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
|
50
|
+
# @!attribute [rw] urls
|
51
|
+
# The unique, encoded urls used to host this payload. Only applicable for http(s) payloads
|
52
|
+
#
|
53
|
+
# @return [Array]
|
54
|
+
|
55
|
+
# @!attribute [rw] description
|
56
|
+
# A description of why this payload was created and what it is being used for.
|
57
|
+
#
|
58
|
+
# @return [String]
|
59
|
+
|
60
|
+
# @!attribute [rw] raw_payload
|
61
|
+
# A URL pointing to where the binary payload can be downloaded from.
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
|
65
|
+
# @!attribute [rw] raw_payload_hash
|
66
|
+
# The unique hash value for the generated payload binary
|
67
|
+
#
|
68
|
+
# @return [String]
|
69
|
+
|
70
|
+
# @!attribute [rw] build_status
|
71
|
+
# The current status of the job building the payload binary. Valid values are "started", "completed", and "error"
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
|
75
|
+
# @!attribute [rw] build_opts
|
76
|
+
# A hash containing various options used to build this payload
|
77
|
+
#
|
78
|
+
# @return [Hash]
|
79
|
+
|
80
|
+
|
81
|
+
#
|
82
|
+
# Validations
|
83
|
+
#
|
84
|
+
|
85
|
+
|
86
|
+
#
|
87
|
+
# Search Attributes
|
88
|
+
#
|
89
|
+
|
90
|
+
search_attribute :uuid,
|
91
|
+
type: :string
|
92
|
+
|
93
|
+
#
|
94
|
+
# Serializations
|
95
|
+
#
|
96
|
+
|
97
|
+
serialize :urls
|
98
|
+
serialize :build_opts
|
99
|
+
|
100
|
+
public
|
101
|
+
|
102
|
+
Metasploit::Concern.run(self)
|
103
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# User settings.
|
2
|
+
class Mdm::Profile < ApplicationRecord
|
3
|
+
#
|
4
|
+
# Attributes
|
5
|
+
#
|
6
|
+
|
7
|
+
# @!attribute active
|
8
|
+
# Whether this is the currently active profile.
|
9
|
+
#
|
10
|
+
# @return [true] if this is the active profile.
|
11
|
+
# @return [false] if this profile is inactive and another profile is active.
|
12
|
+
|
13
|
+
# @!attribute created_at
|
14
|
+
# When this profile was created.
|
15
|
+
#
|
16
|
+
# @return [DateTime]
|
17
|
+
|
18
|
+
# @!attribute name
|
19
|
+
# Name of this profile to distinguish it from other profiles.
|
20
|
+
#
|
21
|
+
# @return [String]
|
22
|
+
|
23
|
+
# @!attribute owner
|
24
|
+
# Owner of this profile.
|
25
|
+
#
|
26
|
+
# @return ['<system>'] System-wide profile for all users.
|
27
|
+
# @return [String] Name of user that uses this profile.
|
28
|
+
|
29
|
+
# @!attribute updated_at
|
30
|
+
# The last time this profile was updated.
|
31
|
+
#
|
32
|
+
# @return [DateTime]
|
33
|
+
|
34
|
+
#
|
35
|
+
# Serializations
|
36
|
+
#
|
37
|
+
|
38
|
+
# Global settings.
|
39
|
+
#
|
40
|
+
# @return [Hash]
|
41
|
+
serialize :settings, MetasploitDataModels::Base64Serializer.new
|
42
|
+
|
43
|
+
Metasploit::Concern.run(self)
|
44
|
+
end
|
45
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# An external vulnerability reference for vulnerabilities that aren't part of a module. {Mdm::Module::Ref} should be
|
2
|
+
# used whenever possible and Mdm::Ref should only be used when the vulnerability is from an import and can't be
|
3
|
+
# correlated to a module and its {Mdm::Module::Detail}.
|
4
|
+
class Mdm::Ref < ApplicationRecord
|
5
|
+
#
|
6
|
+
# Associations
|
7
|
+
#
|
8
|
+
|
9
|
+
# @!attribute [r] module_refs
|
10
|
+
# {Mdm::Module::Ref Mdm::Module::Refs} with the same name as this ref.
|
11
|
+
#
|
12
|
+
# @return [Array<Mdm::Module::Ref>]
|
13
|
+
has_many :module_refs,
|
14
|
+
:class_name => 'Mdm::Module::Ref',
|
15
|
+
:foreign_key => :name,
|
16
|
+
:primary_key => :name
|
17
|
+
|
18
|
+
# @!attribute [rw] vulns_refs
|
19
|
+
# Join model to {Mdm::Vuln Mdm::Vulns}. Use {#vulns} to get the actual {Mdm::Vuln Mdm::Vulns}.
|
20
|
+
#
|
21
|
+
# @todo MSP-3066
|
22
|
+
# @return [Array<Mdm::VulnRef>]
|
23
|
+
has_many :vulns_refs,
|
24
|
+
:class_name => 'Mdm::VulnRef',
|
25
|
+
inverse_of: :ref
|
26
|
+
|
27
|
+
#
|
28
|
+
# Through :vuln_refs
|
29
|
+
#
|
30
|
+
|
31
|
+
# @!attribute [rw] vulns
|
32
|
+
# Vulnerabilities referenced by this reference.
|
33
|
+
#
|
34
|
+
# @return [Array<Mdm::Vuln>]
|
35
|
+
has_many :vulns, :class_name => 'Mdm::Vuln', :through => :vulns_refs
|
36
|
+
|
37
|
+
#
|
38
|
+
# Attributes
|
39
|
+
#
|
40
|
+
|
41
|
+
# @!attribute [rw] name
|
42
|
+
# Designation for external reference. May include a prefix for the authority, such as 'CVE-', in which case the
|
43
|
+
# rest of the name is the designation assigned by that authority.
|
44
|
+
#
|
45
|
+
# @return [String]
|
46
|
+
|
47
|
+
Metasploit::Concern.run(self)
|
48
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Network route that goes through a {#session} to allow accessing IPs on the remote end of the session.
|
2
|
+
class Mdm::Route < ApplicationRecord
|
3
|
+
|
4
|
+
#
|
5
|
+
# Associations
|
6
|
+
#
|
7
|
+
|
8
|
+
# The session over which this route traverses.
|
9
|
+
belongs_to :session,
|
10
|
+
class_name: 'Mdm::Session',
|
11
|
+
inverse_of: :routes
|
12
|
+
|
13
|
+
#
|
14
|
+
# Attributes
|
15
|
+
#
|
16
|
+
|
17
|
+
# @!attribute netmask
|
18
|
+
# The netmask for this route.
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
|
22
|
+
# @!attribute subnet
|
23
|
+
# The subnet for this route.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
|
27
|
+
Metasploit::Concern.run(self)
|
28
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
# A service, such as an ssh server or web server, running on a {#host}.
|
2
|
+
class Mdm::Service < ApplicationRecord
|
3
|
+
include Metasploit::Model::Search
|
4
|
+
|
5
|
+
#
|
6
|
+
# CONSTANTS
|
7
|
+
#
|
8
|
+
|
9
|
+
# Valid values for {#proto}.
|
10
|
+
PROTOS = %w{tcp udp}
|
11
|
+
|
12
|
+
# Valid values for {#state}.
|
13
|
+
STATES = ['open', 'closed', 'filtered', 'unknown']
|
14
|
+
|
15
|
+
#
|
16
|
+
# Associations
|
17
|
+
#
|
18
|
+
|
19
|
+
# @!attribute creds
|
20
|
+
# Credentials gathered from this service.
|
21
|
+
#
|
22
|
+
# @return [ActiveRecord::Relation<Mdm::Cred>]
|
23
|
+
has_many :creds,
|
24
|
+
class_name: 'Mdm::Cred',
|
25
|
+
dependent: :destroy,
|
26
|
+
inverse_of: :service
|
27
|
+
|
28
|
+
# @!attribute exploit_attempts
|
29
|
+
# Exploit attempts against this service.
|
30
|
+
#
|
31
|
+
# @return [ActiveRecord::Relation<Mdm::ExploitAttempt>]
|
32
|
+
has_many :exploit_attempts,
|
33
|
+
class_name: 'Mdm::ExploitAttempt',
|
34
|
+
dependent: :destroy,
|
35
|
+
inverse_of: :service
|
36
|
+
|
37
|
+
# @!attribute exploited_hosts
|
38
|
+
# @todo MSP-2732
|
39
|
+
# @return [Array<Mdm::ExploitHost>]
|
40
|
+
has_many :exploited_hosts,
|
41
|
+
class_name: 'Mdm::ExploitedHost',
|
42
|
+
dependent: :destroy,
|
43
|
+
inverse_of: :service
|
44
|
+
|
45
|
+
# @!attribute host
|
46
|
+
# The host on which this service runs.
|
47
|
+
#
|
48
|
+
# @return [Mdm::Host]
|
49
|
+
belongs_to :host,
|
50
|
+
class_name: 'Mdm::Host',
|
51
|
+
counter_cache: :service_count,
|
52
|
+
inverse_of: :services
|
53
|
+
|
54
|
+
# @!attribute loots
|
55
|
+
# Loot gathers from this service.
|
56
|
+
#
|
57
|
+
# @return [ActiveRecord::Relation<Mdm::Loot>]
|
58
|
+
has_many :loots,
|
59
|
+
class_name: 'Mdm::Loot',
|
60
|
+
dependent: :destroy,
|
61
|
+
inverse_of: :service
|
62
|
+
|
63
|
+
# @!attribute notes
|
64
|
+
# Notes about this service.
|
65
|
+
#
|
66
|
+
# @return [ActiveRecord::Relation<Mdm::Note>]
|
67
|
+
has_many :notes,
|
68
|
+
class_name: 'Mdm::Note',
|
69
|
+
dependent: :destroy,
|
70
|
+
inverse_of: :service
|
71
|
+
|
72
|
+
# @!attribute [rw] task_services
|
73
|
+
# Details about what Tasks touched this service
|
74
|
+
#
|
75
|
+
# @return [Array<Mdm::TaskService>]
|
76
|
+
has_many :task_services,
|
77
|
+
class_name: 'Mdm::TaskService',
|
78
|
+
dependent: :destroy,
|
79
|
+
inverse_of: :service
|
80
|
+
|
81
|
+
# @!attribute vulns
|
82
|
+
# Vulnerabilities found in this service.
|
83
|
+
#
|
84
|
+
# @return [ActiveRecord::Relation<Mdm::Vuln>]
|
85
|
+
has_many :vulns,
|
86
|
+
class_name: 'Mdm::Vuln',
|
87
|
+
dependent: :destroy,
|
88
|
+
inverse_of: :service
|
89
|
+
|
90
|
+
# @!attribute web_sites
|
91
|
+
# Web sites running on top of this service.
|
92
|
+
#
|
93
|
+
# @return [ActiveRecord::Relation<Mdm::WebSite>]
|
94
|
+
has_many :web_sites,
|
95
|
+
class_name: 'Mdm::WebSite',
|
96
|
+
dependent: :destroy,
|
97
|
+
inverse_of: :service
|
98
|
+
|
99
|
+
#
|
100
|
+
# through: :task_services
|
101
|
+
#
|
102
|
+
|
103
|
+
# @!attribute [rw] tasks
|
104
|
+
# Tasks that touched this service
|
105
|
+
#
|
106
|
+
# @return [Array<Mdm::Task>]
|
107
|
+
has_many :tasks, :through => :task_services, :class_name => 'Mdm::Task'
|
108
|
+
|
109
|
+
#
|
110
|
+
# Through :web_sites
|
111
|
+
#
|
112
|
+
|
113
|
+
# @!attribute [r] web_pages
|
114
|
+
# Web pages in the {#web_sites} on top of this service.
|
115
|
+
#
|
116
|
+
# @return [Array<Mdm::WebPages>]
|
117
|
+
has_many :web_pages, :through => :web_sites, :class_name => 'Mdm::WebPage'
|
118
|
+
|
119
|
+
# @!attribute [r] web_forms
|
120
|
+
# Form in the {#web_sites} on top of this service.
|
121
|
+
#
|
122
|
+
# @return [Array<Mdm::WebForm>]
|
123
|
+
has_many :web_forms, :through => :web_sites, :class_name => 'Mdm::WebForm'
|
124
|
+
|
125
|
+
# @!attribute [r] web_vulns
|
126
|
+
# Vulnerabilities found in the {#web_sites} on top of this service.
|
127
|
+
#
|
128
|
+
# @return [Array<Mdm::WebVuln>]
|
129
|
+
has_many :web_vulns, :through => :web_sites, :class_name => 'Mdm::WebVuln'
|
130
|
+
|
131
|
+
#
|
132
|
+
# Attributes
|
133
|
+
#
|
134
|
+
|
135
|
+
# @!attribute [rw] info
|
136
|
+
# Additional information about the service that does not fit in the {#name} or {#proto}.
|
137
|
+
#
|
138
|
+
# @return [String]
|
139
|
+
|
140
|
+
# @!attribute [rw] port
|
141
|
+
# The port on which this service runs on the {#host}.
|
142
|
+
#
|
143
|
+
# @return [Integer]
|
144
|
+
|
145
|
+
# @!attribute [rw] name
|
146
|
+
# The name of the service.
|
147
|
+
#
|
148
|
+
# @return [String]
|
149
|
+
|
150
|
+
# @!attribute [rw] proto
|
151
|
+
# The protocol used by this service
|
152
|
+
#
|
153
|
+
# @return [String]
|
154
|
+
|
155
|
+
# @!attribute [rw] state
|
156
|
+
# Whether this service is opened, closed, filtered, or in an unknown state.
|
157
|
+
#
|
158
|
+
# @return [String] element of {STATES}.
|
159
|
+
|
160
|
+
#
|
161
|
+
# Callbacks
|
162
|
+
#
|
163
|
+
|
164
|
+
after_save :normalize_host_os
|
165
|
+
|
166
|
+
#
|
167
|
+
# Scopes
|
168
|
+
#
|
169
|
+
|
170
|
+
scope :inactive, -> { where("services.state != 'open'") }
|
171
|
+
scope :with_state, lambda { |a_state| where("services.state = ?", a_state)}
|
172
|
+
scope :search, lambda { |*args|
|
173
|
+
joins(:host).
|
174
|
+
where(
|
175
|
+
'services.name ILIKE ? OR ' +
|
176
|
+
'services.info ILIKE ? OR ' +
|
177
|
+
'services.proto ILIKE ? OR ' +
|
178
|
+
'services.port = ? OR ' +
|
179
|
+
'COALESCE(hosts.name, CAST(hosts.address AS TEXT)) ILIKE ?',
|
180
|
+
"%#{args[0]}%", "%#{args[0]}%", "%#{args[0]}%", (args[0].to_i > 0) ? args[0].to_i : 99999, "%#{args[0]}%"
|
181
|
+
)
|
182
|
+
}
|
183
|
+
|
184
|
+
#
|
185
|
+
#
|
186
|
+
# Search
|
187
|
+
#
|
188
|
+
#
|
189
|
+
|
190
|
+
#
|
191
|
+
# Search Associations
|
192
|
+
#
|
193
|
+
|
194
|
+
search_associations host: :tags
|
195
|
+
|
196
|
+
#
|
197
|
+
# Search Attributes
|
198
|
+
#
|
199
|
+
|
200
|
+
search_attribute :info,
|
201
|
+
type: :string
|
202
|
+
search_attribute :name,
|
203
|
+
type: :string
|
204
|
+
search_attribute :proto,
|
205
|
+
type: {
|
206
|
+
set: :string
|
207
|
+
}
|
208
|
+
|
209
|
+
#
|
210
|
+
# Search Withs
|
211
|
+
#
|
212
|
+
|
213
|
+
search_with MetasploitDataModels::Search::Operator::Port::List
|
214
|
+
|
215
|
+
#
|
216
|
+
# Validations
|
217
|
+
#
|
218
|
+
validates :port,
|
219
|
+
numericality: {
|
220
|
+
only_integer: true
|
221
|
+
},
|
222
|
+
inclusion: {
|
223
|
+
in: 1..65535
|
224
|
+
}
|
225
|
+
validates :port,
|
226
|
+
uniqueness: {
|
227
|
+
message: 'already exists on this host and protocol',
|
228
|
+
scope: [
|
229
|
+
:host_id,
|
230
|
+
:proto
|
231
|
+
]
|
232
|
+
}
|
233
|
+
validates :proto,
|
234
|
+
inclusion: {
|
235
|
+
in: PROTOS
|
236
|
+
}
|
237
|
+
|
238
|
+
|
239
|
+
#
|
240
|
+
# Class Methods
|
241
|
+
#
|
242
|
+
|
243
|
+
# Set of searchable values for {#proto}.
|
244
|
+
#
|
245
|
+
# @return [Set<String>] {PROTOS} as a `Set`.
|
246
|
+
# @see Metasploit::Model::Search::Operation::Set#membership
|
247
|
+
# @see Metasploit::Model::Search::Operator::Attribute#attribute_set
|
248
|
+
def self.proto_set
|
249
|
+
@proto_set ||= Set.new(PROTOS)
|
250
|
+
end
|
251
|
+
|
252
|
+
#
|
253
|
+
# Instance Methods
|
254
|
+
#
|
255
|
+
|
256
|
+
# {Mdm::Host::OperatingSystemNormalization#normalize_os Normalizes the host operating system} whenever {#info} has
|
257
|
+
# changed.
|
258
|
+
#
|
259
|
+
# @return [void]
|
260
|
+
def normalize_host_os
|
261
|
+
if saved_change_to_info? && host.workspace.present? && !host.workspace.import_fingerprint
|
262
|
+
host.normalize_os
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
Metasploit::Concern.run(self)
|
267
|
+
end
|