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,123 @@
|
|
1
|
+
# A segment number in an IPv4 address or the
|
2
|
+
# {MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range#begin} or
|
3
|
+
# {MetasploitDataModels::IPAddress::V4::Segment::Nmap::Range#send}.
|
4
|
+
class MetasploitDataModels::IPAddress::V4::Segment::Single < Metasploit::Model::Base
|
5
|
+
extend MetasploitDataModels::Match::Child
|
6
|
+
|
7
|
+
include Comparable
|
8
|
+
|
9
|
+
#
|
10
|
+
# CONSTANTS
|
11
|
+
#
|
12
|
+
|
13
|
+
# Number of bits in a IPv4 segment
|
14
|
+
BITS = 8
|
15
|
+
|
16
|
+
# Limit that {#value} can never reach
|
17
|
+
LIMIT = 1 << BITS
|
18
|
+
|
19
|
+
# Maximum segment {#value}
|
20
|
+
MAXIMUM = LIMIT - 1
|
21
|
+
|
22
|
+
# Minimum segment {#value}
|
23
|
+
MINIMUM = 0
|
24
|
+
|
25
|
+
# Regular expression for a segment (octet) of an IPv4 address in decimal dotted notation.
|
26
|
+
#
|
27
|
+
# @see http://stackoverflow.com/a/17871737/470451
|
28
|
+
REGEXP = /(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])/
|
29
|
+
|
30
|
+
#
|
31
|
+
# Attributes
|
32
|
+
#
|
33
|
+
|
34
|
+
# @!attribute value
|
35
|
+
# The segment number.
|
36
|
+
#
|
37
|
+
# @return [Integer, String]
|
38
|
+
attr_reader :value
|
39
|
+
|
40
|
+
#
|
41
|
+
# Validations
|
42
|
+
#
|
43
|
+
|
44
|
+
validates :value,
|
45
|
+
numericality: {
|
46
|
+
greater_than_or_equal_to: MINIMUM,
|
47
|
+
less_than_or_equal_to: MAXIMUM,
|
48
|
+
only_integer: true
|
49
|
+
}
|
50
|
+
|
51
|
+
#
|
52
|
+
# Class Methods
|
53
|
+
#
|
54
|
+
|
55
|
+
# (see BITS)
|
56
|
+
#
|
57
|
+
# @return [Integer] {BITS}
|
58
|
+
def self.bits
|
59
|
+
BITS
|
60
|
+
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Instance Methods
|
64
|
+
#
|
65
|
+
|
66
|
+
# Compare this segment to `other`.
|
67
|
+
#
|
68
|
+
# @param other [#value] another segent to compare against.
|
69
|
+
# @return [1] if this segment is greater than `other`.
|
70
|
+
# @return [0] if this segment is equal to `other`.
|
71
|
+
# @return [-1] if this segment is less than `other`.
|
72
|
+
def <=>(other)
|
73
|
+
value <=> other.value
|
74
|
+
end
|
75
|
+
|
76
|
+
# Full add (as in [full adder](https://en.wikipedia.org/wiki/Full_adder)) two (this segment and `other`) segments and
|
77
|
+
# a carry from the previous {#add_with_carry}.
|
78
|
+
#
|
79
|
+
# @param other [MetasploitDataModels:IPAddress::V4::Segment::Single] segment to add to this segment.
|
80
|
+
# @param carry [Integer] integer to add to this segment and other segment from a previous call to {#add_with_carry}
|
81
|
+
# for lower segments.
|
82
|
+
# @return [Array<(MetasploitDataModels::IPAddress::V4::Segment::Single, Integer)>] Array containing a proper segment
|
83
|
+
# (where {#value} is less than {LIMIT}) and a carry integer to pass to next call to {#add_with_carry}.
|
84
|
+
# @return (see #half_add)
|
85
|
+
def add_with_carry(other, carry=0)
|
86
|
+
improper_value = self.value + other.value + carry
|
87
|
+
proper_value = improper_value % LIMIT
|
88
|
+
carry = improper_value / LIMIT
|
89
|
+
segment = self.class.new(value: proper_value)
|
90
|
+
|
91
|
+
[segment, carry]
|
92
|
+
end
|
93
|
+
|
94
|
+
# The succeeding segment. Used in `Range`s when walking the `Range`.
|
95
|
+
#
|
96
|
+
# @return [MetasploitDataModels::IPAddress::V4::Segment::Single] if {#value} responds to `#succ`.
|
97
|
+
# @return [nil] otherwise
|
98
|
+
def succ
|
99
|
+
if value.respond_to? :succ
|
100
|
+
self.class.new(value: value.succ)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
delegate :to_s,
|
105
|
+
to: :value
|
106
|
+
|
107
|
+
# Sets {#value} by type casting String to Integer.
|
108
|
+
#
|
109
|
+
# @param formatted_value [#to_s]
|
110
|
+
# @return [Integer] if `formatted_value` contains only an Integer#to_s
|
111
|
+
# @return [#to_s] `formatted_value` if it does not contain an Integer#to_s
|
112
|
+
def value=(formatted_value)
|
113
|
+
@value_before_type_cast = formatted_value
|
114
|
+
|
115
|
+
begin
|
116
|
+
# use Integer() instead of String#to_i as String#to_i will ignore trailing letters (i.e. '1two' -> 1) and turn all
|
117
|
+
# string without an integer in it to 0.
|
118
|
+
@value = Integer(formatted_value.to_s)
|
119
|
+
rescue ArgumentError
|
120
|
+
@value = formatted_value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
# @note {segment} must be called in subclasses to set the {segment_class_name}.
|
2
|
+
#
|
3
|
+
# An IPv4 address that is composed of {SEGMENT_COUNT 4} {#segments} separated by {SEPARATOR `'.'`}.
|
4
|
+
#
|
5
|
+
# @example Using single segments to make a single IPv4 address class
|
6
|
+
# class MetasploitDataModels::IPAddress::V4::Single < MetasploitDataModels::IPAddress::V4::Segmented
|
7
|
+
# #
|
8
|
+
# # Segments
|
9
|
+
# #
|
10
|
+
#
|
11
|
+
# segment class_name: 'MetasploitDataModels::IPAddress::V4::Segment::Single'
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
class MetasploitDataModels::IPAddress::V4::Segmented < Metasploit::Model::Base
|
15
|
+
extend MetasploitDataModels::Match::Child
|
16
|
+
|
17
|
+
include Comparable
|
18
|
+
|
19
|
+
#
|
20
|
+
# CONSTANTS
|
21
|
+
#
|
22
|
+
|
23
|
+
# The number of {#segments}
|
24
|
+
SEGMENT_COUNT = 4
|
25
|
+
# Separator between segments
|
26
|
+
SEPARATOR = '.'
|
27
|
+
|
28
|
+
#
|
29
|
+
# Attributes
|
30
|
+
#
|
31
|
+
|
32
|
+
# @!attribute value
|
33
|
+
# Segments of IP address from high to low.
|
34
|
+
#
|
35
|
+
# @return [Array<MetasploitDataModels::IPAddress:V4::Segment::Nmap>]
|
36
|
+
attr_reader :value
|
37
|
+
|
38
|
+
#
|
39
|
+
#
|
40
|
+
# Validations
|
41
|
+
#
|
42
|
+
#
|
43
|
+
|
44
|
+
#
|
45
|
+
# Validation Methods
|
46
|
+
#
|
47
|
+
|
48
|
+
validate :segments_valid
|
49
|
+
|
50
|
+
#
|
51
|
+
# Attribute Validations
|
52
|
+
#
|
53
|
+
|
54
|
+
validates :segments,
|
55
|
+
length: {
|
56
|
+
is: SEGMENT_COUNT
|
57
|
+
}
|
58
|
+
|
59
|
+
#
|
60
|
+
# Class methods
|
61
|
+
#
|
62
|
+
|
63
|
+
# @note Call {segment} with the {segment_class_name} before calling this method, as it uses {segment_class} to look
|
64
|
+
# up the `REGEXP` of the {segment_class}.
|
65
|
+
#
|
66
|
+
# Regular expression that matches the part of a string that represents a IPv4 segmented IP address format.
|
67
|
+
#
|
68
|
+
# @return [Regexp]
|
69
|
+
def self.regexp
|
70
|
+
unless instance_variable_defined? :@regexp
|
71
|
+
separated_segment_count = SEGMENT_COUNT - 1
|
72
|
+
|
73
|
+
@regexp = %r{
|
74
|
+
(#{segment_class::REGEXP}#{Regexp.escape(SEPARATOR)}){#{separated_segment_count},#{separated_segment_count}}
|
75
|
+
#{segment_class::REGEXP}
|
76
|
+
}x
|
77
|
+
end
|
78
|
+
|
79
|
+
@regexp
|
80
|
+
end
|
81
|
+
|
82
|
+
# Sets up the {segment_class_name} for the subclass.
|
83
|
+
#
|
84
|
+
# @example Using {segment} to set {segment_class_name}
|
85
|
+
# segment class_name: 'MetasploitDataModels::IPAddress::V4::Segment::Single'
|
86
|
+
#
|
87
|
+
# @param options [Hash{Symbol => String}]
|
88
|
+
# @option options [String] :class_name a `Class#name` to use for {segment_class_name}.
|
89
|
+
# @return [void]
|
90
|
+
def self.segment(options={})
|
91
|
+
options.assert_valid_keys(:class_name)
|
92
|
+
|
93
|
+
@segment_class_name = options.fetch(:class_name)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @note Call {segment} to set the {segment_class_name} before calling {segment_class}, which will attempt to
|
97
|
+
# String#constantize` {segment_class_name}.
|
98
|
+
#
|
99
|
+
# The `Class` used to parse each segment of the IPv4 address.
|
100
|
+
#
|
101
|
+
# @return [Class]
|
102
|
+
def self.segment_class
|
103
|
+
@segment_class = segment_class_name.constantize
|
104
|
+
end
|
105
|
+
|
106
|
+
# @note Call {segment} to set {segment_class_name}
|
107
|
+
#
|
108
|
+
# The name of {segment_class}
|
109
|
+
#
|
110
|
+
# @return [String] a `Class#name` for {segment_class}.
|
111
|
+
def self.segment_class_name
|
112
|
+
@segment_class_name
|
113
|
+
end
|
114
|
+
|
115
|
+
# (see SEGMENT_COUNT)
|
116
|
+
#
|
117
|
+
# @return [Integer]
|
118
|
+
def self.segment_count
|
119
|
+
SEGMENT_COUNT
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# Instance methods
|
124
|
+
#
|
125
|
+
|
126
|
+
# Compare this segment IPv4 address to `other`.
|
127
|
+
#
|
128
|
+
# @return [1] if {#segments} are greater than {#segments} of `other`.
|
129
|
+
# @return [0] if {#segments} are equal to {#segments} of `other`.
|
130
|
+
# @return [-1] if {#segments} are less than {#segments} of `other`.
|
131
|
+
# @return [nil] if `other` isn't the same `Class`
|
132
|
+
def <=>(other)
|
133
|
+
if other.is_a? self.class
|
134
|
+
segments <=> other.segments
|
135
|
+
else
|
136
|
+
# The interface for <=> requires nil be returned if other is incomparable
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Array of segments.
|
142
|
+
#
|
143
|
+
# @return [Array] if {#value} is an `Array`.
|
144
|
+
# @return [[]] if {#value} is not an `Array`.
|
145
|
+
def segments
|
146
|
+
if value.is_a? Array
|
147
|
+
value
|
148
|
+
else
|
149
|
+
[]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Set {#segments}.
|
154
|
+
#
|
155
|
+
# @param segments [Array] `Array` of {segment_class} instances
|
156
|
+
# @return [Array] `Array` of {segment_class} instances
|
157
|
+
def segments=(segments)
|
158
|
+
@value = segments
|
159
|
+
end
|
160
|
+
|
161
|
+
# Segments joined with {SEPARATOR}.
|
162
|
+
#
|
163
|
+
# @return [String]
|
164
|
+
def to_s
|
165
|
+
segments.map(&:to_s).join(SEPARATOR)
|
166
|
+
end
|
167
|
+
|
168
|
+
# @note Set {#segments} if value is not formatted, but already broken into an `Array` of {segment_class} instances.
|
169
|
+
#
|
170
|
+
# Sets {#value} by parsing its segments.
|
171
|
+
#
|
172
|
+
# @param formatted_value [#to_s]
|
173
|
+
def value=(formatted_value)
|
174
|
+
string = formatted_value.to_s
|
175
|
+
match = self.class.match_regexp.match(string)
|
176
|
+
|
177
|
+
if match
|
178
|
+
segments = string.split(SEPARATOR)
|
179
|
+
|
180
|
+
@value = segments.map { |segment|
|
181
|
+
self.class.segment_class.new(value: segment)
|
182
|
+
}
|
183
|
+
else
|
184
|
+
@value = formatted_value
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
|
190
|
+
# Validates that all segments in {#segments} are valid.
|
191
|
+
#
|
192
|
+
# @return [void]
|
193
|
+
def segments_valid
|
194
|
+
segments.each_with_index do |segment, index|
|
195
|
+
unless segment.valid?
|
196
|
+
errors.add(:segments, :segment_invalid, index: index, segment: segment)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# A single IPv4 address, in standard, dotted decimal notation.
|
2
|
+
#
|
3
|
+
# @example Dotted Decimal Notation
|
4
|
+
# '1.2.3.4'
|
5
|
+
#
|
6
|
+
class MetasploitDataModels::IPAddress::V4::Single < MetasploitDataModels::IPAddress::V4::Segmented
|
7
|
+
#
|
8
|
+
# Segments
|
9
|
+
#
|
10
|
+
|
11
|
+
segment class_name: 'MetasploitDataModels::IPAddress::V4::Segment::Single'
|
12
|
+
|
13
|
+
#
|
14
|
+
# Instance Methods
|
15
|
+
#
|
16
|
+
|
17
|
+
# Adds `other` IPv4 address to this IPv4 address.
|
18
|
+
#
|
19
|
+
# @return [MetasploitDataModels::IPAddress::V4::Single] a new IPv4 address contain the sum of the two addresses
|
20
|
+
# segments with carries from lower to higher segments.
|
21
|
+
# @raise [TypeError] if `other` isn't the same class.
|
22
|
+
# @raise [ArgmentError] if `self` plus `other` yields an IP address greater than 255.255.255.255.
|
23
|
+
# @see succ
|
24
|
+
def +(other)
|
25
|
+
unless other.is_a? self.class
|
26
|
+
raise TypeError, "Cannot add #{other.class} to #{self.class}"
|
27
|
+
end
|
28
|
+
|
29
|
+
carry = 0
|
30
|
+
sum_segments = []
|
31
|
+
low_to_high_segments = segments.zip(other.segments).reverse
|
32
|
+
|
33
|
+
low_to_high_segments.each do |self_segment, other_segment|
|
34
|
+
segment, carry = self_segment.add_with_carry(other_segment, carry)
|
35
|
+
sum_segments.unshift segment
|
36
|
+
end
|
37
|
+
|
38
|
+
unless carry == 0
|
39
|
+
raise ArgumentError,
|
40
|
+
"#{self} + #{other} is not a valid IP address. It is #{sum_segments.join('.')} with a carry (#{carry})"
|
41
|
+
end
|
42
|
+
|
43
|
+
self.class.new(segments: sum_segments)
|
44
|
+
end
|
45
|
+
|
46
|
+
# The succeeding IPv4 address.
|
47
|
+
#
|
48
|
+
# @see #+
|
49
|
+
# @raise (see #+)
|
50
|
+
def succ
|
51
|
+
self + self.class.new(value: '0.0.0.1')
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
# {MetasploitDataModels::ModuleRun} holds the record of having launched a piece of Metasploit content.
|
2
|
+
# It has associations to {Mdm::User} for audit purposes, and makes polymorphic associations to things like
|
3
|
+
# {Mdm::Vuln} and {Mdm::Host} for flexible record keeping about activity attacking either specific vulns or just
|
4
|
+
# making mischief on specific remote targets w/out the context of a vuln or even a remote IP service.
|
5
|
+
#
|
6
|
+
# There are also associations to {Mdm::Session} for two use cases: a `spawned_session` is a
|
7
|
+
# session created by the ModuleRun. A `target_session` is a session that the ModuleRun
|
8
|
+
# is acting upon (e.g.) for running a post module.
|
9
|
+
class MetasploitDataModels::ModuleRun < ApplicationRecord
|
10
|
+
#
|
11
|
+
# Constants
|
12
|
+
#
|
13
|
+
|
14
|
+
# Marks the module as having successfully run
|
15
|
+
SUCCEED = 'succeeded'
|
16
|
+
# Marks the run as having not run successfully
|
17
|
+
FAIL = 'failed'
|
18
|
+
# Marks the module as having had a runtime error
|
19
|
+
ERROR = 'error'
|
20
|
+
# {ModuleRun} objects will be validated against these statuses
|
21
|
+
VALID_STATUSES = [SUCCEED, FAIL, ERROR]
|
22
|
+
|
23
|
+
|
24
|
+
#
|
25
|
+
# Attributes
|
26
|
+
#
|
27
|
+
|
28
|
+
# @!attribute [rw] attempted_at
|
29
|
+
# The date/time when this module was run
|
30
|
+
# @return [Datetime]
|
31
|
+
|
32
|
+
# @!attribute [rw] fail_detail
|
33
|
+
# Arbitrary information captured by the module to give in-depth reason for failure
|
34
|
+
# @return [String]
|
35
|
+
|
36
|
+
# @!attribute [rw] fail_reason
|
37
|
+
# One of the values of the constants in `Msf::Module::Failure`
|
38
|
+
# @return [String]
|
39
|
+
|
40
|
+
# @!attribute [rw] module_name
|
41
|
+
# The Msf::Module#fullname of the module being run
|
42
|
+
# @return [String]
|
43
|
+
|
44
|
+
# @!attribute [rw] port
|
45
|
+
# The port that the remote host was attacked on, if any
|
46
|
+
# @return [Fixnum]
|
47
|
+
|
48
|
+
# @!attribute [rw] proto
|
49
|
+
# The name of the protocol that the host was attacked on, if any
|
50
|
+
# @return [String]
|
51
|
+
|
52
|
+
# @!attribute [rw] session_id
|
53
|
+
# The {Mdm::Session} that this was run with, in the case of a post module. In exploit modules, this field will
|
54
|
+
# remain null.
|
55
|
+
# @return [Datetime]
|
56
|
+
|
57
|
+
# @!attribute [rw] status
|
58
|
+
# The result of running the module
|
59
|
+
# @return [String]
|
60
|
+
|
61
|
+
# @!attribute [rw] username
|
62
|
+
# The name of the user running this module
|
63
|
+
# @return [String]
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
#
|
68
|
+
# Associations
|
69
|
+
#
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
# @!attribute [rw] loots
|
74
|
+
# The sweet, sweet loot taken by this module_run
|
75
|
+
#
|
76
|
+
# @return [ActiveRecord::Relation<Mdm::Loot>]
|
77
|
+
has_many :loots,
|
78
|
+
class_name: 'Mdm::Loot',
|
79
|
+
inverse_of: :module_run
|
80
|
+
|
81
|
+
# @!attribute [rw] module_detail
|
82
|
+
# The cached module information
|
83
|
+
#
|
84
|
+
# @return [ActiveRecord::Relation<Mdm::Module::Detail>]
|
85
|
+
belongs_to :module_detail,
|
86
|
+
class_name: 'Mdm::Module::Detail',
|
87
|
+
inverse_of: :module_runs,
|
88
|
+
foreign_key: :module_fullname,
|
89
|
+
primary_key: :fullname
|
90
|
+
|
91
|
+
# @!attribute [rw] spawned_session
|
92
|
+
#
|
93
|
+
# The session created by running this module.
|
94
|
+
# Note that this is NOT the session that modules are run on.
|
95
|
+
#
|
96
|
+
# @return [Mdm::Session]
|
97
|
+
has_one :spawned_session,
|
98
|
+
class_name: 'Mdm::Session',
|
99
|
+
inverse_of: :originating_module_run
|
100
|
+
|
101
|
+
|
102
|
+
# @!attribute [rw] target_session
|
103
|
+
#
|
104
|
+
# The session this module was run on, if any.
|
105
|
+
# Note that this is NOT a session created by this module run
|
106
|
+
# of exploit modules.
|
107
|
+
#
|
108
|
+
# @return [Mdm::Session]
|
109
|
+
belongs_to :target_session,
|
110
|
+
class_name: 'Mdm::Session',
|
111
|
+
foreign_key: :session_id,
|
112
|
+
inverse_of: :target_module_runs
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
# @!attribute [rw] trackable
|
117
|
+
#
|
118
|
+
# A polymorphic association that is tracked as being related to this module run.
|
119
|
+
# {Mdm::Host} and {Mdm::Vuln} can each have {ModuleRun} objects.
|
120
|
+
#
|
121
|
+
# @return [Mdm::Host, Mdm::Vuln]
|
122
|
+
belongs_to :trackable, polymorphic: true
|
123
|
+
|
124
|
+
|
125
|
+
# @!attribute [rw] user
|
126
|
+
#
|
127
|
+
# The user that launched this module
|
128
|
+
#
|
129
|
+
# @return [Mdm::User]
|
130
|
+
belongs_to :user,
|
131
|
+
class_name: 'Mdm::User',
|
132
|
+
foreign_key: 'user_id',
|
133
|
+
inverse_of: :module_runs
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
#
|
138
|
+
#
|
139
|
+
# Validations
|
140
|
+
#
|
141
|
+
#
|
142
|
+
|
143
|
+
#
|
144
|
+
# Method Validations
|
145
|
+
#
|
146
|
+
|
147
|
+
|
148
|
+
# spawned_session is only valid for *exploit modules*
|
149
|
+
validate :no_spawned_session_for_non_exploits_except_logins
|
150
|
+
|
151
|
+
# target_session is only valid for *non-exploit modules*
|
152
|
+
validate :no_target_session_for_exploits
|
153
|
+
|
154
|
+
# Can't save without information on what module has run
|
155
|
+
validate :module_information_is_present
|
156
|
+
|
157
|
+
#
|
158
|
+
# Attribute Validations
|
159
|
+
#
|
160
|
+
|
161
|
+
# When the module was run
|
162
|
+
validates :attempted_at,
|
163
|
+
presence: true
|
164
|
+
# Result of running the module
|
165
|
+
validates :status,
|
166
|
+
inclusion: VALID_STATUSES
|
167
|
+
|
168
|
+
# Splits strings formatted like Msf::Module#fullname into components
|
169
|
+
#
|
170
|
+
# @example
|
171
|
+
# module_name = "exploit/windows/multi/mah-rad-exploit"
|
172
|
+
# module_name_components # => ["exploit","windows","multi","mah-rad-exploit"]
|
173
|
+
# @return [Array]
|
174
|
+
def module_name_components
|
175
|
+
module_fullname.split('/')
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
# Mark the object as invalid if there is no associated #module_name or {Mdm::ModuleDetail}
|
181
|
+
# @return [void]
|
182
|
+
def module_information_is_present
|
183
|
+
if module_fullname.blank?
|
184
|
+
errors.add(:base, "module_fullname cannot be blank")
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Mark the object as invalid if there is a spawned_session but the module is *not* an exploit
|
189
|
+
# and not an aux module with the word "login" in the final portion of `module_fullname`
|
190
|
+
#
|
191
|
+
# @return [void]
|
192
|
+
def no_spawned_session_for_non_exploits_except_logins
|
193
|
+
return true unless spawned_session.present?
|
194
|
+
return true if module_name_components.last.include?("login")
|
195
|
+
|
196
|
+
if module_name_components.first != 'exploit'
|
197
|
+
errors.add(:base, 'spawned_session cannot be set for non-exploit modules. Use target_session.')
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Mark the object as invalid if there is a target_session but the module is an exploit
|
202
|
+
# @return [void]
|
203
|
+
def no_target_session_for_exploits
|
204
|
+
return true unless target_session.present? # nothing to do unless target_session is set
|
205
|
+
|
206
|
+
if module_name_components.first == 'exploit'
|
207
|
+
return true if module_name_components[2] == 'local'
|
208
|
+
errors.add(:base, 'target_session cannot be set for exploit modules. Use spawned_session.')
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Searches an `inet` column in a PostgreSQL database using
|
2
|
+
# {MetasploitDataModels::IPAddress::V4::Single a standard IPv4 address},
|
3
|
+
# {MetasploitDataModels::IPAddress::V4::CIDR an IPv4 CIDR block}, or
|
4
|
+
# {MetasploitDataModels::IPAddress::V4::Range an IPv4 address range}.
|
5
|
+
class MetasploitDataModels::Search::Operation::IPAddress < Metasploit::Model::Search::Operation::Base
|
6
|
+
include MetasploitDataModels::Match::Parent
|
7
|
+
|
8
|
+
#
|
9
|
+
# Match Children
|
10
|
+
#
|
11
|
+
|
12
|
+
# in order of precedence, so simpler single IPv4 addresses are matched before the more complex ranges which may
|
13
|
+
# degenerate to equivalent formatted value
|
14
|
+
match_children_named %w{
|
15
|
+
MetasploitDataModels::IPAddress::V4::Single
|
16
|
+
MetasploitDataModels::IPAddress::V4::CIDR
|
17
|
+
MetasploitDataModels::IPAddress::V4::Range
|
18
|
+
}
|
19
|
+
|
20
|
+
#
|
21
|
+
#
|
22
|
+
# Validations
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
#
|
27
|
+
# Validation Methods
|
28
|
+
#
|
29
|
+
|
30
|
+
validate :value_valid
|
31
|
+
|
32
|
+
#
|
33
|
+
# Attribute Validations
|
34
|
+
#
|
35
|
+
|
36
|
+
validates :value,
|
37
|
+
presence: true
|
38
|
+
|
39
|
+
#
|
40
|
+
# Instance Method
|
41
|
+
#
|
42
|
+
|
43
|
+
# @param formatted_value [#to_s]
|
44
|
+
def value=(formatted_value)
|
45
|
+
@value = match_child(formatted_value) || formatted_value
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# Validates that `#value` is valid.
|
51
|
+
#
|
52
|
+
# @return [void]
|
53
|
+
def value_valid
|
54
|
+
if value.present?
|
55
|
+
unless value.respond_to?(:valid?) && value.valid?
|
56
|
+
errors.add(:value, :invalid)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Search operation on an attribute that holds a port number and is being searched with a single Integer port number.
|
2
|
+
class MetasploitDataModels::Search::Operation::Port::Number < Metasploit::Model::Search::Operation::Integer
|
3
|
+
#
|
4
|
+
# CONSTANTS
|
5
|
+
#
|
6
|
+
|
7
|
+
# The number of bits in a port number
|
8
|
+
BITS = 16
|
9
|
+
# The maximum port number
|
10
|
+
MAXIMUM = (1 << BITS) - 1
|
11
|
+
# The minimum port number
|
12
|
+
MINIMUM = 0
|
13
|
+
|
14
|
+
# The range of valid port numbers from {MINIMUM} to {MAXIMUM}, inclusive.
|
15
|
+
RANGE = (MINIMUM..MAXIMUM)
|
16
|
+
|
17
|
+
#
|
18
|
+
# Validations
|
19
|
+
#
|
20
|
+
|
21
|
+
validates :value,
|
22
|
+
inclusion: {
|
23
|
+
in: RANGE
|
24
|
+
}
|
25
|
+
end
|