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.
Files changed (440) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.github/workflows/verify.yml +68 -0
  4. data/.gitignore +29 -0
  5. data/.rspec +3 -0
  6. data/.simplecov +38 -0
  7. data/.yardopts +4 -0
  8. data/CHANGELOG.md +6 -0
  9. data/CONTRIBUTING.md +133 -0
  10. data/Gemfile +46 -0
  11. data/LICENSE +27 -0
  12. data/README.md +65 -0
  13. data/RELEASING.md +82 -0
  14. data/Rakefile +72 -0
  15. data/UPGRADING.md +1 -0
  16. data/app/models/mdm/api_key.rb +61 -0
  17. data/app/models/mdm/async_callback.rb +64 -0
  18. data/app/models/mdm/client.rb +50 -0
  19. data/app/models/mdm/cred.rb +205 -0
  20. data/app/models/mdm/event.rb +83 -0
  21. data/app/models/mdm/exploit_attempt.rb +105 -0
  22. data/app/models/mdm/exploited_host.rb +42 -0
  23. data/app/models/mdm/host.rb +619 -0
  24. data/app/models/mdm/host_detail.rb +62 -0
  25. data/app/models/mdm/host_tag.rb +49 -0
  26. data/app/models/mdm/listener.rb +82 -0
  27. data/app/models/mdm/loot.rb +161 -0
  28. data/app/models/mdm/macro.rb +62 -0
  29. data/app/models/mdm/mod_ref.rb +24 -0
  30. data/app/models/mdm/module/action.rb +33 -0
  31. data/app/models/mdm/module/arch.rb +28 -0
  32. data/app/models/mdm/module/author.rb +34 -0
  33. data/app/models/mdm/module/detail.rb +388 -0
  34. data/app/models/mdm/module/mixin.rb +31 -0
  35. data/app/models/mdm/module/platform.rb +29 -0
  36. data/app/models/mdm/module/ref.rb +42 -0
  37. data/app/models/mdm/module/target.rb +37 -0
  38. data/app/models/mdm/nexpose_console.rb +121 -0
  39. data/app/models/mdm/note.rb +125 -0
  40. data/app/models/mdm/payload.rb +103 -0
  41. data/app/models/mdm/profile.rb +45 -0
  42. data/app/models/mdm/ref.rb +48 -0
  43. data/app/models/mdm/route.rb +28 -0
  44. data/app/models/mdm/service.rb +267 -0
  45. data/app/models/mdm/session.rb +203 -0
  46. data/app/models/mdm/session_event.rb +44 -0
  47. data/app/models/mdm/tag.rb +114 -0
  48. data/app/models/mdm/task.rb +168 -0
  49. data/app/models/mdm/task_cred.rb +45 -0
  50. data/app/models/mdm/task_host.rb +41 -0
  51. data/app/models/mdm/task_service.rb +41 -0
  52. data/app/models/mdm/task_session.rb +41 -0
  53. data/app/models/mdm/user.rb +230 -0
  54. data/app/models/mdm/vuln.rb +204 -0
  55. data/app/models/mdm/vuln_attempt.rb +76 -0
  56. data/app/models/mdm/vuln_detail.rb +156 -0
  57. data/app/models/mdm/vuln_ref.rb +21 -0
  58. data/app/models/mdm/web_form.rb +53 -0
  59. data/app/models/mdm/web_page.rb +92 -0
  60. data/app/models/mdm/web_site.rb +113 -0
  61. data/app/models/mdm/web_vuln.rb +193 -0
  62. data/app/models/mdm/wmap_request.rb +101 -0
  63. data/app/models/mdm/wmap_target.rb +56 -0
  64. data/app/models/mdm/workspace.rb +286 -0
  65. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +43 -0
  66. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +71 -0
  67. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +40 -0
  68. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +29 -0
  69. data/app/models/metasploit_data_models/ip_address/v4/cidr.rb +14 -0
  70. data/app/models/metasploit_data_models/ip_address/v4/nmap.rb +14 -0
  71. data/app/models/metasploit_data_models/ip_address/v4/range.rb +12 -0
  72. data/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list.rb +125 -0
  73. data/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range.rb +12 -0
  74. data/app/models/metasploit_data_models/ip_address/v4/segment/single.rb +123 -0
  75. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +200 -0
  76. data/app/models/metasploit_data_models/ip_address/v4/single.rb +53 -0
  77. data/app/models/metasploit_data_models/module_run.rb +213 -0
  78. data/app/models/metasploit_data_models/search/operation/ip_address.rb +60 -0
  79. data/app/models/metasploit_data_models/search/operation/port/number.rb +25 -0
  80. data/app/models/metasploit_data_models/search/operation/port/range.rb +79 -0
  81. data/app/models/metasploit_data_models/search/operation/range.rb +56 -0
  82. data/app/models/metasploit_data_models/search/operator/ip_address.rb +33 -0
  83. data/app/models/metasploit_data_models/search/operator/multitext.rb +73 -0
  84. data/app/models/metasploit_data_models/search/operator/port/list.rb +67 -0
  85. data/app/models/metasploit_data_models/search/visitor/attribute.rb +17 -0
  86. data/app/models/metasploit_data_models/search/visitor/includes.rb +47 -0
  87. data/app/models/metasploit_data_models/search/visitor/joins.rb +67 -0
  88. data/app/models/metasploit_data_models/search/visitor/method.rb +16 -0
  89. data/app/models/metasploit_data_models/search/visitor/relation.rb +91 -0
  90. data/app/models/metasploit_data_models/search/visitor/where.rb +128 -0
  91. data/config/initializers/arel_helper.rb +5 -0
  92. data/config/initializers/ipaddr.rb +29 -0
  93. data/config/locales/en.yml +94 -0
  94. data/console_db.yml +9 -0
  95. data/db/migrate/000_create_tables.rb +79 -0
  96. data/db/migrate/001_add_wmap_tables.rb +35 -0
  97. data/db/migrate/002_add_workspaces.rb +36 -0
  98. data/db/migrate/003_move_notes.rb +20 -0
  99. data/db/migrate/004_add_events_table.rb +16 -0
  100. data/db/migrate/005_expand_info.rb +58 -0
  101. data/db/migrate/006_add_timestamps.rb +26 -0
  102. data/db/migrate/007_add_loots.rb +20 -0
  103. data/db/migrate/008_create_users.rb +16 -0
  104. data/db/migrate/009_add_loots_ctype.rb +10 -0
  105. data/db/migrate/010_add_alert_fields.rb +16 -0
  106. data/db/migrate/011_add_reports.rb +19 -0
  107. data/db/migrate/012_add_tasks.rb +24 -0
  108. data/db/migrate/013_add_tasks_result.rb +10 -0
  109. data/db/migrate/014_add_loots_fields.rb +12 -0
  110. data/db/migrate/015_rename_user.rb +16 -0
  111. data/db/migrate/016_add_host_purpose.rb +10 -0
  112. data/db/migrate/017_expand_info2.rb +58 -0
  113. data/db/migrate/018_add_workspace_user_info.rb +29 -0
  114. data/db/migrate/019_add_workspace_desc.rb +23 -0
  115. data/db/migrate/020_add_user_preferences.rb +11 -0
  116. data/db/migrate/021_standardize_info_and_data.rb +18 -0
  117. data/db/migrate/022_enlarge_event_info.rb +10 -0
  118. data/db/migrate/023_add_report_downloaded_at.rb +10 -0
  119. data/db/migrate/024_convert_service_info_to_text.rb +12 -0
  120. data/db/migrate/025_add_user_admin.rb +19 -0
  121. data/db/migrate/026_add_creds_table.rb +19 -0
  122. data/db/migrate/20100819123300_migrate_cred_data.rb +154 -0
  123. data/db/migrate/20100824151500_add_exploited_table.rb +16 -0
  124. data/db/migrate/20100908001428_add_owner_to_workspaces.rb +9 -0
  125. data/db/migrate/20100911122000_add_report_templates.rb +18 -0
  126. data/db/migrate/20100916151530_require_admin_flag.rb +15 -0
  127. data/db/migrate/20100916175000_add_campaigns_and_templates.rb +61 -0
  128. data/db/migrate/20100920012100_add_generate_exe_column.rb +8 -0
  129. data/db/migrate/20100926214000_add_template_prefs.rb +11 -0
  130. data/db/migrate/20101001000000_add_web_tables.rb +57 -0
  131. data/db/migrate/20101002000000_add_query.rb +10 -0
  132. data/db/migrate/20101007000000_add_vuln_info.rb +15 -0
  133. data/db/migrate/20101008111800_add_clients_to_campaigns.rb +10 -0
  134. data/db/migrate/20101009023300_add_campaign_attachments.rb +15 -0
  135. data/db/migrate/20101104135100_add_imported_creds.rb +17 -0
  136. data/db/migrate/20101203000000_fix_web_tables.rb +34 -0
  137. data/db/migrate/20101203000001_expand_host_comment.rb +12 -0
  138. data/db/migrate/20101206212033_add_limit_to_network_to_workspaces.rb +9 -0
  139. data/db/migrate/20110112154300_add_module_uuid_to_tasks.rb +9 -0
  140. data/db/migrate/20110204112800_add_host_tags.rb +28 -0
  141. data/db/migrate/20110317144932_add_session_table.rb +110 -0
  142. data/db/migrate/20110414180600_add_local_id_to_session_table.rb +11 -0
  143. data/db/migrate/20110415175705_add_routes_table.rb +18 -0
  144. data/db/migrate/20110422000000_convert_binary.rb +73 -0
  145. data/db/migrate/20110425095900_add_last_seen_to_sessions.rb +8 -0
  146. data/db/migrate/20110513143900_track_successful_exploits.rb +31 -0
  147. data/db/migrate/20110517160800_rename_and_prune_nessus_vulns.rb +26 -0
  148. data/db/migrate/20110527000000_add_task_id_to_reports_table.rb +11 -0
  149. data/db/migrate/20110527000001_add_api_keys_table.rb +12 -0
  150. data/db/migrate/20110606000001_add_macros_table.rb +16 -0
  151. data/db/migrate/20110622000000_add_settings_to_tasks_table.rb +12 -0
  152. data/db/migrate/20110624000001_add_listeners_table.rb +19 -0
  153. data/db/migrate/20110625000001_add_macro_to_listeners_table.rb +12 -0
  154. data/db/migrate/20110630000001_add_nexpose_consoles_table.rb +21 -0
  155. data/db/migrate/20110630000002_add_name_to_nexpose_consoles_table.rb +12 -0
  156. data/db/migrate/20110717000001_add_profiles_table.rb +15 -0
  157. data/db/migrate/20110727163801_expand_cred_ptype_column.rb +9 -0
  158. data/db/migrate/20110730000001_add_initial_indexes.rb +85 -0
  159. data/db/migrate/20110812000001_prune_indexes.rb +23 -0
  160. data/db/migrate/20110922000000_expand_notes.rb +9 -0
  161. data/db/migrate/20110928101300_add_mod_ref_table.rb +17 -0
  162. data/db/migrate/20111011110000_add_display_name_to_reports_table.rb +24 -0
  163. data/db/migrate/20111203000000_inet_columns.rb +13 -0
  164. data/db/migrate/20111204000000_more_inet_columns.rb +17 -0
  165. data/db/migrate/20111210000000_add_scope_to_hosts.rb +9 -0
  166. data/db/migrate/20120126110000_add_virtual_host_to_hosts.rb +9 -0
  167. data/db/migrate/20120411173220_rename_workspace_members.rb +9 -0
  168. data/db/migrate/20120601152442_add_counter_caches_to_hosts.rb +21 -0
  169. data/db/migrate/20120625000000_add_vuln_details.rb +34 -0
  170. data/db/migrate/20120625000001_add_host_details.rb +16 -0
  171. data/db/migrate/20120625000002_expand_details.rb +16 -0
  172. data/db/migrate/20120625000003_expand_details2.rb +24 -0
  173. data/db/migrate/20120625000004_add_vuln_attempts.rb +19 -0
  174. data/db/migrate/20120625000005_add_vuln_and_host_counter_caches.rb +14 -0
  175. data/db/migrate/20120625000006_add_module_details.rb +118 -0
  176. data/db/migrate/20120625000007_add_exploit_attempts.rb +26 -0
  177. data/db/migrate/20120625000008_add_fail_message.rb +12 -0
  178. data/db/migrate/20120718202805_add_owner_and_payload_to_web_vulns.rb +13 -0
  179. data/db/migrate/20130228214900_change_required_columns_to_null_false_in_web_vulns.rb +19 -0
  180. data/db/migrate/20130412154159_change_foreign_key_in_module_actions.rb +25 -0
  181. data/db/migrate/20130412171844_change_foreign_key_in_module_archs.rb +25 -0
  182. data/db/migrate/20130412173121_change_foreign_key_in_module_authors.rb +25 -0
  183. data/db/migrate/20130412173640_change_foreign_key_in_module_mixins.rb +25 -0
  184. data/db/migrate/20130412174254_change_foreign_key_in_module_platforms.rb +25 -0
  185. data/db/migrate/20130412174719_change_foreign_key_in_module_refs.rb +25 -0
  186. data/db/migrate/20130412175040_change_foreign_key_in_module_targets.rb +25 -0
  187. data/db/migrate/20130423211152_add_creds_counter_cache.rb +24 -0
  188. data/db/migrate/20130430151353_change_required_columns_to_null_false_in_hosts.rb +11 -0
  189. data/db/migrate/20130430162145_enforce_address_uniqueness_in_workspace_in_hosts.rb +101 -0
  190. data/db/migrate/20130510021637_remove_campaigns.rb +11 -0
  191. data/db/migrate/20130515164311_change_web_vulns_confidence_to_integer.rb +48 -0
  192. data/db/migrate/20130515172727_valid_mdm_web_vuln_params.rb +30 -0
  193. data/db/migrate/20130516204810_making_vulns_refs_a_real_ar_model.rb +5 -0
  194. data/db/migrate/20130522001343_create_task_creds.rb +9 -0
  195. data/db/migrate/20130522032517_create_task_hosts.rb +9 -0
  196. data/db/migrate/20130522041110_create_task_services.rb +9 -0
  197. data/db/migrate/20130525015035_remove_campaign_id_from_clients.rb +9 -0
  198. data/db/migrate/20130525212420_drop_table_imported_creds.rb +14 -0
  199. data/db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb +6 -0
  200. data/db/migrate/20130604145732_create_task_sessions.rb +9 -0
  201. data/db/migrate/20130717150737_remove_pname_validation.rb +7 -0
  202. data/db/migrate/20131002004641_create_automatic_exploitation_matches.rb +13 -0
  203. data/db/migrate/20131002164449_create_automatic_exploitation_match_sets.rb +12 -0
  204. data/db/migrate/20131008213344_create_automatic_exploitation_runs.rb +11 -0
  205. data/db/migrate/20131011184338_module_detail_on_automatic_exploitation_match.rb +10 -0
  206. data/db/migrate/20131017150735_create_automatic_exploitation_match_results.rb +11 -0
  207. data/db/migrate/20131021185657_make_match_polymorphic.rb +11 -0
  208. data/db/migrate/20140905031549_add_detected_arch_to_host.rb +5 -0
  209. data/db/migrate/20150112203945_remove_duplicate_services.rb +17 -0
  210. data/db/migrate/20150205192745_drop_service_uniqueness_index.rb +5 -0
  211. data/db/migrate/20150209195939_add_vuln_id_to_note.rb +6 -0
  212. data/db/migrate/20150212214222_remove_duplicate_services2.rb +17 -0
  213. data/db/migrate/20150219173821_create_module_runs.rb +23 -0
  214. data/db/migrate/20150219215039_add_module_run_to_session.rb +8 -0
  215. data/db/migrate/20150226151459_add_module_run_fk_to_loot.rb +8 -0
  216. data/db/migrate/20150312155312_add_module_full_name_to_match.rb +6 -0
  217. data/db/migrate/20150317145455_rename_module_indices.rb +29 -0
  218. data/db/migrate/20150326183742_add_missing_ae_indices.rb +13 -0
  219. data/db/migrate/20150421211719_rename_automatic_exploitation_index.rb +16 -0
  220. data/db/migrate/20150514182921_add_origin_to_mdm_vuln.rb +13 -0
  221. data/db/migrate/20160415153312_remove_not_null_from_web_vuln_p_arams.rb +5 -0
  222. data/db/migrate/20161004165612_add_fingerprinted_to_workspace.rb +5 -0
  223. data/db/migrate/20161227212223_add_os_family_to_hosts.rb +5 -0
  224. data/db/migrate/20180904120211_create_payloads.rb +21 -0
  225. data/db/migrate/20190308134512_create_async_callbacks.rb +13 -0
  226. data/db/migrate/20190507120211_remove_payload_workspaces.rb +5 -0
  227. data/lib/mdm/host/operating_system_normalization.rb +942 -0
  228. data/lib/mdm/module.rb +13 -0
  229. data/lib/mdm.rb +57 -0
  230. data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
  231. data/lib/metasploit_data_models/base64_serializer.rb +99 -0
  232. data/lib/metasploit_data_models/change_required_columns_to_null_false.rb +21 -0
  233. data/lib/metasploit_data_models/engine.rb +32 -0
  234. data/lib/metasploit_data_models/ip_address/cidr.rb +174 -0
  235. data/lib/metasploit_data_models/ip_address/range.rb +181 -0
  236. data/lib/metasploit_data_models/ip_address/v4/segment/nmap.rb +7 -0
  237. data/lib/metasploit_data_models/ip_address/v4/segment.rb +7 -0
  238. data/lib/metasploit_data_models/ip_address/v4.rb +11 -0
  239. data/lib/metasploit_data_models/ip_address.rb +9 -0
  240. data/lib/metasploit_data_models/match/child.rb +48 -0
  241. data/lib/metasploit_data_models/match/parent.rb +103 -0
  242. data/lib/metasploit_data_models/match.rb +8 -0
  243. data/lib/metasploit_data_models/search/operation/port.rb +9 -0
  244. data/lib/metasploit_data_models/search/operation.rb +9 -0
  245. data/lib/metasploit_data_models/search/operator/port.rb +6 -0
  246. data/lib/metasploit_data_models/search/operator.rb +8 -0
  247. data/lib/metasploit_data_models/search/visitor.rb +11 -0
  248. data/lib/metasploit_data_models/search.rb +8 -0
  249. data/lib/metasploit_data_models/serialized_prefs.rb +27 -0
  250. data/lib/metasploit_data_models/version.rb +13 -0
  251. data/lib/metasploit_data_models.rb +56 -0
  252. data/metasploit_data_models.gemspec +65 -0
  253. data/script/rails +8 -0
  254. data/spec/app/models/mdm/api_key_spec.rb +3 -0
  255. data/spec/app/models/mdm/client_spec.rb +43 -0
  256. data/spec/app/models/mdm/cred_spec.rb +346 -0
  257. data/spec/app/models/mdm/event_spec.rb +90 -0
  258. data/spec/app/models/mdm/exploit_attempt_spec.rb +59 -0
  259. data/spec/app/models/mdm/exploited_host_spec.rb +44 -0
  260. data/spec/app/models/mdm/host_detail_spec.rb +48 -0
  261. data/spec/app/models/mdm/host_spec.rb +1139 -0
  262. data/spec/app/models/mdm/host_tag_spec.rb +69 -0
  263. data/spec/app/models/mdm/listener_spec.rb +107 -0
  264. data/spec/app/models/mdm/loot_spec.rb +84 -0
  265. data/spec/app/models/mdm/macro_spec.rb +3 -0
  266. data/spec/app/models/mdm/mod_ref_spec.rb +3 -0
  267. data/spec/app/models/mdm/module/action_spec.rb +34 -0
  268. data/spec/app/models/mdm/module/arch_spec.rb +34 -0
  269. data/spec/app/models/mdm/module/author_spec.rb +52 -0
  270. data/spec/app/models/mdm/module/detail_spec.rb +746 -0
  271. data/spec/app/models/mdm/module/mixin_spec.rb +34 -0
  272. data/spec/app/models/mdm/module/platform_spec.rb +34 -0
  273. data/spec/app/models/mdm/module/ref_spec.rb +58 -0
  274. data/spec/app/models/mdm/module/target_spec.rb +36 -0
  275. data/spec/app/models/mdm/nexpose_console_spec.rb +146 -0
  276. data/spec/app/models/mdm/note_spec.rb +91 -0
  277. data/spec/app/models/mdm/profile_spec.rb +3 -0
  278. data/spec/app/models/mdm/ref_spec.rb +71 -0
  279. data/spec/app/models/mdm/route_spec.rb +35 -0
  280. data/spec/app/models/mdm/service_spec.rb +232 -0
  281. data/spec/app/models/mdm/session_event_spec.rb +42 -0
  282. data/spec/app/models/mdm/session_spec.rb +118 -0
  283. data/spec/app/models/mdm/tag_spec.rb +116 -0
  284. data/spec/app/models/mdm/task_cred_spec.rb +51 -0
  285. data/spec/app/models/mdm/task_host_spec.rb +50 -0
  286. data/spec/app/models/mdm/task_service_spec.rb +50 -0
  287. data/spec/app/models/mdm/task_session_spec.rb +46 -0
  288. data/spec/app/models/mdm/task_spec.rb +71 -0
  289. data/spec/app/models/mdm/user_spec.rb +50 -0
  290. data/spec/app/models/mdm/vuln_attempt_spec.rb +53 -0
  291. data/spec/app/models/mdm/vuln_detail_spec.rb +65 -0
  292. data/spec/app/models/mdm/vuln_ref_spec.rb +46 -0
  293. data/spec/app/models/mdm/vuln_spec.rb +299 -0
  294. data/spec/app/models/mdm/web_form_spec.rb +46 -0
  295. data/spec/app/models/mdm/web_page_spec.rb +101 -0
  296. data/spec/app/models/mdm/web_site_spec.rb +85 -0
  297. data/spec/app/models/mdm/web_vuln_spec.rb +312 -0
  298. data/spec/app/models/mdm/wmap_request_spec.rb +5 -0
  299. data/spec/app/models/mdm/wmap_target_spec.rb +5 -0
  300. data/spec/app/models/mdm/workspace_spec.rb +500 -0
  301. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +86 -0
  302. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +46 -0
  303. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +37 -0
  304. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +38 -0
  305. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +119 -0
  306. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +149 -0
  307. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +298 -0
  308. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +276 -0
  309. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +302 -0
  310. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +27 -0
  311. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +324 -0
  312. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +181 -0
  313. data/spec/app/models/metasploit_data_models/module_run_spec.rb +134 -0
  314. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +180 -0
  315. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +39 -0
  316. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +138 -0
  317. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +233 -0
  318. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +17 -0
  319. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +160 -0
  320. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +162 -0
  321. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +96 -0
  322. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +175 -0
  323. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +396 -0
  324. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +49 -0
  325. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +925 -0
  326. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +187 -0
  327. data/spec/dummy/Rakefile +7 -0
  328. data/spec/dummy/app/assets/config/manifest.js +1 -0
  329. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  330. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  331. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  332. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  333. data/spec/dummy/app/mailers/.gitkeep +0 -0
  334. data/spec/dummy/app/models/.gitkeep +0 -0
  335. data/spec/dummy/app/models/application_record.rb +3 -0
  336. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  337. data/spec/dummy/bin/bundle +3 -0
  338. data/spec/dummy/bin/rails +4 -0
  339. data/spec/dummy/bin/rake +4 -0
  340. data/spec/dummy/config/application.rb +61 -0
  341. data/spec/dummy/config/boot.rb +4 -0
  342. data/spec/dummy/config/database.yml.example +22 -0
  343. data/spec/dummy/config/database.yml.github_actions +21 -0
  344. data/spec/dummy/config/environment.rb +5 -0
  345. data/spec/dummy/config/environments/development.rb +37 -0
  346. data/spec/dummy/config/environments/production.rb +78 -0
  347. data/spec/dummy/config/environments/test.rb +39 -0
  348. data/spec/dummy/config/initializers/active_record_migrations.rb +4 -0
  349. data/spec/dummy/config/initializers/assets.rb +8 -0
  350. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  351. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  352. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  353. data/spec/dummy/config/initializers/inflections.rb +16 -0
  354. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  355. data/spec/dummy/config/initializers/session_store.rb +3 -0
  356. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  357. data/spec/dummy/config/locales/en.yml +23 -0
  358. data/spec/dummy/config/routes.rb +2 -0
  359. data/spec/dummy/config.ru +4 -0
  360. data/spec/dummy/db/structure.sql +3430 -0
  361. data/spec/dummy/db/structure.sql.from_rails_3 +3403 -0
  362. data/spec/dummy/lib/assets/.gitkeep +0 -0
  363. data/spec/dummy/log/.gitkeep +0 -0
  364. data/spec/dummy/public/404.html +26 -0
  365. data/spec/dummy/public/422.html +26 -0
  366. data/spec/dummy/public/500.html +25 -0
  367. data/spec/dummy/public/favicon.ico +0 -0
  368. data/spec/dummy/script/rails +6 -0
  369. data/spec/factories/mdm/addresses.rb +12 -0
  370. data/spec/factories/mdm/clients.rb +8 -0
  371. data/spec/factories/mdm/creds.rb +17 -0
  372. data/spec/factories/mdm/events.rb +15 -0
  373. data/spec/factories/mdm/exploit_attempts.rb +8 -0
  374. data/spec/factories/mdm/exploited_hosts.rb +7 -0
  375. data/spec/factories/mdm/fingerprints/nessus_fingerprints.rb +6 -0
  376. data/spec/factories/mdm/fingerprints/nexpose_fingerprints.rb +6 -0
  377. data/spec/factories/mdm/fingerprints/nmap_fingerprints.rb +6 -0
  378. data/spec/factories/mdm/fingerprints/retina_fingerprints.rb +6 -0
  379. data/spec/factories/mdm/fingerprints/session_fingerprints.rb +6 -0
  380. data/spec/factories/mdm/host_details.rb +8 -0
  381. data/spec/factories/mdm/host_tags.rb +9 -0
  382. data/spec/factories/mdm/hosts.rb +85 -0
  383. data/spec/factories/mdm/listeners.rb +12 -0
  384. data/spec/factories/mdm/loots.rb +11 -0
  385. data/spec/factories/mdm/module/actions.rb +14 -0
  386. data/spec/factories/mdm/module/archs.rb +14 -0
  387. data/spec/factories/mdm/module/authors.rb +22 -0
  388. data/spec/factories/mdm/module/details.rb +73 -0
  389. data/spec/factories/mdm/module/mixins.rb +14 -0
  390. data/spec/factories/mdm/module/platforms.rb +14 -0
  391. data/spec/factories/mdm/module/refs.rb +14 -0
  392. data/spec/factories/mdm/module/targets.rb +19 -0
  393. data/spec/factories/mdm/nexpose_consoles.rb +15 -0
  394. data/spec/factories/mdm/notes.rb +12 -0
  395. data/spec/factories/mdm/refs.rb +9 -0
  396. data/spec/factories/mdm/routes.rb +36 -0
  397. data/spec/factories/mdm/services.rb +41 -0
  398. data/spec/factories/mdm/session_events.rb +8 -0
  399. data/spec/factories/mdm/sessions.rb +13 -0
  400. data/spec/factories/mdm/tags.rb +14 -0
  401. data/spec/factories/mdm/task.rb +16 -0
  402. data/spec/factories/mdm/task_creds.rb +9 -0
  403. data/spec/factories/mdm/task_hosts.rb +9 -0
  404. data/spec/factories/mdm/task_services.rb +8 -0
  405. data/spec/factories/mdm/task_sessions.rb +8 -0
  406. data/spec/factories/mdm/users.rb +22 -0
  407. data/spec/factories/mdm/vuln_attempts.rb +8 -0
  408. data/spec/factories/mdm/vuln_details.rb +8 -0
  409. data/spec/factories/mdm/vuln_refs.rb +4 -0
  410. data/spec/factories/mdm/vulns.rb +20 -0
  411. data/spec/factories/mdm/web_forms.rb +33 -0
  412. data/spec/factories/mdm/web_pages.rb +64 -0
  413. data/spec/factories/mdm/web_sites.rb +8 -0
  414. data/spec/factories/mdm/web_vulns.rb +64 -0
  415. data/spec/factories/mdm/workspaces.rb +23 -0
  416. data/spec/factories/metasploit_data_models/automatic_exploitation/match_results.rb +7 -0
  417. data/spec/factories/metasploit_data_models/automatic_exploitation/match_sets.rb +8 -0
  418. data/spec/factories/metasploit_data_models/automatic_exploitation/matches.rb +7 -0
  419. data/spec/factories/metasploit_data_models/automatic_exploitation/runs.rb +6 -0
  420. data/spec/factories/module_runs.rb +40 -0
  421. data/spec/lib/base64_serializer_spec.rb +172 -0
  422. data/spec/lib/ipaddr_spec.rb +29 -0
  423. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +356 -0
  424. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +75 -0
  425. data/spec/lib/metasploit_data_models/match/child_spec.rb +59 -0
  426. data/spec/lib/metasploit_data_models/match/parent_spec.rb +153 -0
  427. data/spec/lib/metasploit_data_models_spec.rb +13 -0
  428. data/spec/spec_helper.rb +148 -0
  429. data/spec/support/matchers/match_regex_exactly.rb +28 -0
  430. data/spec/support/shared/contexts/rex/text.rb +15 -0
  431. data/spec/support/shared/examples/coerces_inet_column_type_to_string.rb +15 -0
  432. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +20 -0
  433. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +36 -0
  434. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +109 -0
  435. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +38 -0
  436. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +26 -0
  437. data/spec/support/shared/examples/metasploit_data_models/search/visitor/relation/visit/matching_record.rb +50 -0
  438. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +34 -0
  439. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +51 -0
  440. metadata +444 -6
@@ -0,0 +1,388 @@
1
+ # Details about an Msf::Module. Metadata that can be an array is stored in associations in modules under the
2
+ # {Mdm::Module} namespace.
3
+ class Mdm::Module::Detail < ApplicationRecord
4
+ self.table_name = 'module_details'
5
+
6
+ #
7
+ # CONSTANTS
8
+ #
9
+
10
+ # The directory for a given {#mtype} is a not always the pluralization of {#mtype}, so this maps the {#mtype} to the
11
+ # type directory that is used to generate the {#file} from the {#mtype} and {#refname}.
12
+ DIRECTORY_BY_TYPE = {
13
+ 'auxiliary' => 'auxiliary',
14
+ 'encoder' => 'encoders',
15
+ 'exploit' => 'exploits',
16
+ 'nop' => 'nops',
17
+ 'payload' => 'payloads',
18
+ 'post' => 'post',
19
+ 'evasion' => 'evasion'
20
+ }
21
+
22
+ # {#privileged} is Boolean so, valid values are just `true` and `false`, but since both the validation and
23
+ # factory need an array of valid values, this constant exists.
24
+ PRIVILEGES = [
25
+ false,
26
+ true
27
+ ]
28
+
29
+ # Converts {#rank}, which is an Integer, to the name used for that rank.
30
+ RANK_BY_NAME = {
31
+ 'Manual' => 0,
32
+ 'Low' => 100,
33
+ 'Average' => 200,
34
+ 'Normal' => 300,
35
+ 'Good' => 400,
36
+ 'Great' => 500,
37
+ 'Excellent' => 600
38
+ }
39
+
40
+ # Valid values for {#stance}.
41
+ STANCES = [
42
+ 'aggressive',
43
+ 'passive'
44
+ ]
45
+
46
+ #
47
+ # Associations
48
+ #
49
+
50
+ # @!attribute [rw] actions
51
+ # Auxiliary actions to perform when this running this module.
52
+ #
53
+ # @return [ActiveRecord::Relation<Mdm::Module::Action>]
54
+ has_many :actions, :class_name => 'Mdm::Module::Action', :dependent => :destroy
55
+
56
+ # @!attribute [rw] archs
57
+ # Architectures supported by this module.
58
+ #
59
+ # @return [ActiveRecord::Relation<Mdm::Module::Arch>]
60
+ has_many :archs, :class_name => 'Mdm::Module::Arch', :dependent => :destroy
61
+
62
+ # @!attribute [rw] authors
63
+ # Authors (and their emails) of this module. Usually includes the original discoverer who wrote the
64
+ # proof-of-concept and then the people that ported the proof-of-concept to metasploit-framework.
65
+ #
66
+ # @return [ActiveRecord::Relation<Mdm::Module::Mixin>]
67
+ has_many :authors, :class_name => 'Mdm::Module::Author', :dependent => :destroy
68
+
69
+ # @!attribute [rw] matches
70
+ # Matches for this module
71
+ #
72
+ # @return [ActiveRecord::Relation<MetasploitDataModels::AutomaticExploitation::Match>]
73
+ has_many :matches,
74
+ :class_name => 'MetasploitDataModels::AutomaticExploitation::Match',
75
+ :primary_key => :fullname,
76
+ :foreign_key => :module_fullname,
77
+ :inverse_of => :module_detail
78
+
79
+ # @!attribute [rw] mixins
80
+ # Mixins used by this module.
81
+ #
82
+ # @return [ActiveRecord::Relation<Mdm::Module::Mixin>]
83
+ has_many :mixins, :class_name => 'Mdm::Module::Mixin', :dependent => :destroy
84
+
85
+ # @!attribute [rw] module_runs
86
+ # Records of times when this module has been used
87
+ #
88
+ # @return [ActiveRecord::Relation<MetasploitDataModels::ModuleRun>]
89
+ has_many :module_runs,
90
+ :class_name => 'MetasploitDataModels::ModuleRun',
91
+ :primary_key => :fullname,
92
+ :foreign_key => :module_fullname,
93
+ :inverse_of => :module_detail
94
+
95
+ # @!attribute [rw] platforms
96
+ # Platforms supported by this module.
97
+ #
98
+ # @return [ActiveRecord::Relation<Mdm::Module::Platform>]
99
+ has_many :platforms, :class_name => 'Mdm::Module::Platform', :dependent => :destroy
100
+
101
+ # @!attribute [rw] refs
102
+ # External references to the vulnerabilities this module exploits.
103
+ #
104
+ # @return [ActiveRecord::Relation<Mdm::Module::Ref>]
105
+ has_many :refs, :class_name => 'Mdm::Module::Ref', :dependent => :destroy
106
+
107
+ # @!attribute [rw] targets
108
+ # Names of targets with different configurations that can be exploited by this module.
109
+ #
110
+ # @return [ActiveRecord::Relation<Mdm::Module::Target>]
111
+ has_many :targets, :class_name => 'Mdm::Module::Target', :dependent => :destroy
112
+
113
+ #
114
+ # Attributes
115
+ #
116
+
117
+ # @!attribute [rw] default_action
118
+ # Name of the default action in {#actions}.
119
+ #
120
+ # @return [String] {Mdm::Module::Action#name}.
121
+
122
+ # @!attribute [rw] default_target
123
+ # Name of the default target in {#targets}.
124
+ #
125
+ # @return [String] {Mdm::Module::Target#name}.
126
+
127
+ # @!attribute [rw] description
128
+ # A long, paragraph description of what the module does.
129
+ #
130
+ # @return [String]
131
+
132
+ # @!attribute [rw] disclosure_date
133
+ # The date the vulnerability exploited by this module was disclosed to the public.
134
+ #
135
+ # @return [DateTime]
136
+
137
+ # @!attribute [rw] file
138
+ # The full path to the module file on-disk.
139
+ #
140
+ # @return [String]
141
+
142
+ # @!attribute [rw] fullname
143
+ # The full name of the module. The full name is "{#mtype}/{#refname}".
144
+ #
145
+ # @return [String]
146
+
147
+ # @!attribute [rw] license
148
+ # The name of the software license for the module's code.
149
+ #
150
+ # @return [String]
151
+
152
+ # @!attribute [rw] mtime
153
+ # The modification time of the module file on-disk.
154
+ #
155
+ # @return [DateTime]
156
+
157
+ # @!attribute [rw] mtype
158
+ # The type of the module.
159
+ #
160
+ # @return [String] key in {DIRECTORY_BY_TYPE}
161
+
162
+ # @!attribute [rw] name
163
+ # The human readable name of the module. It is unrelated to {#fullname} or {#refname} and is better thought of
164
+ # as a short summary of the {#description}.
165
+ #
166
+ # @return [String]
167
+
168
+ # @!attribute [rw] privileged
169
+ # Whether this module requires priveleged access to run.
170
+ #
171
+ # @return [Boolean]
172
+
173
+ # @!attribute [rw] rank
174
+ # The reliability of the module and likelyhood that the module won't knock over the service or host being exploited.
175
+ # Bigger values is better.
176
+ #
177
+ # @return [Integer]
178
+
179
+ # @!attribute [rw] ready
180
+ # Boolean indicating whether the metadata for the module has been updated from the on-disk module.
181
+ #
182
+ # @return [false] if the associations are still being updated.
183
+ # @return [true] if this detail and its associations are up-to-date.
184
+
185
+ # @!attribute [rw] refname
186
+ # The reference name of the module.
187
+ #
188
+ # @return [String]
189
+
190
+ # @!attribute [rw] stance
191
+ # Whether the module is active or passive. `nil` if the {#mtype module type} does not
192
+ # {#supports_stance? support stances}.
193
+ #
194
+ # @return ['active', 'passive', nil]
195
+
196
+ #
197
+ # Scopes
198
+ #
199
+
200
+ scope :module_arch, ->(values) {
201
+ joins(Mdm::Module::Detail.join_association(:archs,Arel::Nodes::OuterJoin)).
202
+ where(Mdm::Module::Arch[:name].matches_any(values))
203
+ }
204
+
205
+ scope :module_author, ->(values) {
206
+ joins(Mdm::Module::Detail.join_association(:authors, Arel::Nodes::OuterJoin)).
207
+ where(
208
+ Mdm::Module::Author[:email].matches_any(values).or(
209
+ Mdm::Module::Author[:name].matches_any(values)
210
+ )
211
+ )
212
+ }
213
+
214
+ scope :module_name, ->(values) {
215
+ where(
216
+ Mdm::Module::Detail[:fullname].matches_any(values).or(
217
+ Mdm::Module::Detail[:name].matches_any(values)
218
+ )
219
+ )
220
+ }
221
+
222
+ scope :module_os_or_platform, ->(values) {
223
+ joins(
224
+ Mdm::Module::Detail.join_association(:platforms, Arel::Nodes::OuterJoin),
225
+ Mdm::Module::Detail.join_association(:targets, Arel::Nodes::OuterJoin)
226
+ ).where(
227
+ Mdm::Module::Platform[:name].matches_any(values).or(
228
+ Mdm::Module::Target[:name].matches_any(values)
229
+ )
230
+ )
231
+ }
232
+
233
+ scope :module_ref, ->(values) {
234
+ joins(Mdm::Module::Detail.join_association(:refs, Arel::Nodes::OuterJoin)).
235
+ where(Mdm::Module::Ref[:name].matches_any(values))
236
+ }
237
+
238
+ scope :module_stance, ->(values) { where(Mdm::Module::Detail[:stance].matches_any(values)) }
239
+
240
+ scope :module_text, ->(values) {
241
+ joins(
242
+ Mdm::Module::Detail.join_association(:actions, Arel::Nodes::OuterJoin),
243
+ Mdm::Module::Detail.join_association(:archs, Arel::Nodes::OuterJoin),
244
+ Mdm::Module::Detail.join_association(:authors, Arel::Nodes::OuterJoin),
245
+ Mdm::Module::Detail.join_association(:platforms, Arel::Nodes::OuterJoin),
246
+ Mdm::Module::Detail.join_association(:refs, Arel::Nodes::OuterJoin),
247
+ Mdm::Module::Detail.join_association(:targets, Arel::Nodes::OuterJoin)
248
+ ).where(
249
+ Mdm::Module::Detail[:description].matches_any(values).or(
250
+ Mdm::Module::Detail[:fullname].matches_any(values).or(
251
+ Mdm::Module::Detail[:name].matches_any(values).or(
252
+ Mdm::Module::Action[:name].matches_any(values).or(
253
+ Mdm::Module::Arch[:name].matches_any(values).or(
254
+ Mdm::Module::Author[:name].matches_any(values).or(
255
+ Mdm::Module::Platform[:name].matches_any(values).or(
256
+ Mdm::Module::Ref[:name].matches_any(values).or(
257
+ Mdm::Module::Target[:name].matches_any(values)
258
+ )))))))))
259
+ }
260
+
261
+
262
+ scope :module_type, ->(values) { where(Mdm::Module::Detail[:mtype].matches_any(values)) }
263
+
264
+ #
265
+ # Validations
266
+ #
267
+
268
+ validates :mtype,
269
+ :inclusion => {
270
+ :in => DIRECTORY_BY_TYPE.keys
271
+ }
272
+ validates :privileged,
273
+ :inclusion => {
274
+ :in => PRIVILEGES
275
+ }
276
+ validates :rank,
277
+ :inclusion => {
278
+ :in => RANK_BY_NAME.values
279
+ },
280
+ :numericality => {
281
+ :only_integer => true
282
+ }
283
+ validates :refname, :presence => true
284
+ validates :stance,
285
+ :inclusion => {
286
+ :if => :supports_stance?,
287
+ :in => STANCES
288
+ }
289
+
290
+ validates_associated :actions
291
+ validates_associated :archs
292
+ validates_associated :authors
293
+ validates_associated :mixins
294
+ validates_associated :platforms
295
+ validates_associated :refs
296
+ validates_associated :targets
297
+
298
+ # Adds an {Mdm::Module::Action} with the given {Mdm::Module::Action#name} to {#actions} and immediately saves it to
299
+ # the database.
300
+ #
301
+ # @param name [String] {Mdm::Module::Action#name}.
302
+ # @return [true] if save was successful.
303
+ # @return [false] if save was unsucessful.
304
+ def add_action(name)
305
+ self.actions.build(:name => name).save
306
+ end
307
+
308
+ # Adds an {Mdm::Module::Arch} with the given {Mdm::Module::Arch#name} to {#archs} and immediately saves it to the
309
+ # database.
310
+ #
311
+ # @param name [String] {Mdm::Module::Arch#name}.
312
+ # @return [true] if save was successful.
313
+ # @return [false] if save was unsuccessful.
314
+ def add_arch(name)
315
+ self.archs.build(:name => name).save
316
+ end
317
+
318
+ # Adds an {Mdm::Module::Author} with the given {Mdm::Module::Author#name} and {Mdm::Module::Author#email} to
319
+ # {#authors} and immediately saves it to the database.
320
+ #
321
+ # @param name [String] {Mdm::Module::Author#name}.
322
+ # @param email [String] {Mdm::Module::Author#email}.
323
+ # @return [true] if save was successful.
324
+ # @return [false] if save was unsuccessful.
325
+ def add_author(name, email=nil)
326
+ self.authors.build(:name => name, :email => email).save
327
+ end
328
+
329
+ # Adds an {Mdm::Module::Mixin} with the given {Mdm::Module::Mixin#name} to {#mixins} and immediately saves it to the
330
+ # database.
331
+ #
332
+ # @param name [String] {Mdm::Module::Mixin#name}.
333
+ # @return [true] if save was successful.
334
+ # @return [false] if save was unsuccessful.
335
+ def add_mixin(name)
336
+ self.mixins.build(:name => name).save
337
+ end
338
+
339
+ # Adds an {Mdm::Module::Platform} with the given {Mdm::Module::Platform#name} to {#platforms} and immediately saves it
340
+ # to the database.
341
+ #
342
+ # @param name [String] {Mdm::Module::Platform#name}.
343
+ # @return [true] if save was successful.
344
+ # @return [false] if save was unsuccessful.
345
+ def add_platform(name)
346
+ self.platforms.build(:name => name).save
347
+ end
348
+
349
+ # Adds an {Mdm::Module::Ref} with the given {Mdm::Module::Ref#name} to {#refs} and immediately saves it to the
350
+ # database.
351
+ #
352
+ # @param name [String] {Mdm::Module::Ref#name}.
353
+ # @return [true] if save was successful.
354
+ # @return [false] if save was unsuccessful.
355
+ def add_ref(name)
356
+ self.refs.build(:name => name).save
357
+ end
358
+
359
+ # Adds an {Mdm::Module::Target} with the given {Mdm::Module::Target#index} and {Mdm::Module::Target#name} to
360
+ # {#targets} and immediately saves it to the database.
361
+ #
362
+ # @param index [Integer] index of target among other {#targets}.
363
+ # @param name [String] {Mdm::Module::Target#name}.
364
+ # @return [true] if save was successful.
365
+ # @return [false] if save was unsuccessful.
366
+ def add_target(index, name)
367
+ self.targets.build(:index => index, :name => name).save
368
+ end
369
+
370
+ # Returns whether this module supports a {#stance}. Only modules with {#mtype} `'auxiliary'` and `'exploit'` support
371
+ # a non-nil {#stance}.
372
+ #
373
+ # @return [true] if {#mtype} is `'auxiliary'` or `'exploit'`
374
+ # @return [false] otherwise
375
+ # @see https://github.com/rapid7/metasploit-framework/blob/a6070f8584ad9e48918b18c7e765d85f549cb7fd/lib/msf/core/db_manager.rb#L423
376
+ # @see https://github.com/rapid7/metasploit-framework/blob/a6070f8584ad9e48918b18c7e765d85f549cb7fd/lib/msf/core/db_manager.rb#L436
377
+ def supports_stance?
378
+ supports_stance = false
379
+
380
+ if ['auxiliary', 'exploit'].include? mtype
381
+ supports_stance = true
382
+ end
383
+
384
+ supports_stance
385
+ end
386
+
387
+ Metasploit::Concern.run(self)
388
+ end
@@ -0,0 +1,31 @@
1
+ # @deprecated Never populated by metasploit-framework.
2
+ #
3
+ # Module mixed into a {#detail Metasploit Module}.
4
+ class Mdm::Module::Mixin < ApplicationRecord
5
+ self.table_name = 'module_mixins'
6
+
7
+ #
8
+ # Associations
9
+ #
10
+
11
+ # Metasploit Module the {#name named} `Module` was mixed in.
12
+ belongs_to :detail, :class_name => 'Mdm::Module::Detail'
13
+
14
+ #
15
+ # Attributes
16
+ #
17
+
18
+ # @!attribute name
19
+ # The `Module#name` of the mixed in `Module`.
20
+ #
21
+ # @return [String]
22
+
23
+ #
24
+ # Validation
25
+ #
26
+
27
+ validates :detail, :presence => true
28
+ validates :name, :presence => true
29
+
30
+ Metasploit::Concern.run(self)
31
+ end
@@ -0,0 +1,29 @@
1
+ # {#name Platform} on which the {#detail Metasploit Module} can run.
2
+ class Mdm::Module::Platform < ApplicationRecord
3
+ self.table_name = 'module_platforms'
4
+
5
+ #
6
+ # Associations
7
+ #
8
+
9
+ # The Metasploit Module that can run on the {#name named} platform.
10
+ belongs_to :detail, :class_name => 'Mdm::Module::Detail'
11
+
12
+ #
13
+ # Attributes
14
+ #
15
+
16
+ # @!attribute name
17
+ # The name of the platform.
18
+ #
19
+ # @return [String]
20
+
21
+ #
22
+ # Validations
23
+ #
24
+
25
+ validates :detail, :presence => true
26
+ validates :name, :presence => true
27
+
28
+ Metasploit::Concern.run(self)
29
+ end
@@ -0,0 +1,42 @@
1
+ # External references to the vulnerability exploited by this module.
2
+ class Mdm::Module::Ref < ApplicationRecord
3
+ self.table_name = 'module_refs'
4
+
5
+ #
6
+ # Associations
7
+ #
8
+
9
+ # @!attribute [rw] detail
10
+ # The root of the module metadata tree.
11
+ #
12
+ # @return [Mdm::Module::Detail]
13
+ belongs_to :detail, :class_name => 'Mdm::Module::Detail'
14
+
15
+ # @!attribute [r] refs
16
+ # References with the same name attached to {Mdm::Vuln Mdm::Vulns}.
17
+ #
18
+ # @return [Array<Mdm::Ref>]
19
+ has_many :refs,
20
+ :class_name => 'Mdm::Ref',
21
+ :foreign_key => :name,
22
+ :primary_key => :name
23
+
24
+ #
25
+ # Attributes
26
+ #
27
+
28
+ # @!attribute [rw] name
29
+ # Designation for external reference. May include a prefix for the authority, such as 'CVE-', in which case the
30
+ # rest of the name is the designation assigned by that authority.
31
+ #
32
+ # @return [String]
33
+
34
+ #
35
+ # Validations
36
+ #
37
+
38
+ validates :detail, :presence => true
39
+ validates :name, :presence => true
40
+
41
+ Metasploit::Concern.run(self)
42
+ end
@@ -0,0 +1,37 @@
1
+ # A potential target for a {Mdm::Module::Detail exploit Metasploit Module}. Targets can change options including
2
+ # offsets for ROP chains to tune an exploit to work with different system libraries and versions.
3
+ class Mdm::Module::Target < ApplicationRecord
4
+ self.table_name = 'module_targets'
5
+
6
+ #
7
+ # Associations
8
+ #
9
+
10
+ # Exploit Metasploit Module with the {#name named} target at the given {#index}.
11
+ belongs_to :detail, :class_name => 'Mdm::Module::Detail'
12
+
13
+ #
14
+ # Attributes
15
+ #
16
+
17
+ # @!attribute index
18
+ # The index of this target in the {#detail exploit Metasploit Module}'s list of targets. The index is used for
19
+ # target selection.
20
+ #
21
+ # @return [Integer]
22
+
23
+ # @!attribute name
24
+ # The name of this target.
25
+ #
26
+ # @return [String]
27
+
28
+ #
29
+ # Validators
30
+ #
31
+
32
+ validates :detail, :presence => true
33
+ validates :index, :presence => true
34
+ validates :name, :presence => true
35
+
36
+ Metasploit::Concern.run(self)
37
+ end
@@ -0,0 +1,121 @@
1
+ # A connection to Nexpose from Metasploit.
2
+ class Mdm::NexposeConsole < ApplicationRecord
3
+ #
4
+ # Associations
5
+ #
6
+
7
+ # Details for vulnerabilities supplied by this Nexpose console.
8
+ has_many :vuln_details,
9
+ class_name: 'Mdm::VulnDetail',
10
+ foreign_key: :nx_console_id,
11
+ inverse_of: :nexpose_console
12
+
13
+ #
14
+ # Attributes
15
+ #
16
+
17
+ # @!attribute address
18
+ # Address on which Nexpose is running.
19
+ #
20
+ # @return [String]
21
+
22
+ # @!attribute cert
23
+ # @return [String]
24
+
25
+ # @!attribute created_at
26
+ # When this Nexpose console was created.
27
+ #
28
+ # @return [DateTime]
29
+
30
+ # @!attribute enabled
31
+ # Whether metasploit tried to connect to this Nexpose console.
32
+ #
33
+ # @return [false] is not allowed to connect.
34
+ # @return [true] is allowed to connect.
35
+
36
+ # @!attribute name
37
+ # Name of this Nexpose console to differentiate from other Nexpose consoles.
38
+ #
39
+ # @return [String]
40
+
41
+ # @!attribute owner
42
+ # {Mdm::User#username Name of user} that setup this console.
43
+ #
44
+ # @return [String]
45
+ # @todo https://www.pivotaltracker.com/story/show/52413415
46
+
47
+ # @!attribute password
48
+ # Password used to authenticate to Nexpose.
49
+ #
50
+ # @return [String]
51
+ # @todo https://www.pivotaltracker.com/story/show/52414551
52
+
53
+ # @!attribute port
54
+ # Port on {#address} that Nexpose is running.
55
+ #
56
+ # @return [Integer]
57
+
58
+ # @!attribute status
59
+ # Status of the connection to Nexpose.
60
+ #
61
+ # @return [String]
62
+
63
+ # @!attribute updated_at
64
+ # The last time this Nexpose console was updated.
65
+ #
66
+ # @return [DateTime]
67
+
68
+ # @!attribute username
69
+ # Username used to authenticate to Nexpose.
70
+ #
71
+ # @return [String]
72
+
73
+ # @!attribute version
74
+ # The version of Nexpose. Used to handle protocol difference in different versions of Nexpose.
75
+ #
76
+ # @return [String]
77
+
78
+ #
79
+ # Callbacks
80
+ #
81
+
82
+ before_validation :strip_protocol
83
+
84
+ #
85
+ # Serializations
86
+ #
87
+
88
+ # @!attribute [rw] cached_sites
89
+ # List of sites known to Nexpose.
90
+ #
91
+ # @return [Array<String>] Array of site names.
92
+ serialize :cached_sites, MetasploitDataModels::Base64Serializer.new
93
+
94
+ #
95
+ # Validations
96
+ #
97
+
98
+ validates :address, :presence => true, :address_format => true
99
+
100
+ validates :name, :presence => true
101
+
102
+ validates :password, :presence => true
103
+
104
+ validates :port, :numericality => { :only_integer => true }, :inclusion => {:in => 1..65535}
105
+
106
+ validates :username, :presence => true
107
+
108
+ #
109
+ # Instance Methdos
110
+ #
111
+
112
+ # Strips '`http://`' or `'https://'` from {#address}.
113
+ #
114
+ # @return [void]
115
+ def strip_protocol
116
+ self.address.gsub!(/^http(s)*:\/\//i,'') unless self.address.nil?
117
+ end
118
+
119
+ Metasploit::Concern.run(self)
120
+ end
121
+