metasploit_data_models 0.19.4 → 0.19.7

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
- OGVlZmE2OTg5NzU3YmU2OTdiZWI0N2UwYjU5MTJhNTEzNzE4ZjhhNQ==
4
+ YjIzZmZkYmUxMzhmMjg5ZDA0Y2M1MmU2NTgyNjQ2YTRlYzc3OWZhYg==
5
5
  data.tar.gz: !binary |-
6
- NWZiNzhiMDEyYjQ3ODdiZWE3NmQ3Njg5YjE5YjkyNTUxYTA0MmNlYQ==
6
+ NTc2M2QyZjZhOTZiMGQyNDJlOWRjNmEyMzdhY2E0NzQ2NTgwOGMzMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjBmZjA1Njg3MWRkMGRiMDM1NWFiMzUxYzQ3OWJiZTMzZWVjZWIxOTU0Mzc5
10
- YWQ2NTg5MzMyZjczMjg4ZTIyOTBmNDRhZGJjMzg3YzA5Y2NkMDVjYTE3Y2Zm
11
- ZThhN2FkNmMwODI5NzJmMzg5MTgzOTQ5ZGJmYzQwZGNiMWYxZDc=
9
+ NjQwNTdkNTBhZTdlNWZjZTJlYjc3ZjA2MTA1ODBkMTEyNDZlM2I5YjBlN2Qw
10
+ YWY4ZjZhZDA0ZmRiOWQ1MDY1NWEyZGY4MWFkMDc1YzhlYjRkNThjN2NhOGRk
11
+ MjJjMzEyM2U1MDU2ZmZmYjQzZGQyOGRiMTg3N2E4YjhlNDRiOWE=
12
12
  data.tar.gz: !binary |-
13
- ZjM4MDllNmZkYzlkYmU5NmM3MmRjYmQ3Mzc4NGIwOTFlZjY5ZjlmZjZjZmQ4
14
- NjVhYzdjMDMwN2I0OGRiYjMzNDgzNmIzMGQ0YmMzYWM3ODQyMGEzOTYzMDhk
15
- YTdlOTEzYTg0ODFjMTU1ZjE2OGZkMzdmNmRlNWFkODRhZDJiMjI=
13
+ NTUzODYwOWJmMTliMzkzMjhjOGY2NTRmNGExNzgzNzc1YmJmODI2MDYyODZl
14
+ NjMwYmIyMWVkN2YxYTZiZjhhNzAwNDJhZDg3N2ZjYTdhZDQ4OWUyMjgxNWE4
15
+ NjhkZGE2YjU0MGFlYTY0OTM0NTdjOTMwYTZmNzE0Y2ZlMzFmMGQ=
@@ -7,8 +7,13 @@ class Mdm::Host < ActiveRecord::Base
7
7
  # CONSTANTS
8
8
  #
9
9
 
10
- # Either the CPU architecture for native code or the programming language name for exploits that run code in the
11
- # programming language's virtual machine.
10
+ # Special {#arch} value to indicate we should look at {#detected_arch}
11
+ # instead
12
+ UNKNOWN_ARCHITECTURE = 'Unknown'
13
+
14
+ # Either the CPU architecture for native code or the programming language
15
+ # name for exploits that run code in the programming language's virtual
16
+ # machine.
12
17
  ARCHITECTURES = [
13
18
  'armbe',
14
19
  'armle',
@@ -28,7 +33,9 @@ class Mdm::Host < ActiveRecord::Base
28
33
  # To be used for compatability with 'X86_64'
29
34
  'x64',
30
35
  'x86',
31
- 'x86_64'
36
+ 'x86_64',
37
+ '',
38
+ UNKNOWN_ARCHITECTURE
32
39
  ]
33
40
 
34
41
  # Fields searched for the search scope
@@ -309,6 +316,12 @@ class Mdm::Host < ActiveRecord::Base
309
316
  #
310
317
  # @return [Integer]
311
318
 
319
+ # @!attribute [rw] detected_arch
320
+ # The architecture of the host's CPU as detected by `Recog`. If {#arch} is
321
+ # not {UNKNOWN_ARCHITECTURE}, this is undefined.
322
+ #
323
+ # @return [String] a free-form string most likely from network data
324
+
312
325
  # @!attribute [rw] exploit_attempt_count
313
326
  # Counter cache for {#exploit_attempts}.
314
327
  #
@@ -406,6 +419,12 @@ class Mdm::Host < ActiveRecord::Base
406
419
  #
407
420
  # @return [Integer]
408
421
 
422
+ #
423
+ # Callbacks
424
+ #
425
+
426
+ before_validation :normalize_arch
427
+
409
428
  #
410
429
  # Nested Attributes
411
430
  # @note Must be declared after relations being referenced.
@@ -541,6 +560,17 @@ class Mdm::Host < ActiveRecord::Base
541
560
  !!self.virtual_host
542
561
  end
543
562
 
563
+ private
564
+
565
+ def normalize_arch
566
+ if attribute_present?(:arch) && !ARCHITECTURES.include?(self.arch)
567
+ self.detected_arch = arch
568
+ self.arch = UNKNOWN_ARCHITECTURE
569
+ end
570
+ end
571
+
572
+ public
573
+
544
574
  Metasploit::Concern.run(self)
545
575
  end
546
576
 
@@ -0,0 +1,5 @@
1
+ class AddDetectedArchToHost < ActiveRecord::Migration
2
+ def change
3
+ add_column :hosts, :detected_arch, :string, { :null => true }
4
+ end
5
+ end
@@ -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 = 4
9
+ PATCH = 7
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.
@@ -25,7 +25,8 @@ describe Mdm::Host do
25
25
  'x64',
26
26
  'x86',
27
27
  'x86_64',
28
- ''
28
+ '',
29
+ 'Unknown',
29
30
  ]
30
31
  end
31
32
 
@@ -268,6 +269,15 @@ describe Mdm::Host do
268
269
  architectures.should include('x86')
269
270
  architectures.should include('x86_64')
270
271
  end
272
+
273
+ it 'should include blank string to indicate no detection has happened' do
274
+ architectures.should include('')
275
+ end
276
+
277
+ it 'should include "Unknown" for failed detection attempts' do
278
+ architectures.should include('Unknown')
279
+ end
280
+
271
281
  end
272
282
 
273
283
  context 'SEARCH_FIELDS' do
@@ -382,7 +392,24 @@ describe Mdm::Host do
382
392
  end
383
393
  end
384
394
 
385
- it { should ensure_inclusion_of(:arch).in_array(architectures).allow_blank }
395
+ context 'arch' do
396
+ let(:workspace) { FactoryGirl.create(:mdm_workspace) }
397
+ let(:address) { '192.168.0.1' }
398
+ let(:host) { FactoryGirl.create(:mdm_host, :address => address, :workspace => workspace, :arch => arch) }
399
+ context 'with an unknown architecture' do
400
+ let(:arch) { "asdfasdf" }
401
+ it 'should normalize to Unknown' do
402
+ host.should be_valid
403
+ host.arch.should be described_class::UNKNOWN_ARCHITECTURE
404
+ end
405
+ end
406
+ described_class::ARCHITECTURES.each do |arch|
407
+ context "with known architecture '#{arch}'" do
408
+ let(:arch) { arch }
409
+ it { should be_valid }
410
+ end
411
+ end
412
+ end
386
413
  it { should ensure_inclusion_of(:state).in_array(states).allow_nil }
387
414
  it { should validate_presence_of(:workspace) }
388
415
  end
@@ -819,4 +846,4 @@ describe Mdm::Host do
819
846
  end
820
847
 
821
848
  end
822
- end
849
+ end
@@ -310,7 +310,8 @@ CREATE TABLE hosts (
310
310
  service_count integer DEFAULT 0,
311
311
  host_detail_count integer DEFAULT 0,
312
312
  exploit_attempt_count integer DEFAULT 0,
313
- cred_count integer DEFAULT 0
313
+ cred_count integer DEFAULT 0,
314
+ detected_arch character varying(255)
314
315
  );
315
316
 
316
317
 
@@ -2984,6 +2985,8 @@ INSERT INTO schema_migrations (version) VALUES ('20130604145732');
2984
2985
 
2985
2986
  INSERT INTO schema_migrations (version) VALUES ('20130717150737');
2986
2987
 
2988
+ INSERT INTO schema_migrations (version) VALUES ('20140905031549');
2989
+
2987
2990
  INSERT INTO schema_migrations (version) VALUES ('21');
2988
2991
 
2989
2992
  INSERT INTO schema_migrations (version) VALUES ('22');
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.4
4
+ version: 0.19.7
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-29 00:00:00.000000000 Z
14
+ date: 2014-09-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -364,6 +364,7 @@ files:
364
364
  - db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb
365
365
  - db/migrate/20130604145732_create_task_sessions.rb
366
366
  - db/migrate/20130717150737_remove_pname_validation.rb
367
+ - db/migrate/20140905031549_add_detected_arch_to_host.rb
367
368
  - lib/mdm.rb
368
369
  - lib/mdm/host/operating_system_normalization.rb
369
370
  - lib/mdm/module.rb