metasploit_data_models 0.19.0 → 0.19.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTQ0Y2Q5YzA1YWYxNzViOTg0NGVjYTM1M2E5ZTE1NjJkNTJhZTc2Ng==
4
+ MWU5ODZlY2I0YjdjYmY1Mzg1N2U4OGUwNDhiYjc3NjA1NThkYjY1NA==
5
5
  data.tar.gz: !binary |-
6
- YTY1NTEwYWNlZTYzOGEyY2Y5NWU3MmMyOTIzMzBlZDQxNjE4NTNiZA==
6
+ ZjdjNWY0YjZkZjZhZDVhODA5NTUyZGYwOThlZGZjNjcxMTE4MzBlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDhiZjg1M2FhNzg2ZjdiYmUyNzFlOWNhYWQ1YzYzOGM4ZmJiMjY3MzdlMjdk
10
- NzE2ODcwM2JjNWM3MzllZTE0MTNiYzc5Y2VhMjE5OWVkMTQ2MGYwZDdkMmIy
11
- OGFmZTI4YmY0YjExMzQzMTQxYWU1YzVmZDg0MmU3MTI2ZTBmOWY=
9
+ MDNiYTJmYjE1N2JkNGJiNTNjZWU4MzhlMjZjMzA1MGQ5ZTc4NDlkZTA4NDM1
10
+ ZjAyZWExYTdlMmI1NzIwMWRmNjk5MTMxM2I1MDJmZWMzMDY4YzZiNmE0ZWEz
11
+ YzkwYjMyYzM5MDcwNzFlNGEyMDcyZjhkMGQxY2EzYzM1MjQ3ZGU=
12
12
  data.tar.gz: !binary |-
13
- M2ZlZmRmY2E4Y2E4NmQzZjc3MmFmOTZjYzJhMWNjYmM4YWU3ODNhMTNkODI2
14
- ZTNhMTdjMGUzYmI1N2EzMDRmYWMzMzg5MjA1MWI1OTZiNjdkZjBjNzdlNmVm
15
- YmM1NmYyMzU0YjQwNWQ1ZGRjZjE5OGQ4OGYzZTk3MDA5ZTZjYmI=
13
+ NjIyNzQyMmMzNjIyMzI0YjA5NGIyNTA2YjkzNDA1YTg3NGE1OTIwNzE1YWRk
14
+ NjI1NjY1NGRmNmZiMTRjYWQ0Mjg5Mjg4NDM0YTk0ZTM0MjlhMTA0NDY3MGQz
15
+ NzdjMDY5NDgyZDNmOGVkMjAxNWRlOTdmNjA2ODJiY2JiNGI3MTI=
@@ -185,6 +185,12 @@ class Mdm::Service < ActiveRecord::Base
185
185
  #
186
186
  #
187
187
 
188
+ #
189
+ # Search Associations
190
+ #
191
+
192
+ search_association :host
193
+
188
194
  #
189
195
  # Search Attributes
190
196
  #
@@ -202,6 +208,14 @@ class Mdm::Service < ActiveRecord::Base
202
208
  # Search Withs
203
209
  #
204
210
 
211
+ # Have to declare on Mdm::Service because non-attribute operators cannot function as association operators
212
+ search_with MetasploitDataModels::Search::Operator::Multitext,
213
+ name: :'host.os',
214
+ operator_names: [
215
+ :'host.os_name',
216
+ :'host.os_flavor',
217
+ :'host.os_sp'
218
+ ]
205
219
  search_with MetasploitDataModels::Search::Operator::Port::List
206
220
 
207
221
  #
@@ -6,7 +6,7 @@ module MetasploitDataModels
6
6
  # The minor version number, scoped to the {MAJOR} version number.
7
7
  MINOR = 19
8
8
  # The patch number, scoped to the {MINOR} version number.
9
- PATCH = 0
9
+ PATCH = 3
10
10
 
11
11
  # The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the `PRERELEASE` in the
12
12
  # {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
@@ -119,6 +119,16 @@ describe Mdm::Service do
119
119
  end
120
120
  end
121
121
 
122
+ context 'search' do
123
+ let(:base_class) {
124
+ described_class
125
+ }
126
+
127
+ context 'associations' do
128
+ it_should_behave_like 'search_association', :host
129
+ end
130
+ end
131
+
122
132
  context "validations" do
123
133
  subject(:mdm_service) {
124
134
  FactoryGirl.build(:mdm_service)
@@ -172,6 +172,32 @@ describe MetasploitDataModels::Search::Visitor::Relation do
172
172
  # Don't use factories to prevent prefix aliasing when sequences go from 1 to 10 or 10 to 100
173
173
  #
174
174
 
175
+ let(:non_matching_host) {
176
+ FactoryGirl.create(
177
+ :mdm_host,
178
+ name: non_matching_host_name,
179
+ os_flavor: non_matching_host_os_flavor,
180
+ os_name: non_matching_host_os_name,
181
+ os_sp: non_matching_host_os_sp
182
+ )
183
+ }
184
+
185
+ let(:non_matching_host_name) {
186
+ 'mdm_host_name_b'
187
+ }
188
+
189
+ let(:non_matching_host_os_flavor) {
190
+ 'mdm_host_os_flavor_b'
191
+ }
192
+
193
+ let(:non_matching_host_os_name) {
194
+ 'mdm_host_os_name_b'
195
+ }
196
+
197
+ let(:non_matching_host_os_sp) {
198
+ 'mdm_host_os_sp_b'
199
+ }
200
+
175
201
  let(:non_matching_info) {
176
202
  'mdm_service_info_c'
177
203
  }
@@ -195,13 +221,13 @@ describe MetasploitDataModels::Search::Visitor::Relation do
195
221
  let!(:non_matching_record) {
196
222
  FactoryGirl.create(
197
223
  :mdm_service,
224
+ host: non_matching_host,
198
225
  info: non_matching_info,
199
226
  name: non_matching_name,
200
227
  port: non_matching_port,
201
228
  proto: non_matching_proto
202
229
  )
203
230
  }
204
- p
205
231
 
206
232
  context 'with port' do
207
233
  #
@@ -294,6 +320,32 @@ describe MetasploitDataModels::Search::Visitor::Relation do
294
320
  # Don't use factories to prevent prefix aliasing when sequences go from 1 to 10 or 10 to 100
295
321
  #
296
322
 
323
+ let(:matching_host) {
324
+ FactoryGirl.create(
325
+ :mdm_host,
326
+ name: matching_host_name,
327
+ os_flavor: matching_host_os_flavor,
328
+ os_name: matching_host_os_name,
329
+ os_sp: matching_host_os_sp
330
+ )
331
+ }
332
+
333
+ let(:matching_host_name) {
334
+ 'mdm_host_name_a'
335
+ }
336
+
337
+ let(:matching_host_os_flavor) {
338
+ 'mdm_host_os_flavor_a'
339
+ }
340
+
341
+ let(:matching_host_os_name) {
342
+ 'mdm_host_os_name_a'
343
+ }
344
+
345
+ let(:matching_host_os_sp) {
346
+ 'mdm_host_os_sp_a'
347
+ }
348
+
297
349
  let(:matching_info) {
298
350
  'mdm_service_info_a'
299
351
  }
@@ -317,6 +369,7 @@ describe MetasploitDataModels::Search::Visitor::Relation do
317
369
  let!(:matching_record) {
318
370
  FactoryGirl.create(
319
371
  :mdm_service,
372
+ host: matching_host,
320
373
  info: matching_info,
321
374
  name: matching_name,
322
375
  port: matching_port,
@@ -324,6 +377,70 @@ describe MetasploitDataModels::Search::Visitor::Relation do
324
377
  )
325
378
  }
326
379
 
380
+ it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
381
+ association: :host,
382
+ attribute: :name
383
+
384
+ context 'with host.os' do
385
+ let(:matching_host_os_flavor) {
386
+ 'XP'
387
+ }
388
+
389
+ let(:matching_host_os_name) {
390
+ 'Microsoft Windows'
391
+ }
392
+
393
+ let(:matching_host_os_sp) {
394
+ 'SP1'
395
+ }
396
+
397
+ context 'with a combination of Mdm::Host#os_name and Mdm:Host#os_sp' do
398
+ let(:formatted) {
399
+ %Q{host.os:"win xp"}
400
+ }
401
+
402
+ it 'finds matching record' do
403
+ expect(visit).to match_array [matching_record]
404
+ end
405
+ end
406
+
407
+ context 'with a combination of Mdm::Host#os_flavor and Mdm::Host#os_sp' do
408
+ let(:formatted) {
409
+ %Q{host.os:"xp sp1"}
410
+ }
411
+
412
+ it 'finds matching record' do
413
+ expect(visit).to match_array [matching_record]
414
+ end
415
+ end
416
+
417
+ context 'with multiple records matching one word' do
418
+ let(:formatted) {
419
+ %Q{host.os:"win xp"}
420
+ }
421
+
422
+ let(:non_matching_host_os_name) {
423
+ 'Microsoft Windows'
424
+ }
425
+
426
+ it 'finds only matching record by other words refining search' do
427
+ expect(visit).to match_array [matching_record]
428
+ end
429
+ end
430
+ end
431
+
432
+ it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
433
+ association: :host,
434
+ attribute: :os_flavor
435
+
436
+ it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
437
+ association: :host,
438
+ attribute: :os_name
439
+
440
+ it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
441
+ association: :host,
442
+ attribute: :os_sp
443
+
327
444
  it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
328
445
  attribute: :info
329
446
 
@@ -335,7 +452,16 @@ describe MetasploitDataModels::Search::Visitor::Relation do
335
452
 
336
453
  context 'with all operators' do
337
454
  let(:formatted) {
338
- %Q{name:#{matching_name} port:#{matching_port} proto:#{matching_proto}}
455
+ %Q{
456
+ host.name:#{matching_host_name}
457
+ host.os:"#{matching_host_os_name} #{matching_host_os_flavor} #{matching_host_os_sp}"
458
+ host.os_flavor:#{matching_host_os_flavor}
459
+ host.os_name:#{matching_host_os_name}
460
+ host.os_sp:#{matching_host_os_sp}
461
+ name:#{matching_name}
462
+ port:#{matching_port}
463
+ proto:#{matching_proto}
464
+ }
339
465
  }
340
466
 
341
467
  it 'finds only matching record' do
@@ -567,67 +693,65 @@ describe MetasploitDataModels::Search::Visitor::Relation do
567
693
  end
568
694
  end
569
695
 
696
+ context 'with Mdm::Tag' do
697
+ #
698
+ # lets
699
+ #
700
+
701
+ let(:klass) {
702
+ Mdm::Tag
703
+ }
704
+
705
+ let(:matching_desc) {
706
+ 'This is a description'
707
+ }
570
708
 
571
- end
709
+ let(:matching_name) {
710
+ 'matching.tag'
711
+ }
712
+
713
+ let(:non_matching_desc) {
714
+ 'This could be a description'
715
+ }
572
716
 
573
- context 'with Mdm::Tag' do
574
- #
575
- # lets
576
- #
577
-
578
- let(:klass) {
579
- Mdm::Tag
580
- }
581
-
582
- let(:matching_desc) {
583
- 'This is a description'
584
- }
585
-
586
- let(:matching_name) {
587
- 'matching.tag'
588
- }
589
-
590
- let(:non_matching_desc) {
591
- 'This could be a description'
592
- }
593
-
594
- let(:non_matching_name) {
595
- 'tag.does.not.match'
596
- }
597
-
598
- #
599
- # let!s
600
- #
601
-
602
- let!(:matching_record) {
603
- FactoryGirl.create(
604
- :mdm_tag,
605
- desc: matching_desc,
606
- name: matching_name
607
- )
608
- }
609
-
610
- let!(:non_matching_record) {
611
- FactoryGirl.create(
612
- :mdm_tag,
613
- desc: non_matching_desc,
614
- name: non_matching_name
615
- )
616
- }
617
-
618
- it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
619
- attribute: :desc
620
-
621
- it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
622
- attribute: :name
623
-
624
- context 'with all operators' do
625
- let(:formatted) {
626
- %Q{desc:"#{matching_desc}" name:"#{matching_name}"}
717
+ let(:non_matching_name) {
718
+ 'tag.does.not.match'
627
719
  }
628
720
 
629
- it 'should find only matching record' do
630
- expect(visit).to match_array([matching_record])
721
+ #
722
+ # let!s
723
+ #
724
+
725
+ let!(:matching_record) {
726
+ FactoryGirl.create(
727
+ :mdm_tag,
728
+ desc: matching_desc,
729
+ name: matching_name
730
+ )
731
+ }
732
+
733
+ let!(:non_matching_record) {
734
+ FactoryGirl.create(
735
+ :mdm_tag,
736
+ desc: non_matching_desc,
737
+ name: non_matching_name
738
+ )
739
+ }
740
+
741
+ it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
742
+ attribute: :desc
743
+
744
+ it_should_behave_like 'MetasploitDataModels::Search::Visitor::Relation#visit matching record',
745
+ attribute: :name
746
+
747
+ context 'with all operators' do
748
+ let(:formatted) {
749
+ %Q{desc:"#{matching_desc}" name:"#{matching_name}"}
750
+ }
751
+
752
+ it 'should find only matching record' do
753
+ expect(visit).to match_array([matching_record])
754
+ end
631
755
  end
632
756
  end
633
757
  end
@@ -4,5 +4,14 @@ FactoryGirl.define do
4
4
  # Associations
5
5
  #
6
6
  association :service, :factory => :mdm_service
7
+
8
+ active true
9
+ pass{ generate :mdm_cred_pass }
10
+ ptype 'password'
11
+ user{ generate :mdm_user_username }
12
+ end
13
+
14
+ sequence :mdm_cred_pass do |n|
15
+ "mahp455w3rd!-#{n}"
7
16
  end
8
17
  end
@@ -32,6 +32,7 @@ Rails.backtrace_cleaner.remove_silencers!
32
32
 
33
33
  engines = [
34
34
  Metasploit::Concern::Engine,
35
+ Metasploit::Model::Engine,
35
36
  MetasploitDataModels::Engine
36
37
  ]
37
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metasploit_data_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.19.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Huckins
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-07-18 00:00:00.000000000 Z
14
+ date: 2014-07-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake