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,286 @@
|
|
1
|
+
# Workspace to separate different collections of {#hosts}. Can be used to separate pentests against different networks
|
2
|
+
# or different clients as reports are normally generated against all records in a workspace.
|
3
|
+
class Mdm::Workspace < ApplicationRecord
|
4
|
+
#
|
5
|
+
# CONSTANTS
|
6
|
+
#
|
7
|
+
|
8
|
+
DEFAULT = 'default'
|
9
|
+
|
10
|
+
#
|
11
|
+
# Associations
|
12
|
+
#
|
13
|
+
|
14
|
+
# Automatic exploitation runs against this workspace.
|
15
|
+
has_many :automatic_exploitation_runs,
|
16
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::Run',
|
17
|
+
inverse_of: :workspace
|
18
|
+
|
19
|
+
# Automatic exploitation match sets generated against {#hosts} and {#services} in this workspace.
|
20
|
+
has_many :automatic_exploitation_match_sets,
|
21
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation:MatchSet',
|
22
|
+
inverse_of: :workspace
|
23
|
+
|
24
|
+
|
25
|
+
# Events that occurred in this workspace.
|
26
|
+
has_many :events, dependent: :delete_all, :class_name => 'Mdm::Event'
|
27
|
+
|
28
|
+
# Hosts in this workspace.
|
29
|
+
has_many :hosts, :dependent => :destroy, :class_name => 'Mdm::Host'
|
30
|
+
|
31
|
+
# Listeners running for this workspace.
|
32
|
+
has_many :listeners, :dependent => :destroy, :class_name => 'Mdm::Listener'
|
33
|
+
|
34
|
+
# Notes about this workspace.
|
35
|
+
has_many :notes, :class_name => 'Mdm::Note'
|
36
|
+
|
37
|
+
# User that owns this workspace and has full permissions within this workspace even if they are not an
|
38
|
+
# {Mdm::User#admin administrator}.
|
39
|
+
belongs_to :owner, :class_name => 'Mdm::User', :foreign_key => 'owner_id'
|
40
|
+
|
41
|
+
# Tasks run inside this workspace.
|
42
|
+
has_many :tasks,
|
43
|
+
-> { order('created_at DESC') },
|
44
|
+
class_name: 'Mdm::Task',
|
45
|
+
dependent: :destroy
|
46
|
+
|
47
|
+
# Users that are allowed to use this workspace. Does not necessarily include all users, as an {Mdm::User#admin
|
48
|
+
# administrator} can access any workspace, even ones where they are not a member.
|
49
|
+
has_and_belongs_to_many :users,
|
50
|
+
-> { distinct },
|
51
|
+
class_name: 'Mdm::User',
|
52
|
+
join_table: 'workspace_members'
|
53
|
+
|
54
|
+
#
|
55
|
+
# through: :hosts
|
56
|
+
#
|
57
|
+
|
58
|
+
# Social engineering campaign or browser autopwn clients from {#hosts} in this workspace.
|
59
|
+
has_many :clients, :through => :hosts, :class_name => 'Mdm::Client'
|
60
|
+
|
61
|
+
# Hosts exploited in this workspace.
|
62
|
+
has_many :exploited_hosts, :through => :hosts, :class_name => 'Mdm::ExploitedHost'
|
63
|
+
|
64
|
+
# Loot gathered from {#hosts} in this workspace.
|
65
|
+
has_many :loots, :through => :hosts, :class_name => 'Mdm::Loot'
|
66
|
+
|
67
|
+
# Services running on {#hosts} in this workspace.
|
68
|
+
has_many :services,
|
69
|
+
class_name: 'Mdm::Service',
|
70
|
+
foreign_key: :service_id,
|
71
|
+
through: :hosts
|
72
|
+
|
73
|
+
# Vulnerabilities found on {#hosts} in this workspace.
|
74
|
+
has_many :vulns, :through => :hosts, :class_name => 'Mdm::Vuln'
|
75
|
+
|
76
|
+
# Sessions opened on {#hosts} in this workspace.
|
77
|
+
has_many :sessions, :through => :hosts, :class_name => 'Mdm::Session'
|
78
|
+
|
79
|
+
# @deprecated Use `Mdm::Workspace#core_credentials` defined by `Metasploit::Credential::Engine` to get
|
80
|
+
# `Metasploit::Credential::Core`s gathered from this workspace's {#hosts} and {#services}.
|
81
|
+
#
|
82
|
+
# Creds gathered from this workspace's {#hosts} and {#services}.
|
83
|
+
has_many :creds, :through => :services, :class_name => 'Mdm::Cred'
|
84
|
+
|
85
|
+
#
|
86
|
+
# Attributes
|
87
|
+
#
|
88
|
+
|
89
|
+
# @!attribute boundary
|
90
|
+
# Comma separated list of IP ranges (in various formats) and IP addresses that users of this workspace are allowed
|
91
|
+
# to interact with if {#limit_to_network} is `true`.
|
92
|
+
#
|
93
|
+
# @return [String]
|
94
|
+
|
95
|
+
# @!attribute description
|
96
|
+
# Long description (beyond {#name}) that explains the purpose of this workspace.
|
97
|
+
#
|
98
|
+
# @return [String]
|
99
|
+
|
100
|
+
# @!attribute limit_to_network
|
101
|
+
# Whether {#boundary} is respected.
|
102
|
+
#
|
103
|
+
# @return [false] do not limit interactions to {#boundary}.
|
104
|
+
# @return [true] limit interactions to {#boundary}.
|
105
|
+
|
106
|
+
# @!attribute name
|
107
|
+
# Name of this workspace.
|
108
|
+
#
|
109
|
+
# @return [String]
|
110
|
+
|
111
|
+
# @!attribute created_at
|
112
|
+
# When this workspace was created.
|
113
|
+
#
|
114
|
+
# @return [DateTime]
|
115
|
+
|
116
|
+
# @!attribute updated_at
|
117
|
+
# The last time this workspace was updated.
|
118
|
+
#
|
119
|
+
# @return [DateTime]
|
120
|
+
|
121
|
+
#
|
122
|
+
# Callbacks
|
123
|
+
#
|
124
|
+
|
125
|
+
before_save :normalize
|
126
|
+
|
127
|
+
#
|
128
|
+
# Validations
|
129
|
+
#
|
130
|
+
|
131
|
+
validates :name, :presence => true, :uniqueness => true, :length => {:maximum => 255}
|
132
|
+
validates :description, :length => {:maximum => 4096}
|
133
|
+
|
134
|
+
#
|
135
|
+
# Instance Methods
|
136
|
+
#
|
137
|
+
|
138
|
+
# @deprecated Use `Mdm::Workspace#credential_cores` when `Metasploit::Credential::Engine` is installed to get
|
139
|
+
# `Metasploit::Credential::Core`s. Use `Mdm::Service#logins` when `Metasploit::Credential::Engine` is installed to
|
140
|
+
# get `Metasploit::Credential::Login`s.
|
141
|
+
#
|
142
|
+
# @return [ActiveRecord::Relation<Mdm::Cred>]
|
143
|
+
def creds
|
144
|
+
Mdm::Cred
|
145
|
+
.joins(service: :host)
|
146
|
+
.where(hosts: {
|
147
|
+
workspace_id: self.id
|
148
|
+
})
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns default {Mdm::Workspace}.
|
152
|
+
#
|
153
|
+
# @return [Mdm::Workspace]
|
154
|
+
def self.default
|
155
|
+
where(name: DEFAULT).first_or_create
|
156
|
+
end
|
157
|
+
|
158
|
+
# Whether this is the {default} workspace.
|
159
|
+
#
|
160
|
+
# @return [true] if this is the {default} workspace.
|
161
|
+
# @return [false] if this is not the {default} workspace.
|
162
|
+
def default?
|
163
|
+
name == DEFAULT
|
164
|
+
end
|
165
|
+
|
166
|
+
# @deprecated Use `workspace.credential_cores.each` when `Metasploit::Credential::Engine` is installed to enumerate
|
167
|
+
# `Metasploit::Credential::Core`s. Use `service.logins.each` when `Metasploit::Credential::Engine` is installed to
|
168
|
+
# enumerate `Metasploit::Credential::Login`s.
|
169
|
+
#
|
170
|
+
# Enumerates each element of {#creds}.
|
171
|
+
#
|
172
|
+
# @yield [cred]
|
173
|
+
# @yieldparam cred [Mdm::Cred] Cred associated with {#hosts a host} or {#services a service} in this workspace.
|
174
|
+
# @yieldreturn [void]
|
175
|
+
# @return [void]
|
176
|
+
def each_cred(&block)
|
177
|
+
creds.each do |cred|
|
178
|
+
block.call(cred)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Enumerates each element of {#host_tags}.
|
183
|
+
#
|
184
|
+
# @yield [tag]
|
185
|
+
# @yieldparam tag [Mdm::Tag] a tag on {#hosts}.
|
186
|
+
# @yieldreturn [void]
|
187
|
+
# @return [void]
|
188
|
+
def each_host_tag(&block)
|
189
|
+
host_tags.each do |host_tag|
|
190
|
+
block.call(host_tag)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Tags on {#hosts}.
|
195
|
+
#
|
196
|
+
# @return [ActiveRecord::Relation<Mdm::Tag>]
|
197
|
+
def host_tags
|
198
|
+
Mdm::Tag
|
199
|
+
.joins(:hosts)
|
200
|
+
.where(hosts: {
|
201
|
+
workspace_id: self.id
|
202
|
+
})
|
203
|
+
end
|
204
|
+
|
205
|
+
# Web forms found on {#web_sites}.
|
206
|
+
#
|
207
|
+
# @return [ActiveRecord::Relation<Mdm::WebForm>]
|
208
|
+
def web_forms
|
209
|
+
Mdm::WebForm.joins(
|
210
|
+
Mdm::WebForm.join_association(:web_site),
|
211
|
+
Mdm::WebSite.join_association(:service),
|
212
|
+
Mdm::Service.join_association(:host),
|
213
|
+
Mdm::Host.join_association(:workspace)
|
214
|
+
).where(Mdm::Workspace[:id].eq(id)).distinct
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
# Web pages found on {#web_sites}.
|
219
|
+
#
|
220
|
+
# @return [ActiveRecord::Relation<Mdm::WebPage>]
|
221
|
+
def web_pages
|
222
|
+
Mdm::WebPage.joins(
|
223
|
+
Mdm::WebPage.join_association(:web_site),
|
224
|
+
Mdm::WebSite.join_association(:service),
|
225
|
+
Mdm::Service.join_association(:host),
|
226
|
+
Mdm::Host.join_association(:workspace)
|
227
|
+
).where(Mdm::Workspace[:id].eq(id)).distinct
|
228
|
+
end
|
229
|
+
|
230
|
+
# Web sites running on {#services}.
|
231
|
+
#
|
232
|
+
# @return [ActiveRecord::Relation<Mdm::WebSite>]
|
233
|
+
def web_sites
|
234
|
+
Mdm::WebSite.joins(
|
235
|
+
Mdm::WebSite.join_association(:service),
|
236
|
+
Mdm::Service.join_association(:host),
|
237
|
+
Mdm::Host.join_association(:workspace)
|
238
|
+
).where(Mdm::Workspace[:id].eq(id)).distinct
|
239
|
+
end
|
240
|
+
|
241
|
+
# Web vulnerability found on {#web_sites}.
|
242
|
+
#
|
243
|
+
# @return [ActiveRecord::Relation<Mdm::WebVuln>]
|
244
|
+
def web_vulns
|
245
|
+
Mdm::WebVuln.joins(
|
246
|
+
Mdm::WebVuln.join_association(:web_site),
|
247
|
+
Mdm::WebSite.join_association(:service),
|
248
|
+
Mdm::Service.join_association(:host),
|
249
|
+
Mdm::Host.join_association(:workspace)
|
250
|
+
).where(Mdm::Workspace[:id].eq(id)).distinct
|
251
|
+
end
|
252
|
+
|
253
|
+
# Web forms on {#web_sites}.
|
254
|
+
#
|
255
|
+
# @return [ActiveRecord::Relation<Mdm::WebForm>]
|
256
|
+
def unique_web_forms
|
257
|
+
web_forms.select('web_forms.id, web_forms.web_site_id, web_forms.path, web_forms.method, web_forms.query')
|
258
|
+
end
|
259
|
+
|
260
|
+
# {#unique_web_forms} hosted on `addrs`.
|
261
|
+
#
|
262
|
+
# @param addrs [Array<IPAddr, String>] {Mdm::Host#address} for the {Mdm::Service#host} for the {Mdm::WebSite#service}
|
263
|
+
# for the {Mdm::WebForm#web_site}.
|
264
|
+
# @return [Array<Mdm::WebForm>]
|
265
|
+
def web_unique_forms(addrs=nil)
|
266
|
+
forms = unique_web_forms
|
267
|
+
if addrs
|
268
|
+
forms.to_a.reject!{|f| not addrs.include?( f.web_site.service.host.address.to_s ) }
|
269
|
+
end
|
270
|
+
forms
|
271
|
+
end
|
272
|
+
|
273
|
+
private
|
274
|
+
|
275
|
+
# Strips {#boundary}.
|
276
|
+
#
|
277
|
+
# @return [void]
|
278
|
+
def normalize
|
279
|
+
boundary.strip! if boundary
|
280
|
+
end
|
281
|
+
|
282
|
+
public
|
283
|
+
|
284
|
+
Metasploit::Concern.run(self)
|
285
|
+
end
|
286
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Matches {#matchable} {Mdm::Service} or {Mdm::Vuln} to a {#module_detail Metasploit Module} that can exploit it.
|
2
|
+
class MetasploitDataModels::AutomaticExploitation::Match < ApplicationRecord
|
3
|
+
#
|
4
|
+
# Associations
|
5
|
+
#
|
6
|
+
|
7
|
+
# A (polymorphic) "matchable" entity like a {Mdm::Vuln} or {Mdm::Service}
|
8
|
+
#
|
9
|
+
# @return [Mdm::Service, Mdm::Vuln]
|
10
|
+
belongs_to :matchable, polymorphic: true
|
11
|
+
|
12
|
+
# The {MatchSet} this match is part of
|
13
|
+
has_many :match_results,
|
14
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchResult',
|
15
|
+
inverse_of: :match
|
16
|
+
|
17
|
+
# The {MatchSet} this match is part of
|
18
|
+
belongs_to :match_set,
|
19
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
|
20
|
+
inverse_of: :matches
|
21
|
+
|
22
|
+
# The Metasploit Module that this match connects to
|
23
|
+
belongs_to :module_detail,
|
24
|
+
class_name: 'Mdm::Module::Detail',
|
25
|
+
foreign_key: :module_fullname,
|
26
|
+
primary_key: :fullname
|
27
|
+
|
28
|
+
# Scope a match to a MetasploitDataModels::AutomaticExploitation::Run
|
29
|
+
scope :by_run_and_vuln,
|
30
|
+
->(run,vuln){
|
31
|
+
joins(
|
32
|
+
MetasploitDataModels::AutomaticExploitation::Match.join_association(:match_set),
|
33
|
+
MetasploitDataModels::AutomaticExploitation::MatchSet.join_association(:runs)
|
34
|
+
).where(
|
35
|
+
MetasploitDataModels::AutomaticExploitation::Run[:id].eq(run.id)
|
36
|
+
).where(
|
37
|
+
MetasploitDataModels::AutomaticExploitation::Match[:matchable_id].eq(vuln.id),
|
38
|
+
MetasploitDataModels::AutomaticExploitation::Match[:matchable_type].eq("Mdm::Vuln")
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
42
|
+
Metasploit::Concern.run(self)
|
43
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# The result of {#run running} a {#match}.
|
2
|
+
class MetasploitDataModels::AutomaticExploitation::MatchResult < ApplicationRecord
|
3
|
+
#
|
4
|
+
# CONSTANTS
|
5
|
+
#
|
6
|
+
|
7
|
+
# Running associated exploit did NOT create a session
|
8
|
+
FAILED = "failed"
|
9
|
+
# Running associated exploit created a session
|
10
|
+
SUCCEEDED = "succeeded"
|
11
|
+
|
12
|
+
# Valid values for {#state}
|
13
|
+
VALID_STATES = [FAILED, SUCCEEDED]
|
14
|
+
|
15
|
+
#
|
16
|
+
# Associations
|
17
|
+
#
|
18
|
+
|
19
|
+
# A {MetasploitDataModels::AutomaticExploitation::Match#module_detail Metasploit Module} matched to
|
20
|
+
# {MetasploitDataModels::AutomaticExploitation::Match#matchable Mdm::Host or Mdm::Service}.
|
21
|
+
belongs_to :match,
|
22
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::Match',
|
23
|
+
inverse_of: :match_results,
|
24
|
+
dependent: :destroy
|
25
|
+
|
26
|
+
# A mass automatic exploitation run.
|
27
|
+
belongs_to :run,
|
28
|
+
inverse_of: :match_results,
|
29
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::Run'
|
30
|
+
|
31
|
+
#
|
32
|
+
# Attributes
|
33
|
+
#
|
34
|
+
|
35
|
+
# @!attribute state
|
36
|
+
# Whether the {#run} of {#match} succeeded.
|
37
|
+
#
|
38
|
+
# @return ['failed', 'succeeded']
|
39
|
+
|
40
|
+
#
|
41
|
+
# Validations
|
42
|
+
#
|
43
|
+
|
44
|
+
# must be present and one of allowable values
|
45
|
+
validates :state,
|
46
|
+
presence: true,
|
47
|
+
inclusion: VALID_STATES
|
48
|
+
|
49
|
+
#
|
50
|
+
# Scopes
|
51
|
+
#
|
52
|
+
|
53
|
+
# Runs of {#match} that failed
|
54
|
+
scope :failed, lambda { where(state:"failed") }
|
55
|
+
|
56
|
+
# Runs of {#match} that succeeded
|
57
|
+
scope :succeeded, lambda { where(state:"succeeded") }
|
58
|
+
|
59
|
+
# Runs of {#match} by workspace ID
|
60
|
+
scope :by_workspace, lambda { |workspace_id|
|
61
|
+
joins(
|
62
|
+
MetasploitDataModels::AutomaticExploitation::MatchResult.join_association(:match),
|
63
|
+
MetasploitDataModels::AutomaticExploitation::Match.join_association(:match_set)
|
64
|
+
).where(
|
65
|
+
MetasploitDataModels::AutomaticExploitation::MatchSet[:workspace_id].eq(workspace_id),
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
69
|
+
Metasploit::Concern.run(self)
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# A set of {#matches automatic exploitation matches}.
|
2
|
+
class MetasploitDataModels::AutomaticExploitation::MatchSet < ApplicationRecord
|
3
|
+
#
|
4
|
+
# Associations
|
5
|
+
#
|
6
|
+
|
7
|
+
# Runs of this set of {#matches}.
|
8
|
+
has_many :runs,
|
9
|
+
class_name: "MetasploitDataModels::AutomaticExploitation::Run",
|
10
|
+
inverse_of: :match_set
|
11
|
+
|
12
|
+
# Matches in this set.
|
13
|
+
has_many :matches,
|
14
|
+
class_name: "MetasploitDataModels::AutomaticExploitation::Match",
|
15
|
+
inverse_of: :match_set,
|
16
|
+
dependent: :destroy
|
17
|
+
|
18
|
+
# User that created this match set.
|
19
|
+
belongs_to :user,
|
20
|
+
inverse_of: :automatic_exploitation_match_sets,
|
21
|
+
class_name: "Mdm::User"
|
22
|
+
|
23
|
+
# Workspace in which this match set exists.
|
24
|
+
belongs_to :workspace,
|
25
|
+
inverse_of: :automatic_exploitation_match_sets,
|
26
|
+
class_name: "Mdm::Workspace"
|
27
|
+
|
28
|
+
#
|
29
|
+
# Validations
|
30
|
+
#
|
31
|
+
|
32
|
+
validates :user,
|
33
|
+
presence: true
|
34
|
+
|
35
|
+
validates :workspace,
|
36
|
+
presence: true
|
37
|
+
|
38
|
+
|
39
|
+
Metasploit::Concern.run(self)
|
40
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Runs a {#match_set set of matches} to produce {#match_results results}.
|
2
|
+
class MetasploitDataModels::AutomaticExploitation::Run < ApplicationRecord
|
3
|
+
#
|
4
|
+
# Associations
|
5
|
+
#
|
6
|
+
|
7
|
+
# Results of each match in {#match_set}.
|
8
|
+
has_many :match_results,
|
9
|
+
class_name:'MetasploitDataModels::AutomaticExploitation::MatchResult',
|
10
|
+
inverse_of: :run,
|
11
|
+
dependent: :destroy
|
12
|
+
|
13
|
+
# Set of matches to run
|
14
|
+
belongs_to :match_set,
|
15
|
+
class_name: 'MetasploitDataModels::AutomaticExploitation::MatchSet',
|
16
|
+
inverse_of: :runs
|
17
|
+
|
18
|
+
# User that initiated this run.
|
19
|
+
belongs_to :user,
|
20
|
+
class_name: "Mdm::User",
|
21
|
+
inverse_of: :automatic_exploitation_runs
|
22
|
+
|
23
|
+
# Workspace in which this run was performed.
|
24
|
+
belongs_to :workspace,
|
25
|
+
class_name: "Mdm::Workspace",
|
26
|
+
inverse_of: :automatic_exploitation_runs
|
27
|
+
|
28
|
+
Metasploit::Concern.run(self)
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# An IPv4 CIDR (Classless InterDomain Routing) block composed of a
|
2
|
+
# {MetasploitDataModels::IPAddress::V4::Single IPv4} {MetasploitDataModels::IPAddress::CIDR#address address} and
|
3
|
+
# {MetasploitDataModels::IPAddress::CIDR#prefix_length prefix_length} written in the form `'a.b.c.d/prefix_length'`.
|
4
|
+
#
|
5
|
+
# @see https://en.wikipedia.org/wiki/Cidr#IPv6_CIDR_blocks
|
6
|
+
class MetasploitDataModels::IPAddress::V4::CIDR < Metasploit::Model::Base
|
7
|
+
include MetasploitDataModels::IPAddress::CIDR
|
8
|
+
|
9
|
+
#
|
10
|
+
# CIDR
|
11
|
+
#
|
12
|
+
|
13
|
+
cidr address_class: MetasploitDataModels::IPAddress::V4::Single
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Nmap's octet range format composed of segments of comma separated list of segment numbers and segment number ranges.
|
2
|
+
#
|
3
|
+
# @example Nmap octect range format
|
4
|
+
# # equivalent to ['1.5.6.7', '3.5.6.7', '4.5.6.7']
|
5
|
+
# '1,3-4.5.6.7'
|
6
|
+
#
|
7
|
+
# @see http://nmap.org/book/man-target-specification.html
|
8
|
+
class MetasploitDataModels::IPAddress::V4::Nmap < MetasploitDataModels::IPAddress::V4::Segmented
|
9
|
+
#
|
10
|
+
# Segments
|
11
|
+
#
|
12
|
+
|
13
|
+
segment class_name: 'MetasploitDataModels::IPAddress::V4::Segment::Nmap::List'
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# A range of complete IPv4 addresses, separated by a `-`.
|
2
|
+
class MetasploitDataModels::IPAddress::V4::Range < Metasploit::Model::Base
|
3
|
+
extend MetasploitDataModels::Match::Child
|
4
|
+
|
5
|
+
include MetasploitDataModels::IPAddress::Range
|
6
|
+
|
7
|
+
#
|
8
|
+
# Range Extremes
|
9
|
+
#
|
10
|
+
|
11
|
+
extremes class_name: 'MetasploitDataModels::IPAddress::V4::Single'
|
12
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# A comma separated list of {MetasploitDataModels::IPAddress::V4::Segment::Single segment numbers} and
|
2
|
+
# {MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range range of segment numbers} making up one segment of
|
3
|
+
# {MetasploitDataModels::IPAddress::V4::Nmap}.
|
4
|
+
class MetasploitDataModels::IPAddress::V4::Segment::Nmap::List < Metasploit::Model::Base
|
5
|
+
|
6
|
+
include MetasploitDataModels::Match::Parent
|
7
|
+
|
8
|
+
#
|
9
|
+
# CONSTANTS
|
10
|
+
#
|
11
|
+
|
12
|
+
# Either an individual {MetasploitDataModels::IPAddress::V4::Segment::Single segment number} or a
|
13
|
+
# {MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range segment range}.
|
14
|
+
RANGE_OR_NUMBER_REGEXP = %r{
|
15
|
+
(?<range>#{parent::Range.regexp})
|
16
|
+
|
|
17
|
+
# range first because it contains a segment and if the range isn't first only the first part of the range will
|
18
|
+
# match.
|
19
|
+
(?<number>#{MetasploitDataModels::IPAddress::V4::Segment::Single::REGEXP})
|
20
|
+
}x
|
21
|
+
# Separator between number or ranges
|
22
|
+
SEPARATOR = ','
|
23
|
+
# Segment of an NMAP address, composed of comma separated {RANGE_OR_NUMBER_REGEXP segment numbers or ranges}.
|
24
|
+
REGEXP = /#{RANGE_OR_NUMBER_REGEXP}(#{SEPARATOR}#{RANGE_OR_NUMBER_REGEXP})*/
|
25
|
+
|
26
|
+
# Matches exactly an Nmap comma separated list of segment numbers and ranges.
|
27
|
+
MATCH_REGEXP = /\A#{REGEXP}\z/
|
28
|
+
|
29
|
+
#
|
30
|
+
# Attributes
|
31
|
+
#
|
32
|
+
|
33
|
+
# @!attribute value
|
34
|
+
# The NMAP IPv4 octect range.
|
35
|
+
#
|
36
|
+
# @return [Array<MetasploitDataModels::IPAddress::V4::Segment::Number, MetasploitDataModels::IPAddress::V4::Segment::Range>]
|
37
|
+
# number and range in the order they appeared in formatted value.
|
38
|
+
attr_reader :value
|
39
|
+
|
40
|
+
#
|
41
|
+
# Match Children
|
42
|
+
#
|
43
|
+
|
44
|
+
match_children_named %w{
|
45
|
+
MetasploitDataModels::IPAddress::V4::Segment::Single
|
46
|
+
MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range
|
47
|
+
}
|
48
|
+
|
49
|
+
#
|
50
|
+
#
|
51
|
+
# Validations
|
52
|
+
#
|
53
|
+
#
|
54
|
+
|
55
|
+
#
|
56
|
+
# Method Validations
|
57
|
+
#
|
58
|
+
|
59
|
+
validate :value_elements_valid
|
60
|
+
validate :value_is_array
|
61
|
+
|
62
|
+
#
|
63
|
+
# Attribute Validations
|
64
|
+
#
|
65
|
+
|
66
|
+
validates :value,
|
67
|
+
presence: true
|
68
|
+
|
69
|
+
#
|
70
|
+
# Instance Methods
|
71
|
+
#
|
72
|
+
|
73
|
+
# @return [String]
|
74
|
+
def to_s
|
75
|
+
if value.is_a? Array
|
76
|
+
value.map(&:to_s).join(SEPARATOR)
|
77
|
+
else
|
78
|
+
value.to_s
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Set {#value} to an `Array` of segment numbers and ranges.
|
83
|
+
#
|
84
|
+
# @param formatted_value [#to_s]
|
85
|
+
# @return [Array<MetasploitDataModels::IPAddress::V4::Segment::Single, MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range>] a parsed `Array` of segment numbers and ranges.
|
86
|
+
# @return [#to_s] if `formatted_value` does not match {MATCH_REGEXP}.
|
87
|
+
def value=(formatted_value)
|
88
|
+
string = formatted_value.to_s
|
89
|
+
match = MATCH_REGEXP.match(string)
|
90
|
+
|
91
|
+
if match
|
92
|
+
ranges_or_numbers = string.split(SEPARATOR)
|
93
|
+
|
94
|
+
@value = ranges_or_numbers.map { |range_or_number|
|
95
|
+
match_child(range_or_number) || range_or_number
|
96
|
+
}
|
97
|
+
else
|
98
|
+
@value = formatted_value
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
# Validates that {#value}'s elements are all valid.
|
105
|
+
#
|
106
|
+
# @return [void]
|
107
|
+
def value_elements_valid
|
108
|
+
if value.is_a? Array
|
109
|
+
value.each_with_index do |element, index|
|
110
|
+
unless element.valid?
|
111
|
+
errors.add(:value, :element, element: element, index: index)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Validates that {#value} is an `Array`.
|
118
|
+
#
|
119
|
+
# @return [void]
|
120
|
+
def value_is_array
|
121
|
+
unless value.is_a? Array
|
122
|
+
errors.add(:value, :array)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# A range of segment number composed of a {#begin} and {#end} segment number, separated by a `-`.
|
2
|
+
class MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range < Metasploit::Model::Base
|
3
|
+
extend MetasploitDataModels::Match::Child
|
4
|
+
|
5
|
+
include MetasploitDataModels::IPAddress::Range
|
6
|
+
|
7
|
+
#
|
8
|
+
# Range Extremes
|
9
|
+
#
|
10
|
+
|
11
|
+
extremes class_name: 'MetasploitDataModels::IPAddress::V4::Segment::Single'
|
12
|
+
end
|