ronin 1.0.0 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/.yardopts +0 -1
  2. data/ChangeLog.md +67 -3
  3. data/Gemfile +20 -12
  4. data/README.md +3 -5
  5. data/gemspec.yml +5 -5
  6. data/lib/ronin/address.rb +8 -3
  7. data/lib/ronin/arch.rb +39 -14
  8. data/lib/ronin/author.rb +2 -0
  9. data/lib/ronin/auto_load.rb +67 -0
  10. data/lib/ronin/campaign.rb +15 -2
  11. data/lib/ronin/class_methods.rb +7 -1
  12. data/lib/ronin/config.rb +5 -0
  13. data/lib/ronin/credential.rb +14 -3
  14. data/lib/ronin/database/database.rb +38 -12
  15. data/lib/ronin/database/migrations.rb +3 -1
  16. data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +48 -0
  17. data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +47 -0
  18. data/lib/ronin/database/migrations/create_licenses_table.rb +1 -1
  19. data/lib/ronin/database/migrations/create_passwords_table.rb +1 -1
  20. data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb} +4 -4
  21. data/lib/ronin/database/migrations/migration.rb +3 -6
  22. data/lib/ronin/database/migrations/migrations.rb +3 -3
  23. data/lib/ronin/email_address.rb +20 -3
  24. data/lib/ronin/environment.rb +0 -3
  25. data/lib/ronin/host_name.rb +20 -6
  26. data/lib/ronin/host_name_ip_address.rb +2 -3
  27. data/lib/ronin/installation.rb +92 -23
  28. data/lib/ronin/ip_address.rb +31 -8
  29. data/lib/ronin/ip_address_mac_address.rb +2 -3
  30. data/lib/ronin/license.rb +1 -1
  31. data/lib/ronin/mac_address.rb +6 -4
  32. data/lib/ronin/model/class_methods.rb +4 -0
  33. data/lib/ronin/model/has_authors/class_methods.rb +4 -0
  34. data/lib/ronin/model/has_authors/has_authors.rb +4 -0
  35. data/lib/ronin/model/has_description/class_methods.rb +2 -0
  36. data/lib/ronin/model/has_description/has_description.rb +2 -0
  37. data/lib/ronin/model/has_license/class_methods.rb +2 -0
  38. data/lib/ronin/model/has_license/has_license.rb +4 -0
  39. data/lib/ronin/model/has_name/class_methods.rb +2 -0
  40. data/lib/ronin/model/has_name/has_name.rb +4 -0
  41. data/lib/ronin/model/has_title/class_methods.rb +2 -0
  42. data/lib/ronin/model/has_title/has_title.rb +2 -0
  43. data/lib/ronin/model/has_unique_name/class_methods.rb +2 -0
  44. data/lib/ronin/model/has_unique_name/has_unique_name.rb +7 -1
  45. data/lib/ronin/model/has_version/class_methods.rb +4 -0
  46. data/lib/ronin/model/has_version/has_version.rb +2 -0
  47. data/lib/ronin/model/model.rb +2 -0
  48. data/lib/ronin/model/types.rb +1 -7
  49. data/lib/ronin/model/types/description.rb +2 -0
  50. data/lib/ronin/network/mixins/esmtp.rb +40 -25
  51. data/lib/ronin/network/mixins/http.rb +336 -73
  52. data/lib/ronin/network/mixins/imap.rb +38 -25
  53. data/lib/ronin/network/mixins/pop3.rb +34 -21
  54. data/lib/ronin/network/mixins/smtp.rb +40 -25
  55. data/lib/ronin/network/mixins/tcp.rb +66 -41
  56. data/lib/ronin/network/mixins/telnet.rb +43 -30
  57. data/lib/ronin/network/mixins/udp.rb +59 -40
  58. data/lib/ronin/open_port.rb +12 -5
  59. data/lib/ronin/organization.rb +1 -2
  60. data/lib/ronin/os.rb +10 -3
  61. data/lib/ronin/os_guess.rb +2 -3
  62. data/lib/ronin/password.rb +11 -3
  63. data/lib/ronin/port.rb +7 -2
  64. data/lib/ronin/{engine/exceptions/deploy_failed.rb → repositories.rb} +4 -6
  65. data/lib/ronin/repository.rb +110 -37
  66. data/lib/ronin/ronin.rb +4 -3
  67. data/lib/ronin/{engine.rb → script.rb} +2 -1
  68. data/lib/ronin/{engine → script}/buildable.rb +43 -29
  69. data/lib/ronin/script/class_methods.rb +84 -0
  70. data/lib/ronin/{engine → script}/deployable.rb +61 -40
  71. data/lib/ronin/{engine → script}/exceptions.rb +4 -3
  72. data/lib/ronin/script/exceptions/deploy_failed.rb +27 -0
  73. data/lib/ronin/{engine/exceptions/not_built.rb → script/exceptions/exception.rb} +2 -2
  74. data/lib/ronin/{engine/exceptions/verification_failed.rb → script/exceptions/not_built.rb} +4 -2
  75. data/lib/ronin/script/exceptions/test_failed.rb +27 -0
  76. data/lib/ronin/script/instance_methods.rb +217 -0
  77. data/lib/ronin/script/path.rb +277 -0
  78. data/lib/ronin/{engine/engine.rb → script/script.rb} +52 -15
  79. data/lib/ronin/{engine/verifiable.rb → script/testable.rb} +97 -68
  80. data/lib/ronin/service.rb +1 -2
  81. data/lib/ronin/service_credential.rb +1 -2
  82. data/lib/ronin/software.rb +3 -2
  83. data/lib/ronin/spec/database.rb +0 -4
  84. data/lib/ronin/target.rb +11 -3
  85. data/lib/ronin/tcp_port.rb +3 -2
  86. data/lib/ronin/udp_port.rb +2 -0
  87. data/lib/ronin/ui/cli/cli.rb +6 -0
  88. data/lib/ronin/ui/cli/command.rb +48 -12
  89. data/lib/ronin/ui/cli/commands/campaigns.rb +3 -3
  90. data/lib/ronin/ui/cli/commands/console.rb +2 -1
  91. data/lib/ronin/ui/cli/commands/creds.rb +3 -3
  92. data/lib/ronin/ui/cli/commands/database.rb +1 -17
  93. data/lib/ronin/ui/cli/commands/emails.rb +3 -3
  94. data/lib/ronin/ui/cli/commands/hosts.rb +3 -7
  95. data/lib/ronin/ui/cli/commands/ips.rb +3 -7
  96. data/lib/ronin/ui/cli/commands/repos.rb +5 -17
  97. data/lib/ronin/ui/cli/commands/urls.rb +3 -3
  98. data/lib/ronin/ui/cli/model_command.rb +82 -97
  99. data/lib/ronin/ui/cli/resources_command.rb +89 -0
  100. data/lib/ronin/ui/cli/script_command.rb +115 -0
  101. data/lib/ronin/ui/console.rb +17 -3
  102. data/lib/ronin/ui/output/helpers.rb +18 -0
  103. data/lib/ronin/ui/output/output.rb +20 -1
  104. data/lib/ronin/ui/output/terminal/color.rb +10 -0
  105. data/lib/ronin/ui/output/terminal/raw.rb +10 -0
  106. data/lib/ronin/ui/shell.rb +2 -0
  107. data/lib/ronin/url.rb +47 -12
  108. data/lib/ronin/url_query_param.rb +4 -0
  109. data/lib/ronin/url_scheme.rb +3 -3
  110. data/lib/ronin/user_name.rb +2 -0
  111. data/lib/ronin/version.rb +1 -1
  112. data/lib/ronin/web_credential.rb +6 -3
  113. data/spec/arch_spec.rb +3 -3
  114. data/spec/classes/my_script.rb +21 -0
  115. data/spec/helpers/repos/{test1 → installed}/ronin.yml +1 -1
  116. data/spec/helpers/repos/{hello/cache → installed/scripts}/.keep +0 -0
  117. data/spec/helpers/repos/local/lib/init.rb +1 -0
  118. data/spec/helpers/repos/{hello → local}/lib/stuff/another_test.rb +0 -0
  119. data/spec/helpers/repos/{hello → local}/lib/stuff/test.rb +0 -0
  120. data/spec/helpers/repos/{random → local}/ronin.yml +1 -1
  121. data/spec/helpers/repos/{random/cache → local/scripts}/.keep +0 -0
  122. data/spec/helpers/repos/{hello → remote}/ronin.yml +1 -1
  123. data/spec/helpers/repos/remote/scripts/.keep +0 -0
  124. data/spec/helpers/repos/{test2 → scripts}/ronin.yml +0 -0
  125. data/spec/helpers/repos/scripts/scripts/cached/cached.rb +10 -0
  126. data/spec/helpers/repos/scripts/scripts/cached/missing.rb +10 -0
  127. data/spec/helpers/repos/scripts/scripts/cached/modified.rb +10 -0
  128. data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +10 -0
  129. data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +11 -0
  130. data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/load_errors.rb +3 -1
  131. data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/name_errors.rb +1 -0
  132. data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +10 -0
  133. data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +11 -0
  134. data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +11 -0
  135. data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +16 -0
  136. data/spec/model/spec_helper.rb +0 -2
  137. data/spec/repository_spec.rb +61 -81
  138. data/spec/ronin_spec.rb +2 -2
  139. data/spec/{engine → script}/buildable_spec.rb +9 -9
  140. data/spec/script/classes/buildable_class.rb +15 -0
  141. data/spec/script/classes/deployable_class.rb +13 -0
  142. data/spec/{engine/classes/engine_class.rb → script/classes/script_class.rb} +3 -3
  143. data/spec/{engine/classes/verifiable_class.rb → script/classes/testable_class.rb} +5 -5
  144. data/spec/{engine → script}/deployable_spec.rb +10 -10
  145. data/spec/{cached_file_spec.rb → script/path_spec.rb} +33 -72
  146. data/spec/script/script_spec.rb +130 -0
  147. data/spec/script/testable_spec.rb +117 -0
  148. data/spec/spec_helper.rb +15 -13
  149. metadata +114 -139
  150. data/lib/ronin/cached_file.rb +0 -247
  151. data/lib/ronin/engine/class_methods.rb +0 -135
  152. data/lib/ronin/engine/instance_methods.rb +0 -97
  153. data/lib/ronin/model/cacheable.rb +0 -21
  154. data/lib/ronin/model/cacheable/cacheable.rb +0 -273
  155. data/lib/ronin/model/cacheable/class_methods.rb +0 -60
  156. data/lib/ronin/ui/cli/engine_command.rb +0 -106
  157. data/spec/engine/classes/buildable_class.rb +0 -15
  158. data/spec/engine/classes/deployable_class.rb +0 -13
  159. data/spec/engine/engine_spec.rb +0 -55
  160. data/spec/engine/verifiable_spec.rb +0 -117
  161. data/spec/helpers/repos/hello/lib/init.rb +0 -1
  162. data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +0 -15
  163. data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +0 -7
  164. data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +0 -9
  165. data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +0 -7
  166. data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +0 -15
  167. data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +0 -9
  168. data/spec/model/cacheable_spec.rb +0 -96
  169. data/spec/model/models/cacheable_model.rb +0 -13
@@ -1,15 +0,0 @@
1
- require 'ronin/engine'
2
- require 'ronin/engine/buildable'
3
-
4
- class BuildableClass
5
-
6
- include Ronin::Engine
7
- include Ronin::Engine::Buildable
8
-
9
- property :id, Serial
10
-
11
- parameter :var, :default => 'world'
12
-
13
- attr_reader :output
14
-
15
- end
@@ -1,13 +0,0 @@
1
- require 'ronin/engine'
2
- require 'ronin/engine/deployable'
3
-
4
- class DeployableClass
5
-
6
- include Ronin::Engine
7
- include Ronin::Engine::Deployable
8
-
9
- property :id, Serial
10
-
11
- parameter :var, :default => 5
12
-
13
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/engine'
3
- require 'engine/classes/engine_class'
4
-
5
- describe Engine do
6
- subject { EngineClass }
7
-
8
- it "should be a Model" do
9
- subject.included_modules.should include(Model)
10
- end
11
-
12
- it "should have a name" do
13
- subject.included_modules.should include(Model::HasName)
14
- end
15
-
16
- it "should have a description" do
17
- subject.included_modules.should include(Model::HasDescription)
18
- end
19
-
20
- it "should have a version" do
21
- subject.included_modules.should include(Model::HasVersion)
22
- end
23
-
24
- it "should include Model::Cacheable" do
25
- subject.included_modules.should include(Model::Cacheable)
26
- end
27
-
28
- it "should include Parameters" do
29
- subject.included_modules.should include(Parameters)
30
- end
31
-
32
- it "should initialize attributes" do
33
- resource = subject.new(:name => 'test')
34
-
35
- resource.name.should == 'test'
36
- end
37
-
38
- it "should initialize parameters" do
39
- resource = subject.new(:x => 5)
40
-
41
- resource.x.should == 5
42
- end
43
-
44
- it "should allow custom initialize methods" do
45
- resource = subject.new
46
-
47
- resource.y.should == 2
48
- end
49
-
50
- it "should have an engine-name" do
51
- resource = subject.new
52
-
53
- resource.engine_name.should == 'EngineClass'
54
- end
55
- end
@@ -1,117 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/engine/verifiable'
3
- require 'engine/classes/verifiable_class'
4
-
5
- describe Engine::Verifiable do
6
- subject { VerifiableClass }
7
-
8
- it "should allow for custom verifications" do
9
- obj = subject.new do
10
- verify do
11
- flunk('var must be greater than 2') unless self.var > 2
12
- end
13
-
14
- verify do
15
- flunk('var must be less than 10') unless self.var < 10
16
- end
17
- end
18
-
19
- obj.var = 20
20
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
21
-
22
- obj.var = 4
23
- obj.verify!.should == true
24
- end
25
-
26
- it "should verify an expression is true" do
27
- obj = subject.new do
28
- verify? 'var + 2 must equal 4' do
29
- (self.var + 2) == 4
30
- end
31
- end
32
-
33
- obj.var = 1
34
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
35
-
36
- obj.var = 2
37
- obj.verify!.should == true
38
- end
39
-
40
- it "should verify a method returns an expected value" do
41
- obj = subject.new { verify_equal :var, 5 }
42
-
43
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
44
-
45
- obj.var = 5
46
- obj.verify!.should == true
47
- end
48
-
49
- it "should verify a method does not return an expected value" do
50
- obj = subject.new { verify_not_equal :var, 5 }
51
-
52
- obj.var = 5
53
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
54
-
55
- obj.var = 2
56
- obj.verify!.should == true
57
- end
58
-
59
- it "should verify a method returns a non-nil value" do
60
- obj = subject.new { verify_set :var }
61
-
62
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
63
-
64
- obj.var = 2
65
- obj.verify!.should == true
66
- end
67
-
68
- it "should verify a method returns a non-empty value" do
69
- obj = subject.new { verify_set :var }
70
-
71
- obj.var = ''
72
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
73
-
74
- obj.var = 'hello'
75
- obj.verify!.should == true
76
- end
77
-
78
- it "should verify a method matches a pattern" do
79
- obj = subject.new { verify_match :var, /lo/ }
80
-
81
- obj.var = 'goodbye'
82
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
83
-
84
- obj.var = 'hello'
85
- obj.verify!.should == true
86
- end
87
-
88
- it "should verify a method does not match a pattern" do
89
- obj = subject.new { verify_no_match :var, /lo/ }
90
-
91
- obj.var = 'hello'
92
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
93
-
94
- obj.var = 'goodbye'
95
- obj.verify!.should == true
96
- end
97
-
98
- it "should verify a method returns a value in a set of values" do
99
- obj = subject.new { verify_in :var, [0, 2, 4, 8] }
100
-
101
- obj.var = 3
102
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
103
-
104
- obj.var = 2
105
- obj.verify!.should == true
106
- end
107
-
108
- it "should verify a method returns a value not in a set of values" do
109
- obj = subject.new { verify_not_in :var, [0, 2, 4, 8] }
110
-
111
- obj.var = 2
112
- lambda { obj.verify! }.should raise_error(Engine::VerificationFailed)
113
-
114
- obj.var = 3
115
- obj.verify!.should == true
116
- end
117
- end
@@ -1 +0,0 @@
1
- $hello_repo_loaded = true
@@ -1,15 +0,0 @@
1
- require 'model/models/cacheable_model'
2
-
3
- CacheableModel.object do
4
-
5
- @var = 1
6
-
7
- cache do
8
- self.content = 'this is test one'
9
- end
10
-
11
- def greeting
12
- 'hello'
13
- end
14
-
15
- end
@@ -1,7 +0,0 @@
1
- require 'model/models/cacheable_model'
2
-
3
- CacheableModel.object do
4
-
5
- raise("Exception when caching a file")
6
-
7
- end
@@ -1,9 +0,0 @@
1
- require 'model/models/cacheable_model'
2
-
3
- CacheableModel.objectttttt do
4
-
5
- cache do
6
- self.content = 'this is a NoMethodError test'
7
- end
8
-
9
- end
@@ -1,7 +0,0 @@
1
- require 'model/models/cacheable_model'
2
-
3
- CacheableModel.object do
4
-
5
- def
6
-
7
- end
@@ -1,15 +0,0 @@
1
- require 'model/models/cacheable_model'
2
-
3
- CacheableModel.object do
4
-
5
- @var = 2
6
-
7
- cache do
8
- self.content = 'this is test two'
9
- end
10
-
11
- def greeting
12
- 'hello'
13
- end
14
-
15
- end
@@ -1,9 +0,0 @@
1
- require 'model/models/cacheable_model'
2
-
3
- CacheableModel.object do
4
-
5
- cache do
6
- # intentionally do not set the content property
7
- end
8
-
9
- end
@@ -1,96 +0,0 @@
1
- require 'model/spec_helper'
2
- require 'model/models/cacheable_model'
3
- require 'helpers/repositories'
4
-
5
- require 'ronin/model/cacheable'
6
-
7
- describe Model::Cacheable do
8
- include Helpers::Repositories
9
-
10
- let(:repo) { repository('test1') }
11
-
12
- subject { CacheableModel }
13
-
14
- before(:all) { repo.cache_files! }
15
-
16
- it "should include Ronin::Model" do
17
- subject.ancestors.should include(Model)
18
- end
19
-
20
- it "should add the type property to the model" do
21
- subject.properties.should be_named(:type)
22
- end
23
-
24
- it "should add a relation between CachedFile and the model" do
25
- subject.relationships.should be_named(:cached_file)
26
- end
27
-
28
- it "should add the class to Cacheable.models" do
29
- Model::Cacheable.models.should include(subject)
30
- end
31
-
32
- describe "load_from" do
33
- let(:path) { repo.cached_files.first.path }
34
-
35
- subject { Model::Cacheable.load_from(path) }
36
-
37
- it "should have a cached_file resource" do
38
- subject.cached_file.should_not be_nil
39
- end
40
-
41
- it "should have a cache_path" do
42
- subject.cache_path.should == path
43
- end
44
-
45
- it "should prepare the object to be cached" do
46
- subject.content.should == 'this is test one'
47
- end
48
-
49
- it "should preserve instance variables" do
50
- subject.var.should == 1
51
- end
52
-
53
- it "should preserve instance methods" do
54
- subject.greeting.should == 'hello'
55
- end
56
-
57
- it "should load the original code" do
58
- subject.should be_original_loaded
59
- end
60
- end
61
-
62
- context "previously cached" do
63
- subject { CacheableModel.first }
64
-
65
- it "should have a cached_file resource" do
66
- subject.cached_file.should_not be_nil
67
- end
68
-
69
- it "should have a cache_path" do
70
- subject.cache_path.should be_file
71
- end
72
-
73
- it "should load the context block" do
74
- subject.class.load_context_block(subject.cache_path).should_not be_nil
75
- end
76
-
77
- it "should be able to load the original object" do
78
- subject.load_original!
79
-
80
- subject.greeting.should == 'hello'
81
- end
82
-
83
- it "should load the original object on demand" do
84
- subject.greeting.should == 'hello'
85
- end
86
-
87
- it "should only load the original object once" do
88
- subject.load_original!
89
-
90
- subject.var = false
91
- subject.load_original!
92
-
93
- subject.var.should == false
94
- end
95
- end
96
- end
@@ -1,13 +0,0 @@
1
- require 'ronin/model/cacheable'
2
-
3
- class CacheableModel
4
-
5
- include Ronin::Model::Cacheable
6
-
7
- property :id, Serial
8
-
9
- property :content, String, :required => true
10
-
11
- attr_accessor :var
12
-
13
- end