ronin 1.3.0 → 1.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +51 -1
- data/Gemfile +1 -1
- data/README.md +36 -41
- data/bin/ronin-install +25 -0
- data/bin/ronin-uninstall +25 -0
- data/bin/ronin-update +25 -0
- data/gemspec.yml +4 -4
- data/lib/bond/completions/ronin.rb +6 -5
- data/lib/ronin/address.rb +0 -2
- data/lib/ronin/auto_load.rb +4 -5
- data/lib/ronin/campaign.rb +1 -0
- data/lib/ronin/credential.rb +6 -5
- data/lib/ronin/database/database.rb +1 -0
- data/lib/ronin/email_address.rb +28 -3
- data/lib/ronin/environment.rb +3 -6
- data/lib/ronin/host_name.rb +1 -3
- data/lib/ronin/host_name_ip_address.rb +0 -2
- data/lib/ronin/ip_address.rb +1 -4
- data/lib/ronin/ip_address_mac_address.rb +0 -2
- data/lib/ronin/mac_address.rb +0 -2
- data/lib/ronin/model/has_unique_name.rb +17 -0
- data/lib/ronin/open_port.rb +0 -4
- data/lib/ronin/organization.rb +0 -1
- data/lib/ronin/os.rb +0 -2
- data/lib/ronin/os_guess.rb +0 -2
- data/lib/ronin/password.rb +17 -1
- data/lib/ronin/port.rb +34 -1
- data/lib/ronin/repository.rb +31 -25
- data/lib/ronin/script/buildable.rb +19 -4
- data/lib/ronin/script/deployable.rb +7 -8
- data/lib/ronin/script/exceptions.rb +1 -0
- data/lib/ronin/script/exceptions/build_failed.rb +27 -0
- data/lib/ronin/script/path.rb +28 -11
- data/lib/ronin/script/script.rb +17 -14
- data/lib/ronin/script/testable.rb +3 -3
- data/lib/ronin/service.rb +0 -1
- data/lib/ronin/service_credential.rb +0 -1
- data/lib/ronin/software.rb +0 -1
- data/lib/ronin/target.rb +0 -2
- data/lib/ronin/tcp_port.rb +0 -1
- data/lib/ronin/ui/cli/class_command.rb +130 -0
- data/lib/ronin/ui/cli/command.rb +344 -159
- data/lib/ronin/ui/cli/commands/campaigns.rb +39 -29
- data/lib/ronin/ui/cli/commands/console.rb +24 -15
- data/lib/ronin/ui/cli/commands/creds.rb +14 -12
- data/lib/ronin/ui/cli/commands/database.rb +63 -46
- data/lib/ronin/ui/cli/commands/emails.rb +15 -15
- data/lib/ronin/ui/cli/commands/help.rb +6 -5
- data/lib/ronin/ui/cli/commands/hosts.rb +24 -24
- data/lib/ronin/ui/cli/commands/install.rb +104 -0
- data/lib/ronin/ui/cli/commands/ips.rb +23 -23
- data/lib/ronin/ui/cli/commands/repos.rb +69 -182
- data/lib/ronin/ui/cli/commands/uninstall.rb +65 -0
- data/lib/ronin/ui/cli/commands/update.rb +100 -0
- data/lib/ronin/ui/cli/commands/urls.rb +24 -24
- data/lib/ronin/ui/cli/model_command.rb +8 -6
- data/lib/ronin/ui/cli/printing.rb +167 -0
- data/lib/ronin/ui/cli/resources_command.rb +21 -13
- data/lib/ronin/ui/cli/script_command.rb +126 -24
- data/lib/ronin/ui/console/commands.rb +4 -1
- data/lib/ronin/ui/console/console.rb +1 -1
- data/lib/ronin/ui/console/context.rb +1 -1
- data/lib/ronin/url.rb +24 -5
- data/lib/ronin/url_query_param.rb +0 -1
- data/lib/ronin/version.rb +1 -1
- data/lib/ronin/web_credential.rb +0 -5
- data/spec/email_address_spec.rb +17 -0
- data/spec/installation_spec.rb +24 -34
- data/spec/model/has_authors_spec.rb +1 -1
- data/spec/model/has_description_spec.rb +1 -1
- data/spec/model/has_license_spec.rb +1 -1
- data/spec/model/has_name_spec.rb +1 -1
- data/spec/model/has_title_spec.rb +1 -1
- data/spec/model/has_version_spec.rb +1 -1
- data/spec/model/model_spec.rb +1 -1
- data/spec/repository_spec.rb +9 -9
- data/spec/script/script_spec.rb +2 -4
- data/spec/spec_helper.rb +16 -0
- data/spec/ui/cli/classes/test_command.rb +7 -3
- data/spec/ui/cli/command_spec.rb +37 -5
- metadata +82 -73
- data/spec/model/spec_helper.rb +0 -20
data/lib/ronin/environment.rb
CHANGED
@@ -21,13 +21,10 @@
|
|
21
21
|
# Loads all extensions to core Ruby classes.
|
22
22
|
#
|
23
23
|
require 'ronin/ronin'
|
24
|
-
require 'ronin/
|
25
|
-
require 'ronin/formatting/extensions'
|
26
|
-
require 'ronin/network/extensions'
|
27
|
-
require 'ronin/ui/output/helpers'
|
24
|
+
require 'ronin/support'
|
28
25
|
|
29
26
|
#
|
30
|
-
# Includes the Ronin namespace and
|
27
|
+
# Includes the Ronin namespace and additional helper methods.
|
31
28
|
#
|
32
29
|
include Ronin
|
33
|
-
include Ronin::
|
30
|
+
include Ronin::Support
|
data/lib/ronin/host_name.rb
CHANGED
@@ -21,9 +21,7 @@ require 'ronin/extensions/regexp'
|
|
21
21
|
require 'ronin/extensions/resolv'
|
22
22
|
require 'ronin/model/importable'
|
23
23
|
require 'ronin/address'
|
24
|
-
require 'ronin/
|
25
|
-
require 'ronin/email_address'
|
26
|
-
require 'ronin/url'
|
24
|
+
require 'ronin/ip_address'
|
27
25
|
|
28
26
|
require 'uri/generic'
|
29
27
|
require 'strscan'
|
data/lib/ronin/ip_address.rb
CHANGED
@@ -21,10 +21,7 @@ require 'ronin/extensions/ip_addr'
|
|
21
21
|
require 'ronin/extensions/resolv'
|
22
22
|
require 'ronin/model/importable'
|
23
23
|
require 'ronin/address'
|
24
|
-
require 'ronin/
|
25
|
-
require 'ronin/host_name_ip_address'
|
26
|
-
require 'ronin/os'
|
27
|
-
require 'ronin/open_port'
|
24
|
+
require 'ronin/host_name'
|
28
25
|
|
29
26
|
require 'ipaddr'
|
30
27
|
|
data/lib/ronin/mac_address.rb
CHANGED
@@ -51,6 +51,23 @@ module Ronin
|
|
51
51
|
# Class methods that will be added when {HasUniqueName} is included.
|
52
52
|
#
|
53
53
|
module ClassMethods
|
54
|
+
#
|
55
|
+
# Parses a unique name.
|
56
|
+
#
|
57
|
+
# @param [String] name
|
58
|
+
# The name to parse.
|
59
|
+
#
|
60
|
+
# @return [Model]
|
61
|
+
# A new or previously saved resource.
|
62
|
+
#
|
63
|
+
# @since 1.4.0
|
64
|
+
#
|
65
|
+
# @api public
|
66
|
+
#
|
67
|
+
def parse(name)
|
68
|
+
first_or_new(:name => name.strip)
|
69
|
+
end
|
70
|
+
|
54
71
|
#
|
55
72
|
# Searches for models with the unique name.
|
56
73
|
#
|
data/lib/ronin/open_port.rb
CHANGED
data/lib/ronin/organization.rb
CHANGED
data/lib/ronin/os.rb
CHANGED
data/lib/ronin/os_guess.rb
CHANGED
data/lib/ronin/password.rb
CHANGED
@@ -18,7 +18,6 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/model'
|
21
|
-
require 'ronin/credential'
|
22
21
|
|
23
22
|
require 'digest'
|
24
23
|
|
@@ -44,6 +43,23 @@ module Ronin
|
|
44
43
|
# The user names which use the password
|
45
44
|
has 0..n, :user_names, :through => :credentials
|
46
45
|
|
46
|
+
#
|
47
|
+
# Parses a password.
|
48
|
+
#
|
49
|
+
# @param [#to_s] password
|
50
|
+
# The password to parse.
|
51
|
+
#
|
52
|
+
# @return [Password]
|
53
|
+
# The parsed password.
|
54
|
+
#
|
55
|
+
# @since 1.4.0
|
56
|
+
#
|
57
|
+
# @api public
|
58
|
+
#
|
59
|
+
def self.parse(password)
|
60
|
+
first_or_new(:clear_text => password.to_s)
|
61
|
+
end
|
62
|
+
|
47
63
|
#
|
48
64
|
# Hashes the password.
|
49
65
|
#
|
data/lib/ronin/port.rb
CHANGED
@@ -18,7 +18,6 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/model'
|
21
|
-
require 'ronin/open_port'
|
22
21
|
|
23
22
|
module Ronin
|
24
23
|
#
|
@@ -47,6 +46,40 @@ module Ronin
|
|
47
46
|
|
48
47
|
validates_uniqueness_of :number, :scope => [:protocol]
|
49
48
|
|
49
|
+
#
|
50
|
+
# Creates a new Port.
|
51
|
+
#
|
52
|
+
# @param [String, Integer] number
|
53
|
+
# The port number.
|
54
|
+
#
|
55
|
+
# @return [Port]
|
56
|
+
# The new or previously saved port.
|
57
|
+
#
|
58
|
+
# @since 1.4.0
|
59
|
+
#
|
60
|
+
# @api public
|
61
|
+
#
|
62
|
+
def self.from(number)
|
63
|
+
first_or_new(:number => number)
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Parses a port number.
|
68
|
+
#
|
69
|
+
# @param [String, Integer] number
|
70
|
+
# The port number to parse.
|
71
|
+
#
|
72
|
+
# @return [Port]
|
73
|
+
# The parsed port.
|
74
|
+
#
|
75
|
+
# @since 1.4.0
|
76
|
+
#
|
77
|
+
# @api public
|
78
|
+
#
|
79
|
+
def self.parse(number)
|
80
|
+
from(number.to_i)
|
81
|
+
end
|
82
|
+
|
50
83
|
#
|
51
84
|
# Converts the port to an integer.
|
52
85
|
#
|
data/lib/ronin/repository.rb
CHANGED
@@ -19,7 +19,9 @@
|
|
19
19
|
|
20
20
|
require 'ronin/exceptions/duplicate_repository'
|
21
21
|
require 'ronin/exceptions/repository_not_found'
|
22
|
-
require 'ronin/
|
22
|
+
require 'ronin/model/has_name'
|
23
|
+
require 'ronin/model/has_title'
|
24
|
+
require 'ronin/model/has_description'
|
23
25
|
require 'ronin/model/has_license'
|
24
26
|
require 'ronin/model/has_authors'
|
25
27
|
require 'ronin/model'
|
@@ -39,6 +41,9 @@ module Ronin
|
|
39
41
|
class Repository
|
40
42
|
|
41
43
|
include Model
|
44
|
+
include Model::HasName
|
45
|
+
include Model::HasTitle
|
46
|
+
include Model::HasDescription
|
42
47
|
include Model::HasAuthors
|
43
48
|
include Model::HasLicense
|
44
49
|
include DataPaths
|
@@ -81,7 +86,7 @@ module Ronin
|
|
81
86
|
property :installed, Boolean, :default => false
|
82
87
|
|
83
88
|
# Name of the repository
|
84
|
-
property :name, String, :default =>
|
89
|
+
property :name, String, :default => proc { |repo,name|
|
85
90
|
repo.path.basename
|
86
91
|
}
|
87
92
|
|
@@ -146,15 +151,15 @@ module Ronin
|
|
146
151
|
def initialize(attributes={})
|
147
152
|
super(attributes)
|
148
153
|
|
149
|
-
@bin_dir
|
150
|
-
@lib_dir
|
151
|
-
@data_dir
|
154
|
+
@bin_dir = self.path.join(BIN_DIR)
|
155
|
+
@lib_dir = self.path.join(LIB_DIR)
|
156
|
+
@data_dir = self.path.join(DATA_DIR)
|
152
157
|
@script_dirs = SCRIPT_DIRS.map { |dir| self.path.join(dir) }
|
153
158
|
|
154
|
-
@activated = false
|
155
|
-
|
156
159
|
initialize_metadata
|
157
160
|
|
161
|
+
@activated = false
|
162
|
+
|
158
163
|
yield self if block_given?
|
159
164
|
end
|
160
165
|
|
@@ -217,7 +222,7 @@ module Ronin
|
|
217
222
|
#
|
218
223
|
# @api private
|
219
224
|
#
|
220
|
-
def Repository.add
|
225
|
+
def Repository.add(options={})
|
221
226
|
unless options.has_key?(:path)
|
222
227
|
raise(ArgumentError,"the :path option was not given")
|
223
228
|
end
|
@@ -234,9 +239,9 @@ module Ronin
|
|
234
239
|
|
235
240
|
# create the repository
|
236
241
|
repo = Repository.new(options.merge(
|
237
|
-
:path
|
242
|
+
:path => path,
|
238
243
|
:installed => false,
|
239
|
-
:domain
|
244
|
+
:domain => LOCAL_DOMAIN
|
240
245
|
))
|
241
246
|
|
242
247
|
if Repository.count(:name => repo.name, :domain => repo.domain) > 0
|
@@ -284,13 +289,14 @@ module Ronin
|
|
284
289
|
#
|
285
290
|
# @api private
|
286
291
|
#
|
287
|
-
def Repository.install
|
292
|
+
def Repository.install(options={})
|
288
293
|
unless options[:uri]
|
289
294
|
raise(ArgumentError,":uri must be passed to Repository.install")
|
290
295
|
end
|
291
296
|
|
292
297
|
remote_repo = Pullr::RemoteRepository.new(options)
|
293
|
-
|
298
|
+
|
299
|
+
name = remote_repo.name
|
294
300
|
domain = if remote_repo.uri.scheme
|
295
301
|
remote_repo.uri.host
|
296
302
|
else
|
@@ -310,12 +316,12 @@ module Ronin
|
|
310
316
|
|
311
317
|
# add the new remote repository
|
312
318
|
repo = Repository.new(
|
313
|
-
:path
|
314
|
-
:scm
|
315
|
-
:uri
|
319
|
+
:path => path,
|
320
|
+
:scm => local_repo.scm,
|
321
|
+
:uri => remote_repo.uri,
|
316
322
|
:installed => true,
|
317
|
-
:name
|
318
|
-
:domain
|
323
|
+
:name => name,
|
324
|
+
:domain => domain
|
319
325
|
)
|
320
326
|
|
321
327
|
# save the repository
|
@@ -359,14 +365,14 @@ module Ronin
|
|
359
365
|
# @return [nil]
|
360
366
|
#
|
361
367
|
# @example Uninstall the repository with the given name
|
362
|
-
# Repository.uninstall
|
368
|
+
# Repository.uninstall('postmodern-repo')
|
363
369
|
#
|
364
370
|
# @example Uninstall the repository with the given name and domain.
|
365
|
-
# Repository.uninstall
|
371
|
+
# Repository.uninstall('postmodern-repo/github.com')
|
366
372
|
#
|
367
373
|
# @api private
|
368
374
|
#
|
369
|
-
def Repository.uninstall
|
375
|
+
def Repository.uninstall(name)
|
370
376
|
Repository.find(name).uninstall!
|
371
377
|
end
|
372
378
|
|
@@ -600,7 +606,6 @@ module Ronin
|
|
600
606
|
|
601
607
|
# deactivates the repository
|
602
608
|
deactivate!
|
603
|
-
|
604
609
|
return self
|
605
610
|
end
|
606
611
|
|
@@ -615,6 +620,7 @@ module Ronin
|
|
615
620
|
# @api private
|
616
621
|
#
|
617
622
|
def clean_scripts!
|
623
|
+
self.script_paths.destroy
|
618
624
|
self.script_paths.clear
|
619
625
|
return self
|
620
626
|
end
|
@@ -640,7 +646,7 @@ module Ronin
|
|
640
646
|
def update!
|
641
647
|
local_repo = Pullr::LocalRepository.new(
|
642
648
|
:path => self.path,
|
643
|
-
:scm
|
649
|
+
:scm => self.scm
|
644
650
|
)
|
645
651
|
|
646
652
|
# only update if we have a repository
|
@@ -711,11 +717,11 @@ module Ronin
|
|
711
717
|
def initialize_metadata
|
712
718
|
metadata_path = self.path.join(METADATA_FILE)
|
713
719
|
|
714
|
-
self.title
|
720
|
+
self.title = self.name
|
715
721
|
self.description = nil
|
716
|
-
self.license
|
722
|
+
self.license = nil
|
717
723
|
|
718
|
-
self.source
|
724
|
+
self.source = self.uri
|
719
725
|
self.website = self.source
|
720
726
|
self.authors.clear
|
721
727
|
|
@@ -18,6 +18,7 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'ronin/script/exceptions/not_built'
|
21
|
+
require 'ronin/script/exceptions/build_failed'
|
21
22
|
require 'ronin/script/testable'
|
22
23
|
require 'ronin/ui/output/helpers'
|
23
24
|
|
@@ -80,15 +81,15 @@ module Ronin
|
|
80
81
|
#
|
81
82
|
def build!(options={})
|
82
83
|
self.params = options
|
83
|
-
print_debug "#{
|
84
|
+
print_debug "#{self.class.short_name} #{self} parameters: #{self.params.inspect}"
|
84
85
|
|
85
|
-
print_info "Building #{
|
86
|
+
print_info "Building #{self.class.short_name} #{self} ..."
|
86
87
|
|
87
88
|
@built = false
|
88
89
|
@build_blocks.each { |block| block.call() }
|
89
90
|
@built = true
|
90
91
|
|
91
|
-
print_info "#{
|
92
|
+
print_info "#{self.class.short_name} #{self} built!"
|
92
93
|
|
93
94
|
yield if block_given?
|
94
95
|
return self
|
@@ -111,7 +112,7 @@ module Ronin
|
|
111
112
|
#
|
112
113
|
def test!
|
113
114
|
unless built?
|
114
|
-
raise(NotBuilt,"cannot verify an unbuilt #{
|
115
|
+
raise(NotBuilt,"cannot verify an unbuilt #{self.class.short_name}")
|
115
116
|
end
|
116
117
|
|
117
118
|
super
|
@@ -119,6 +120,20 @@ module Ronin
|
|
119
120
|
|
120
121
|
protected
|
121
122
|
|
123
|
+
#
|
124
|
+
# Indicates the build has failed.
|
125
|
+
#
|
126
|
+
# @raise [BuildFailed]
|
127
|
+
# The building of the script failed.
|
128
|
+
#
|
129
|
+
# @since 1.4.0
|
130
|
+
#
|
131
|
+
# @api public
|
132
|
+
#
|
133
|
+
def build_failed!(message)
|
134
|
+
raise(BuildFailed,message)
|
135
|
+
end
|
136
|
+
|
122
137
|
#
|
123
138
|
# Registers a given block to be called when the script is built.
|
124
139
|
#
|
@@ -67,8 +67,7 @@ module Ronin
|
|
67
67
|
end
|
68
68
|
|
69
69
|
#
|
70
|
-
# Tests and then deploys the
|
71
|
-
# the payload will also be deployed.
|
70
|
+
# Tests and then deploys the script.
|
72
71
|
#
|
73
72
|
# @yield []
|
74
73
|
# If a block is given, it will be passed the deployed script
|
@@ -86,14 +85,14 @@ module Ronin
|
|
86
85
|
def deploy!
|
87
86
|
test!
|
88
87
|
|
89
|
-
print_info "Deploying #{
|
88
|
+
print_info "Deploying #{self.class.short_name} #{self} ..."
|
90
89
|
|
91
90
|
@deployed = false
|
92
91
|
@deploy_blocks.each { |block| block.call() }
|
93
92
|
@deployed = true
|
94
93
|
@evacuated = false
|
95
94
|
|
96
|
-
print_info "#{
|
95
|
+
print_info "#{self.class.short_name} #{self} deployed!"
|
97
96
|
|
98
97
|
yield if block_given?
|
99
98
|
return self
|
@@ -132,24 +131,24 @@ module Ronin
|
|
132
131
|
def evacuate!
|
133
132
|
yield if block_given?
|
134
133
|
|
135
|
-
print_info "Evauating #{
|
134
|
+
print_info "Evauating #{self.class.short_name} #{self} ..."
|
136
135
|
|
137
136
|
@evacuated = false
|
138
137
|
@evacuate_blocks.each { |block| block.call() }
|
139
138
|
@evacuated = true
|
140
139
|
@deployed = false
|
141
140
|
|
142
|
-
print_info "#{
|
141
|
+
print_info "#{self.class.short_name} #{self} evacuated."
|
143
142
|
return self
|
144
143
|
end
|
145
144
|
|
146
145
|
protected
|
147
146
|
|
148
147
|
#
|
149
|
-
# Indicates the deployment of the
|
148
|
+
# Indicates the deployment of the script has failed.
|
150
149
|
#
|
151
150
|
# @raise [DeployFailed]
|
152
|
-
# The deployment of the
|
151
|
+
# The deployment of the script failed.
|
153
152
|
#
|
154
153
|
# @since 1.1.0
|
155
154
|
#
|