metasploit-model 0.28.0-java → 0.29.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/config/locales/en.yml +0 -171
  4. data/lib/metasploit/model.rb +0 -2
  5. data/lib/metasploit/model/spec.rb +0 -130
  6. data/lib/metasploit/model/version.rb +1 -1
  7. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +4 -6
  8. data/spec/support/shared/examples/metasploit/model/translation.rb +1 -1
  9. data/spec/support/shared/examples/search_association.rb +1 -1
  10. data/spec/support/shared/examples/search_with.rb +4 -2
  11. metadata +2 -348
  12. data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -125
  13. data/app/models/metasploit/model/module/class/spec/template.rb +0 -92
  14. data/app/models/metasploit/model/module/instance/spec/template.rb +0 -97
  15. data/app/models/metasploit/model/spec/template.rb +0 -277
  16. data/app/validators/derivation_validator.rb +0 -17
  17. data/app/validators/dynamic_length_validator.rb +0 -45
  18. data/lib/metasploit/model/architecture.rb +0 -342
  19. data/lib/metasploit/model/author.rb +0 -54
  20. data/lib/metasploit/model/authority.rb +0 -141
  21. data/lib/metasploit/model/authority/bid.rb +0 -10
  22. data/lib/metasploit/model/authority/cve.rb +0 -10
  23. data/lib/metasploit/model/authority/msb.rb +0 -10
  24. data/lib/metasploit/model/authority/osvdb.rb +0 -10
  25. data/lib/metasploit/model/authority/pmasa.rb +0 -10
  26. data/lib/metasploit/model/authority/secunia.rb +0 -10
  27. data/lib/metasploit/model/authority/us_cert_vu.rb +0 -10
  28. data/lib/metasploit/model/authority/waraxe.rb +0 -31
  29. data/lib/metasploit/model/authority/zdi.rb +0 -10
  30. data/lib/metasploit/model/derivation.rb +0 -109
  31. data/lib/metasploit/model/derivation/full_name.rb +0 -19
  32. data/lib/metasploit/model/email_address.rb +0 -124
  33. data/lib/metasploit/model/module.rb +0 -20
  34. data/lib/metasploit/model/module/action.rb +0 -52
  35. data/lib/metasploit/model/module/ancestor.rb +0 -491
  36. data/lib/metasploit/model/module/ancestor/spec.rb +0 -6
  37. data/lib/metasploit/model/module/architecture.rb +0 -34
  38. data/lib/metasploit/model/module/author.rb +0 -40
  39. data/lib/metasploit/model/module/class.rb +0 -403
  40. data/lib/metasploit/model/module/class/spec.rb +0 -6
  41. data/lib/metasploit/model/module/handler.rb +0 -29
  42. data/lib/metasploit/model/module/instance.rb +0 -622
  43. data/lib/metasploit/model/module/instance/spec.rb +0 -6
  44. data/lib/metasploit/model/module/path.rb +0 -159
  45. data/lib/metasploit/model/module/platform.rb +0 -32
  46. data/lib/metasploit/model/module/rank.rb +0 -85
  47. data/lib/metasploit/model/module/reference.rb +0 -32
  48. data/lib/metasploit/model/module/stance.rb +0 -16
  49. data/lib/metasploit/model/module/target.rb +0 -78
  50. data/lib/metasploit/model/module/target/architecture.rb +0 -34
  51. data/lib/metasploit/model/module/target/platform.rb +0 -34
  52. data/lib/metasploit/model/module/type.rb +0 -38
  53. data/lib/metasploit/model/platform.rb +0 -246
  54. data/lib/metasploit/model/real_pathname.rb +0 -16
  55. data/lib/metasploit/model/reference.rb +0 -104
  56. data/spec/app/models/metasploit/model/module/ancestor/spec/template_spec.rb +0 -174
  57. data/spec/app/models/metasploit/model/module/class/spec/template_spec.rb +0 -222
  58. data/spec/app/models/metasploit/model/module/instance/spec/template_spec.rb +0 -201
  59. data/spec/app/models/metasploit/model/search/operator/deprecated/app_spec.rb +0 -62
  60. data/spec/app/models/metasploit/model/search/operator/deprecated/author_spec.rb +0 -197
  61. data/spec/app/models/metasploit/model/search/operator/deprecated/authority_spec.rb +0 -135
  62. data/spec/app/models/metasploit/model/search/operator/deprecated/platform_spec.rb +0 -124
  63. data/spec/app/models/metasploit/model/search/operator/deprecated/ref_spec.rb +0 -387
  64. data/spec/app/models/metasploit/model/search/operator/deprecated/text_spec.rb +0 -399
  65. data/spec/app/models/metasploit/model/spec/template_spec.rb +0 -23
  66. data/spec/app/validators/derivation_validator_spec.rb +0 -92
  67. data/spec/app/validators/dynamic_length_validator_spec.rb +0 -293
  68. data/spec/dummy/app/models/dummy/architecture.rb +0 -92
  69. data/spec/dummy/app/models/dummy/author.rb +0 -15
  70. data/spec/dummy/app/models/dummy/authority.rb +0 -130
  71. data/spec/dummy/app/models/dummy/email_address.rb +0 -27
  72. data/spec/dummy/app/models/dummy/module/action.rb +0 -25
  73. data/spec/dummy/app/models/dummy/module/ancestor.rb +0 -67
  74. data/spec/dummy/app/models/dummy/module/architecture.rb +0 -19
  75. data/spec/dummy/app/models/dummy/module/author.rb +0 -28
  76. data/spec/dummy/app/models/dummy/module/class.rb +0 -69
  77. data/spec/dummy/app/models/dummy/module/instance.rb +0 -209
  78. data/spec/dummy/app/models/dummy/module/path.rb +0 -64
  79. data/spec/dummy/app/models/dummy/module/platform.rb +0 -19
  80. data/spec/dummy/app/models/dummy/module/rank.rb +0 -44
  81. data/spec/dummy/app/models/dummy/module/reference.rb +0 -19
  82. data/spec/dummy/app/models/dummy/module/target.rb +0 -62
  83. data/spec/dummy/app/models/dummy/module/target/architecture.rb +0 -19
  84. data/spec/dummy/app/models/dummy/module/target/platform.rb +0 -19
  85. data/spec/dummy/app/models/dummy/platform.rb +0 -58
  86. data/spec/dummy/app/models/dummy/reference.rb +0 -31
  87. data/spec/dummy/spec/factories/dummy/architectures.rb +0 -13
  88. data/spec/dummy/spec/factories/dummy/authorities.rb +0 -32
  89. data/spec/dummy/spec/factories/dummy/authors.rb +0 -8
  90. data/spec/dummy/spec/factories/dummy/email_addresses.rb +0 -8
  91. data/spec/dummy/spec/factories/dummy/module/actions.rb +0 -13
  92. data/spec/dummy/spec/factories/dummy/module/ancestors.rb +0 -45
  93. data/spec/dummy/spec/factories/dummy/module/architectures.rb +0 -35
  94. data/spec/dummy/spec/factories/dummy/module/authors.rb +0 -10
  95. data/spec/dummy/spec/factories/dummy/module/classes.rb +0 -40
  96. data/spec/dummy/spec/factories/dummy/module/instances.rb +0 -86
  97. data/spec/dummy/spec/factories/dummy/module/paths.rb +0 -16
  98. data/spec/dummy/spec/factories/dummy/module/platforms.rb +0 -35
  99. data/spec/dummy/spec/factories/dummy/module/ranks.rb +0 -14
  100. data/spec/dummy/spec/factories/dummy/module/references.rb +0 -17
  101. data/spec/dummy/spec/factories/dummy/module/target/architectures.rb +0 -40
  102. data/spec/dummy/spec/factories/dummy/module/target/platforms.rb +0 -41
  103. data/spec/dummy/spec/factories/dummy/module/targets.rb +0 -46
  104. data/spec/dummy/spec/factories/dummy/platforms.rb +0 -3
  105. data/spec/dummy/spec/factories/dummy/references.rb +0 -26
  106. data/spec/factories/metasploit/model/architectures.rb +0 -6
  107. data/spec/factories/metasploit/model/authorities.rb +0 -28
  108. data/spec/factories/metasploit/model/authors.rb +0 -9
  109. data/spec/factories/metasploit/model/email_addresses.rb +0 -14
  110. data/spec/factories/metasploit/model/module/actions.rb +0 -9
  111. data/spec/factories/metasploit/model/module/ancestors.rb +0 -180
  112. data/spec/factories/metasploit/model/module/architectures.rb +0 -15
  113. data/spec/factories/metasploit/model/module/classes.rb +0 -47
  114. data/spec/factories/metasploit/model/module/handlers.rb +0 -3
  115. data/spec/factories/metasploit/model/module/instances.rb +0 -83
  116. data/spec/factories/metasploit/model/module/paths.rb +0 -51
  117. data/spec/factories/metasploit/model/module/platforms.rb +0 -15
  118. data/spec/factories/metasploit/model/module/ranks.rb +0 -9
  119. data/spec/factories/metasploit/model/module/references.rb +0 -11
  120. data/spec/factories/metasploit/model/module/stances.rb +0 -3
  121. data/spec/factories/metasploit/model/module/targets.rb +0 -22
  122. data/spec/factories/metasploit/model/module/types.rb +0 -5
  123. data/spec/factories/metasploit/model/references.rb +0 -88
  124. data/spec/lib/metasploit/model/architecture_spec.rb +0 -52
  125. data/spec/lib/metasploit/model/author_spec.rb +0 -6
  126. data/spec/lib/metasploit/model/authority/bid_spec.rb +0 -17
  127. data/spec/lib/metasploit/model/authority/cve_spec.rb +0 -17
  128. data/spec/lib/metasploit/model/authority/msb_spec.rb +0 -17
  129. data/spec/lib/metasploit/model/authority/osvdb_spec.rb +0 -17
  130. data/spec/lib/metasploit/model/authority/pmasa_spec.rb +0 -17
  131. data/spec/lib/metasploit/model/authority/secunia_spec.rb +0 -17
  132. data/spec/lib/metasploit/model/authority/us_cert_vu_spec.rb +0 -17
  133. data/spec/lib/metasploit/model/authority/waraxe_spec.rb +0 -51
  134. data/spec/lib/metasploit/model/authority/zdi_spec.rb +0 -21
  135. data/spec/lib/metasploit/model/authority_spec.rb +0 -10
  136. data/spec/lib/metasploit/model/derivation/full_name_spec.rb +0 -75
  137. data/spec/lib/metasploit/model/derivation_spec.rb +0 -217
  138. data/spec/lib/metasploit/model/email_address_spec.rb +0 -19
  139. data/spec/lib/metasploit/model/module/action_spec.rb +0 -6
  140. data/spec/lib/metasploit/model/module/ancestor_spec.rb +0 -6
  141. data/spec/lib/metasploit/model/module/architecture_spec.rb +0 -9
  142. data/spec/lib/metasploit/model/module/author_spec.rb +0 -6
  143. data/spec/lib/metasploit/model/module/class_spec.rb +0 -19
  144. data/spec/lib/metasploit/model/module/handler_spec.rb +0 -61
  145. data/spec/lib/metasploit/model/module/instance_spec.rb +0 -183
  146. data/spec/lib/metasploit/model/module/path_spec.rb +0 -6
  147. data/spec/lib/metasploit/model/module/platform_spec.rb +0 -9
  148. data/spec/lib/metasploit/model/module/rank_spec.rb +0 -29
  149. data/spec/lib/metasploit/model/module/reference_spec.rb +0 -9
  150. data/spec/lib/metasploit/model/module/stance_spec.rb +0 -30
  151. data/spec/lib/metasploit/model/module/target/architecture_spec.rb +0 -9
  152. data/spec/lib/metasploit/model/module/target/platform_spec.rb +0 -9
  153. data/spec/lib/metasploit/model/module/target_spec.rb +0 -9
  154. data/spec/lib/metasploit/model/module/type_spec.rb +0 -125
  155. data/spec/lib/metasploit/model/platform_spec.rb +0 -100
  156. data/spec/lib/metasploit/model/reference_spec.rb +0 -21
  157. data/spec/support/shared/contexts/metasploit/model/module/ancestor/contents/metasploit_module.rb +0 -12
  158. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents.rb +0 -10
  159. data/spec/support/shared/contexts/metasploit/model/module/ancestor/factory/contents/metasploit_module.rb +0 -15
  160. data/spec/support/shared/examples/derives.rb +0 -115
  161. data/spec/support/shared/examples/metasploit/model/architecture.rb +0 -425
  162. data/spec/support/shared/examples/metasploit/model/architecture/seed.rb +0 -25
  163. data/spec/support/shared/examples/metasploit/model/author.rb +0 -27
  164. data/spec/support/shared/examples/metasploit/model/authority.rb +0 -124
  165. data/spec/support/shared/examples/metasploit/model/authority/seed.rb +0 -49
  166. data/spec/support/shared/examples/metasploit/model/email_address.rb +0 -220
  167. data/spec/support/shared/examples/metasploit/model/module/action.rb +0 -26
  168. data/spec/support/shared/examples/metasploit/model/module/ancestor.rb +0 -2004
  169. data/spec/support/shared/examples/metasploit/model/module/ancestor/payload_factory.rb +0 -63
  170. data/spec/support/shared/examples/metasploit/model/module/architecture.rb +0 -36
  171. data/spec/support/shared/examples/metasploit/model/module/author.rb +0 -29
  172. data/spec/support/shared/examples/metasploit/model/module/class.rb +0 -1514
  173. data/spec/support/shared/examples/metasploit/model/module/handler.rb +0 -21
  174. data/spec/support/shared/examples/metasploit/model/module/instance.rb +0 -1384
  175. data/spec/support/shared/examples/metasploit/model/module/instance/class_methods.rb +0 -537
  176. data/spec/support/shared/examples/metasploit/model/module/instance/is_not_stanced_with_module_type.rb +0 -22
  177. data/spec/support/shared/examples/metasploit/model/module/instance/is_stanced_with_module_type.rb +0 -38
  178. data/spec/support/shared/examples/metasploit/model/module/instance/validates/dynamic_length_of.rb +0 -131
  179. data/spec/support/shared/examples/metasploit/model/module/path.rb +0 -493
  180. data/spec/support/shared/examples/metasploit/model/module/platform.rb +0 -36
  181. data/spec/support/shared/examples/metasploit/model/module/rank.rb +0 -92
  182. data/spec/support/shared/examples/metasploit/model/module/reference.rb +0 -16
  183. data/spec/support/shared/examples/metasploit/model/module/target.rb +0 -29
  184. data/spec/support/shared/examples/metasploit/model/module/target/architecture.rb +0 -56
  185. data/spec/support/shared/examples/metasploit/model/module/target/platform.rb +0 -56
  186. data/spec/support/shared/examples/metasploit/model/platform.rb +0 -213
  187. data/spec/support/shared/examples/metasploit/model/real_pathname.rb +0 -29
  188. data/spec/support/shared/examples/metasploit/model/reference.rb +0 -410
  189. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/app.rb +0 -44
  190. data/spec/support/shared/examples/search/query/metasploit/model/search/operator/deprecated/authority.rb +0 -72
  191. data/spec/support/templates/metasploit/model/module/ancestors/_attributes.rb.erb +0 -9
  192. data/spec/support/templates/metasploit/model/module/ancestors/_methods.rb.erb +0 -8
  193. data/spec/support/templates/metasploit/model/module/ancestors/_validations.rb.erb +0 -6
  194. data/spec/support/templates/metasploit/model/module/ancestors/base.rb.erb +0 -3
  195. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_auxiliary.rb.erb +0 -1
  196. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_encoder.rb.erb +0 -1
  197. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_exploit.rb.erb +0 -1
  198. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_non_payload.rb.erb +0 -5
  199. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_nop.rb.erb +0 -1
  200. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_payload.rb.erb +0 -4
  201. data/spec/support/templates/metasploit/model/module/ancestors/module_types/_post.rb.erb +0 -1
  202. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_handled.rb.erb +0 -20
  203. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_single.rb.erb +0 -1
  204. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stage.rb.erb +0 -0
  205. data/spec/support/templates/metasploit/model/module/ancestors/payload_types/_stager.rb.erb +0 -1
  206. data/spec/support/templates/metasploit/model/module/classes/_methods.rb.erb +0 -9
@@ -1,9 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_author_name do |n|
3
- "Metasploit::Model::Author #{n}"
4
- end
5
-
6
- trait :metasploit_model_author do
7
- name { generate :metasploit_model_author_name }
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_email_address_domain do |n|
3
- "metasploit-model-email-address-domain#{n}.com"
4
- end
5
-
6
- sequence :metasploit_model_email_address_local do |n|
7
- "metasploit.model.email.address.local+#{n}"
8
- end
9
-
10
- trait :metasploit_model_email_address do
11
- domain { generate :metasploit_model_email_address_domain }
12
- local { generate :metasploit_model_email_address_local }
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_module_action_name do |n|
3
- "Metasploit::Model::Module::Action#name #{n}"
4
- end
5
-
6
- trait :metasploit_model_module_action do
7
- name { generate :metasploit_model_module_action_name }
8
- end
9
- end
@@ -1,180 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_module_ancestor_handler_type do |n|
3
- "metasploit_model_module_ancestor_handler_type#{n}"
4
- end
5
-
6
- minimum_version = 1
7
- maximum_version = 4
8
- range = maximum_version - minimum_version + 1
9
-
10
- sequence :metasploit_model_module_ancestor_metasploit_module_relative_name do |n|
11
- version = (n % range) + minimum_version
12
-
13
- "Metasploit#{version}"
14
- end
15
-
16
- sequence :metasploit_model_module_ancestor_payload_type, Metasploit::Model::Module::Ancestor::PAYLOAD_TYPES.cycle
17
-
18
- sequence :metasploit_model_module_ancestor_reference_name do |n|
19
- [
20
- 'metasploit',
21
- 'model',
22
- 'module',
23
- 'ancestor',
24
- 'reference',
25
- "name#{n}"
26
- ].join('/')
27
- end
28
-
29
- sequence :metasploit_model_module_ancestor_non_payload_reference_name do |n|
30
- [
31
- 'mdm',
32
- 'module',
33
- 'ancestor',
34
- 'non',
35
- 'payload',
36
- 'reference',
37
- "name#{n}"
38
- ].join('/')
39
- end
40
-
41
- payload_type_directories = Metasploit::Model::Module::Ancestor::PAYLOAD_TYPES.map(&:pluralize)
42
-
43
- sequence :metasploit_model_module_ancestor_payload_reference_name do |n|
44
- payload_type_directory = payload_type_directories[n % payload_type_directories.length]
45
-
46
- [
47
- payload_type_directory,
48
- 'metasploit',
49
- 'model',
50
- 'module',
51
- 'ancestor',
52
- 'payload',
53
- 'reference',
54
- "name#{n}"
55
- ].join('/')
56
- end
57
-
58
- sequence :metasploit_model_module_ancestor_relative_payload_name do |n|
59
- [
60
- 'metasploit',
61
- 'model',
62
- 'module',
63
- 'ancestor',
64
- 'relative',
65
- 'payload',
66
- "name#{n}"
67
- ].join('/')
68
- end
69
-
70
- trait :metasploit_model_module_ancestor do
71
- #
72
- # Attributes
73
- #
74
-
75
- module_type { generate :metasploit_model_module_type }
76
-
77
- ignore do
78
- # depends on module_type
79
- payload_type {
80
- if payload?
81
- generate :metasploit_model_module_ancestor_payload_type
82
- else
83
- nil
84
- end
85
- }
86
-
87
- #
88
- # Callback helpers
89
- #
90
-
91
- before_write_template {
92
- ->(module_ancestor, evaluator){}
93
- }
94
- write_template {
95
- ->(module_ancestor, evaluator){
96
- Metasploit::Model::Module::Ancestor::Spec::Template.write(module_ancestor: module_ancestor)
97
- }
98
- }
99
- end
100
-
101
- # depends on module_type
102
- reference_name {
103
- if payload?
104
- payload_type_directory = payload_type.pluralize
105
- relative_payload_name = generate :metasploit_model_module_ancestor_relative_payload_name
106
-
107
- [
108
- payload_type_directory,
109
- relative_payload_name
110
- ].join('/')
111
- else
112
- generate :metasploit_model_module_ancestor_non_payload_reference_name
113
- end
114
- }
115
-
116
- # depends on derived_payload_type which depends on reference_name
117
- handler_type {
118
- # can't use #handled? because it will check payload_type on model, not ignored field in factory, so use
119
- # .handled?
120
- if @instance.class.handled?(:module_type => module_type, :payload_type => derived_payload_type)
121
- generate :metasploit_model_module_ancestor_handler_type
122
- else
123
- nil
124
- end
125
- }
126
-
127
- #
128
- # Callbacks
129
- #
130
-
131
- after(:build) do |module_ancestor, evaluator|
132
- instance_exec(module_ancestor, evaluator, &evaluator.before_write_template)
133
- instance_exec(module_ancestor, evaluator, &evaluator.write_template)
134
- end
135
- end
136
-
137
- trait :non_payload_metasploit_model_module_ancestor do
138
- module_type { generate :metasploit_model_non_payload_module_type }
139
-
140
- ignore do
141
- payload_type nil
142
- end
143
- end
144
-
145
- trait :payload_metasploit_model_module_ancestor do
146
- module_type 'payload'
147
-
148
- ignore do
149
- payload_type { generate :metasploit_model_module_ancestor_payload_type }
150
- end
151
-
152
- reference_name {
153
- payload_type_directory = payload_type.pluralize
154
- relative_payload_name = generate :metasploit_model_module_ancestor_relative_payload_name
155
-
156
- [
157
- payload_type_directory,
158
- relative_payload_name
159
- ].join('/')
160
- }
161
- end
162
-
163
- trait :single_payload_metasploit_model_module_ancestor do
164
- ignore do
165
- payload_type 'single'
166
- end
167
- end
168
-
169
- trait :stage_payload_metasploit_model_module_ancestor do
170
- ignore do
171
- payload_type 'stage'
172
- end
173
- end
174
-
175
- trait :stager_payload_metasploit_model_module_ancestor do
176
- ignore do
177
- payload_type 'stager'
178
- end
179
- end
180
- end
@@ -1,15 +0,0 @@
1
- FactoryGirl.define do
2
- module_architectures_module_types = Metasploit::Model::Module::Instance.module_types_that_allow(:module_architectures)
3
- targets_module_types = Metasploit::Model::Module::Instance.module_types_that_allow(:targets)
4
-
5
- # have to remove target supporting types so that target architectures won't interfere with module architectures
6
- metasploit_model_module_architecture_module_types = module_architectures_module_types - targets_module_types
7
-
8
- sequence :metasploit_model_module_architecture_module_type, metasploit_model_module_architecture_module_types.cycle
9
-
10
- trait :metasploit_model_module_architecture do
11
- ignore do
12
- module_type { generate :metasploit_model_module_architecture_module_type }
13
- end
14
- end
15
- end
@@ -1,47 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_module_class_payload_type, Metasploit::Model::Module::Class::PAYLOAD_TYPES.cycle
3
-
4
- trait :metasploit_model_module_class do
5
- #
6
- # Attributes
7
- #
8
-
9
- # Don't set full_name: before_validation will derive it from {Metasploit::Model::Module::Class#module_type} and
10
- # {Metasploit::Model::Module::Class::reference_name}.
11
-
12
- ignore do
13
- # derives from associations in instance, so don't set on instance
14
- module_type { generate :metasploit_model_module_type }
15
-
16
- # depends on module_type
17
- # ignored because model attribute will derived from reference_name, this factory attribute is used to generate
18
- # the correct reference_name.
19
- payload_type {
20
- # module_type is factory attribute, not model attribute
21
- if module_type == Metasploit::Model::Module::Type::PAYLOAD
22
- generate :metasploit_model_module_class_payload_type
23
- else
24
- nil
25
- end
26
- }
27
-
28
- #
29
- # Callback helpers
30
- #
31
-
32
- before_write_template {
33
- ->(module_class, evaluator) {}
34
- }
35
- write_template {
36
- ->(module_class, evaluator) {
37
- Metasploit::Model::Module::Class::Spec::Template.write(module_class: module_class)
38
- }
39
- }
40
- end
41
-
42
- after(:build) do |module_class, evaluator|
43
- instance_exec(evaluator, evaluator, &evaluator.before_write_template)
44
- instance_exec(evaluator, evaluator, &evaluator.write_template)
45
- end
46
- end
47
- end
@@ -1,3 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_module_handler_type, Metasploit::Model::Module::Handler::TYPES.cycle
3
- end
@@ -1,83 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_module_instance_description do |n|
3
- "Module Description #{n}"
4
- end
5
-
6
- sequence :metasploit_model_module_instance_disclosed_on do |n|
7
- Date.today - n
8
- end
9
-
10
- sequence :metasploit_model_module_instance_license do |n|
11
- "Module License #{n}"
12
- end
13
-
14
- sequence :metasploit_model_module_instance_name do |n|
15
- "Module Name #{n}"
16
- end
17
-
18
- sequence :metasploit_model_module_instance_privileged, Metasploit::Model::Module::Instance::PRIVILEGES.cycle
19
-
20
- total_architectures = Metasploit::Model::Architecture::ABBREVIATIONS.length
21
- total_platforms = Metasploit::Model::Platform.fully_qualified_name_set.length
22
- # chosen so that there is at least 1 element even if 0 is allowed so that factories always test that the associated
23
- # records are handled.
24
- minimum_with_elements = 1
25
- # arbitrarily chosen maximum when there are a bounded total of the associated records. Most chosen because 3 will
26
- # test that there is no 1 or 2 special casing make it work.
27
- arbitrary_maximum = 3
28
- arbitrary_supported_length = ->{
29
- Random.rand(minimum_with_elements .. arbitrary_maximum)
30
- }
31
-
32
- trait :metasploit_model_module_instance do
33
- ignore do
34
- actions_length(&arbitrary_supported_length)
35
-
36
- # this length is only used if supports?(:module_architectures) is true. It can be set to 0 when
37
- # supports?(:module_architectures) is true to make the after(:build) skip building the module architectures automatically.
38
- module_architectures_length {
39
- Random.rand(minimum_with_elements .. total_architectures)
40
- }
41
-
42
- module_authors_length(&arbitrary_supported_length)
43
-
44
- # this length is only used if supports?(:module_platforms) is true. It can be set to 0 when
45
- # supports?(:module_platforms) is true to make the after(:build) skip building the module platforms automatically.
46
- module_platforms_length {
47
- Random.rand(minimum_with_elements .. total_platforms)
48
- }
49
-
50
- module_references_length(&arbitrary_supported_length)
51
- targets_length(&arbitrary_supported_length)
52
-
53
- #
54
- # Callback helpers
55
- #
56
-
57
- # Can't use the after(:build) system because in Mdm, the associations need to be set before writing the template
58
- before_write_template {
59
- ->(module_instance, _evaluator){}
60
- }
61
- write_template {
62
- ->(module_instance, _evaluator) {
63
- Metasploit::Model::Module::Instance::Spec::Template.write(module_instance: module_instance)
64
- }
65
- }
66
- end
67
-
68
- #
69
- # Attributes
70
- #
71
-
72
- description { generate :metasploit_model_module_instance_description }
73
- disclosed_on { generate :metasploit_model_module_instance_disclosed_on }
74
- license { generate :metasploit_model_module_instance_license }
75
- name { generate :metasploit_model_module_instance_name }
76
- privileged { generate :metasploit_model_module_instance_privileged }
77
-
78
- after(:build) do |module_instance, evaluator|
79
- instance_exec(module_instance, evaluator, &evaluator.before_write_template)
80
- instance_exec(module_instance, evaluator, &evaluator.write_template)
81
- end
82
- end
83
- end
@@ -1,51 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :metasploit_model_module_path_gem do |n|
3
- "metasploit_model_module_path_gem#{n}"
4
- end
5
-
6
- sequence :metasploit_model_module_path_name do |n|
7
- "metasploit_model_module_path_name#{n}"
8
- end
9
-
10
- sequence :metasploit_model_module_path_real_path do |n|
11
- pathname = Metasploit::Model::Spec.temporary_pathname.join(
12
- 'metasploit',
13
- 'model',
14
- 'module',
15
- 'path',
16
- 'real',
17
- 'path',
18
- n.to_s
19
- )
20
- Metasploit::Model::Spec::PathnameCollision.check!(pathname)
21
- pathname.mkpath
22
-
23
- pathname.to_path
24
- end
25
-
26
- sequence :metasploit_model_module_path_directory_real_path do |n|
27
- pathname = Metasploit::Model::Spec.temporary_pathname.join(
28
- 'metasploit',
29
- 'model',
30
- 'module',
31
- 'path',
32
- 'directory',
33
- 'real',
34
- 'path',
35
- n.to_s
36
- )
37
- Metasploit::Model::Spec::PathnameCollision.check!(pathname)
38
- pathname.mkpath
39
-
40
- pathname.to_path
41
- end
42
-
43
- trait :unnamed_metasploit_model_module_path do
44
- real_path { generate :metasploit_model_module_path_real_path }
45
- end
46
-
47
- trait :named_metasploit_model_module_path do
48
- gem { generate :metasploit_model_module_path_gem }
49
- name { generate :metasploit_model_module_path_name }
50
- end
51
- end
@@ -1,15 +0,0 @@
1
- FactoryGirl.define do
2
- module_platforms_module_types = Metasploit::Model::Module::Instance.module_types_that_allow(:module_platforms)
3
- targets_module_types = Metasploit::Model::Module::Instance.module_types_that_allow(:targets)
4
-
5
- # have to remove target supporting types so that target platforms won't interfere with module platforms
6
- metasploit_model_module_platform_module_types = module_platforms_module_types - targets_module_types
7
-
8
- sequence :metasploit_model_module_platform_module_type, metasploit_model_module_platform_module_types.cycle
9
-
10
- trait :metasploit_model_module_platform do
11
- ignore do
12
- module_type { generate :metasploit_model_module_platform_module_type }
13
- end
14
- end
15
- end
@@ -1,9 +0,0 @@
1
- FactoryGirl.define do
2
- number_by_name = Metasploit::Model::Module::Rank::NUMBER_BY_NAME
3
-
4
- names = number_by_name.keys
5
- sequence :metasploit_model_module_rank_name, names.cycle
6
-
7
- numbers = number_by_name.values
8
- sequence :metasploit_model_module_rank_number, numbers.cycle
9
- end