metasploit_data_models 0.19.4-java → 0.19.7-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d6d17408ff12f5c425ec48ec37f3aa032c60e92
4
- data.tar.gz: 8a444cb3f6618b2783a7ded1d69d52cb47a74588
3
+ metadata.gz: 1e158d00aaeb03ffb1a8d5ca4aeafc94125f602b
4
+ data.tar.gz: 96880062623265e7dc16102766156f4bb04cc891
5
5
  SHA512:
6
- metadata.gz: 2182b0b0fa86f7c2f2bc5e5055b2da9cf6954799762e6e187daee9982d9657863b5286c3c3830d2a745876da22d605bdd6422485f4f9c1c7113d8ce702bf649f
7
- data.tar.gz: d6fc50178926110ad3fd954c6871e691248ec63798f4205c7bcd14e3f00bfa14157f1d0a8fb235740285f54c4df9d295e24263e779c2db56d5f0671651de3c5e
6
+ metadata.gz: f1a3bfeca77e9da5544e8a16d9d8587ffdc2358969083050b702504a1efbd5964f4629f486e86e9db95da25f3e940b910bc06c6afb931ac264f2ccdb40134c97
7
+ data.tar.gz: c6214b7c6e8d58c427db6ef6945d5521d69fe4e243e24643e9bbe7d906d1f9430052ae0e5c039cf0d0742bd8eaf688b8d7e3e4c6bf1f42975fb446b6916cbc45
@@ -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: java
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
@@ -377,6 +377,7 @@ files:
377
377
  - db/migrate/20130531144949_making_host_tags_a_real_ar_model.rb
378
378
  - db/migrate/20130604145732_create_task_sessions.rb
379
379
  - db/migrate/20130717150737_remove_pname_validation.rb
380
+ - db/migrate/20140905031549_add_detected_arch_to_host.rb
380
381
  - lib/mdm.rb
381
382
  - lib/mdm/host/operating_system_normalization.rb
382
383
  - lib/mdm/module.rb
@@ -584,7 +585,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
584
585
  version: '0'
585
586
  requirements: []
586
587
  rubyforge_project:
587
- rubygems_version: 2.2.2
588
+ rubygems_version: 2.1.9
588
589
  signing_key:
589
590
  specification_version: 4
590
591
  summary: Database code for MSF and Metasploit Pro