ronin 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +21 -0
- data/Manifest.txt +17 -6
- data/README.txt +3 -2
- data/Rakefile +1 -0
- data/bin/ronin-add +12 -0
- data/bin/ronin-console +12 -0
- data/bin/ronin-ext +12 -0
- data/bin/ronin-help +12 -0
- data/bin/ronin-install +12 -0
- data/bin/ronin-ls +12 -0
- data/bin/ronin-overlay +12 -0
- data/bin/ronin-rm +12 -0
- data/bin/ronin-uninstall +12 -0
- data/bin/ronin-update +12 -0
- data/lib/ronin/extensions/string.rb +5 -3
- data/lib/ronin/platform/extension.rb +8 -2
- data/lib/ronin/platform/overlay.rb +16 -32
- data/lib/ronin/ui.rb +1 -1
- data/lib/ronin/ui/command_line.rb +1 -1
- data/lib/ronin/ui/command_line/command.rb +42 -60
- data/lib/ronin/ui/command_line/command_line.rb +28 -50
- data/lib/ronin/ui/command_line/commands/add.rb +41 -40
- data/lib/ronin/ui/command_line/commands/{default.rb → console.rb} +28 -21
- data/lib/ronin/ui/command_line/commands/{extension.rb → ext.rb} +25 -27
- data/lib/ronin/ui/command_line/commands/help.rb +26 -28
- data/lib/ronin/ui/command_line/commands/install.rb +32 -32
- data/lib/ronin/ui/command_line/commands/ls.rb +123 -0
- data/lib/ronin/ui/command_line/commands/overlay.rb +115 -114
- data/lib/ronin/ui/command_line/commands/{remove.rb → rm.rb} +27 -29
- data/lib/ronin/ui/command_line/commands/uninstall.rb +27 -29
- data/lib/ronin/ui/command_line/commands/update.rb +28 -30
- data/lib/ronin/ui/command_line/options.rb +0 -12
- data/lib/ronin/ui/command_line/param_parser.rb +34 -14
- data/lib/ronin/ui/console.rb +1 -0
- data/lib/ronin/ui/diagnostics.rb +5 -19
- data/lib/ronin/ui/{command_line/commands.rb → verbose.rb} +19 -11
- data/lib/ronin/version.rb +1 -1
- data/spec/arch_spec.rb +24 -24
- data/spec/chars/chars_spec.rb +49 -13
- data/spec/extensions/string_spec.rb +6 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/ui/command_line/helpers/example_command.rb +21 -0
- data/spec/ui/command_line/param_parser_spec.rb +9 -18
- data/spec/ui/verbose_spec.rb +17 -0
- metadata +39 -8
- data/lib/ronin/ui/command_line/commands/list.rb +0 -122
- data/spec/ui/diagnostics_spec.rb +0 -17
@@ -21,10 +21,11 @@
|
|
21
21
|
#++
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'ronin/ui/command_line/commands/default'
|
25
24
|
require 'ronin/ui/command_line/exceptions/unknown_command'
|
25
|
+
require 'ronin/ui/command_line/commands/console'
|
26
26
|
require 'ronin/ui/console'
|
27
|
-
|
27
|
+
|
28
|
+
require 'reverse_require'
|
28
29
|
|
29
30
|
module Ronin
|
30
31
|
module UI
|
@@ -33,15 +34,20 @@ module Ronin
|
|
33
34
|
# Returns the commands registered with the command-line utility.
|
34
35
|
#
|
35
36
|
def CommandLine.commands
|
36
|
-
@@ronin_commands
|
37
|
-
|
37
|
+
unless class_variable_defined?('@@ronin_commands')
|
38
|
+
paths = Gem.find_resources('bin/ronin-*')
|
39
|
+
|
40
|
+
@@ronin_commands = {}
|
41
|
+
|
42
|
+
paths.each do |path|
|
43
|
+
next unless File.executable?(path)
|
44
|
+
name = File.basename(path).gsub(/^ronin-/,'')
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@@ronin_commands_by_name ||= {}
|
46
|
+
@@ronin_commands[name] ||= path
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
return @@ronin_commands
|
45
51
|
end
|
46
52
|
|
47
53
|
#
|
@@ -49,7 +55,7 @@ module Ronin
|
|
49
55
|
# registered with the command-line utility.
|
50
56
|
#
|
51
57
|
def CommandLine.has_command?(name)
|
52
|
-
CommandLine.
|
58
|
+
CommandLine.commands.has_key?(name.to_s)
|
53
59
|
end
|
54
60
|
|
55
61
|
#
|
@@ -63,27 +69,7 @@ module Ronin
|
|
63
69
|
raise(UnknownCommand,"unknown command #{name.dump}",caller)
|
64
70
|
end
|
65
71
|
|
66
|
-
return CommandLine.
|
67
|
-
end
|
68
|
-
|
69
|
-
#
|
70
|
-
# Prints the specified error _message_.
|
71
|
-
#
|
72
|
-
def CommandLine.error(message)
|
73
|
-
STDERR.puts "ronin: #{message}"
|
74
|
-
return false
|
75
|
-
end
|
76
|
-
|
77
|
-
#
|
78
|
-
# Prints the given error _message_ and exits unseccessfully from the
|
79
|
-
# command-line utility. If a _block_ is given, it will be called before
|
80
|
-
# any error _message_ are printed.
|
81
|
-
#
|
82
|
-
def CommandLine.fail(message,&block)
|
83
|
-
block.call(self) if block
|
84
|
-
|
85
|
-
CommandLine.error(message)
|
86
|
-
exit -1
|
72
|
+
return CommandLine.commands[name]
|
87
73
|
end
|
88
74
|
|
89
75
|
#
|
@@ -92,26 +78,18 @@ module Ronin
|
|
92
78
|
# attempt to find and execute the Command with the same name.
|
93
79
|
#
|
94
80
|
def CommandLine.run(*argv)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
argv = argv[1..-1]
|
81
|
+
if (argv.empty? || argv[0][0..0]=='-')
|
82
|
+
Commands::Console.run(*argv)
|
83
|
+
else
|
84
|
+
cmd = argv.first
|
85
|
+
argv = argv[1..-1]
|
101
86
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
exit -1
|
108
|
-
end
|
109
|
-
else
|
110
|
-
CommandLine.fail("unknown command #{cmd.dump}")
|
111
|
-
end
|
87
|
+
begin
|
88
|
+
exec(CommandLine.get_command(cmd),*argv)
|
89
|
+
rescue UnknownCommand => e
|
90
|
+
STDERR.puts e
|
91
|
+
exit -1
|
112
92
|
end
|
113
|
-
rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
|
114
|
-
CommandLine.fail(e)
|
115
93
|
end
|
116
94
|
|
117
95
|
return true
|
@@ -27,63 +27,64 @@ require 'ronin/platform/overlay'
|
|
27
27
|
module Ronin
|
28
28
|
module UI
|
29
29
|
module CommandLine
|
30
|
-
|
30
|
+
module Commands
|
31
|
+
class Add < Command
|
31
32
|
|
32
|
-
|
33
|
+
def defaults
|
34
|
+
@cache = nil
|
35
|
+
@media = nil
|
36
|
+
@uri = nil
|
37
|
+
end
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
@media = nil
|
37
|
-
@uri = nil
|
39
|
+
def define_options(opts)
|
40
|
+
opts.usage = 'PATH [options]'
|
38
41
|
|
39
|
-
|
40
|
-
|
42
|
+
opts.options do
|
43
|
+
opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
|
44
|
+
@cache = dir
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
|
47
|
+
opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
|
48
|
+
@media = media
|
49
|
+
end
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
51
|
+
opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri|
|
52
|
+
@uri = uri
|
53
|
+
end
|
49
54
|
|
50
|
-
|
51
|
-
|
55
|
+
opts.on('-L','--local','Similiar to: --media local') do
|
56
|
+
@media = :local
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
|
-
opts.
|
55
|
-
|
56
|
-
|
60
|
+
opts.arguments(
|
61
|
+
'PATH' => 'Add the overlay located at the specified PATH'
|
62
|
+
)
|
57
63
|
|
58
|
-
opts.
|
59
|
-
|
60
|
-
|
64
|
+
opts.summary %{
|
65
|
+
Add a local overlay located at the specified PATH to the
|
66
|
+
Overlay cache
|
67
|
+
}
|
61
68
|
end
|
62
69
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
opts.summary('Add a local overlay located at the specified PATH to the Overlay cache')
|
68
|
-
end
|
69
|
-
|
70
|
-
def arguments(*args)
|
71
|
-
unless args.length == 1
|
72
|
-
fail('only one overlay path maybe specified')
|
73
|
-
end
|
70
|
+
def arguments(*args)
|
71
|
+
unless args.length == 1
|
72
|
+
fail('only one overlay path maybe specified')
|
73
|
+
end
|
74
74
|
|
75
|
-
|
75
|
+
Platform.load_overlays(@cache) if @cache
|
76
76
|
|
77
|
-
|
77
|
+
overlay_options = {:path => args.first}
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
overlay_options[:media] = @media if @media
|
80
|
+
overlay_options[:uri] = @uri if @uri
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
Platform.add(overlay_options) do |overlay|
|
83
|
+
puts "Overlay #{overlay.name.dump} added."
|
84
|
+
end
|
84
85
|
end
|
85
|
-
end
|
86
86
|
|
87
|
+
end
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|
@@ -22,42 +22,49 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
require 'ronin/ui/command_line/command'
|
25
|
+
require 'ronin/ui/verbose'
|
25
26
|
require 'ronin/ui/console'
|
26
27
|
require 'ronin/database'
|
27
28
|
|
28
29
|
module Ronin
|
29
30
|
module UI
|
30
31
|
module CommandLine
|
31
|
-
|
32
|
+
module Commands
|
33
|
+
class Console < Command
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def define_options(opts)
|
36
|
+
opts.usage = '<command> [options]'
|
37
|
+
opts.options do
|
38
|
+
opts.on('-D','--database URI','The URI for the Database') do |uri|
|
39
|
+
Database.config = uri.to_s
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
opts.on('-r','--require LIB','Require the specified library or path') do |lib|
|
43
|
+
UI::Console.auto_load << lib.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on('-v','--verbose','Enables verbose output') do
|
47
|
+
UI::Verbose.enable!
|
48
|
+
end
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
opts.on('-V','--version','Print version information and exit') do
|
51
|
+
success do
|
52
|
+
puts "Ronin #{Ronin::VERSION}"
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
56
|
+
|
57
|
+
opts.summary %{
|
58
|
+
Ronin is a Ruby development platform designed for information
|
59
|
+
security and data exploration tasks.
|
60
|
+
}
|
49
61
|
end
|
50
62
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
55
|
-
end
|
63
|
+
def arguments(*args)
|
64
|
+
UI::Console.start
|
65
|
+
end
|
56
66
|
|
57
|
-
def arguments(*args)
|
58
|
-
Console.start
|
59
67
|
end
|
60
|
-
|
61
68
|
end
|
62
69
|
end
|
63
70
|
end
|
@@ -31,41 +31,39 @@ require 'erb'
|
|
31
31
|
module Ronin
|
32
32
|
module UI
|
33
33
|
module CommandLine
|
34
|
-
|
34
|
+
module Commands
|
35
|
+
class Ext < Command
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@uses = []
|
40
|
-
|
41
|
-
super
|
42
|
-
end
|
37
|
+
def defaults
|
38
|
+
@uses = []
|
39
|
+
end
|
43
40
|
|
44
|
-
|
45
|
-
|
41
|
+
def define_options(opts)
|
42
|
+
opts.usage = 'PATH [...]'
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
opts.arguments(
|
45
|
+
'PATH' => 'The PATH of the Extension to be created'
|
46
|
+
)
|
50
47
|
|
51
|
-
|
52
|
-
|
48
|
+
opts.summary('Create an empty Extension at the specified PATH')
|
49
|
+
end
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
def arguments(*args)
|
52
|
+
args.each do |path|
|
53
|
+
path = File.expand_path(path)
|
54
|
+
extension_path = File.join(path,Platform::Extension::EXTENSION_FILE)
|
55
|
+
lib_dir = File.join(path,Platform::Extension::LIB_DIR)
|
56
|
+
template_path = File.join(Config::STATIC_DIR,'extension.rb')
|
60
57
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
FileUtils.mkdir_p(path)
|
59
|
+
FileUtils.mkdir_p(lib_dir)
|
60
|
+
FileUtils.touch(File.join(lib_dir,File.basename(path) + '.rb'))
|
61
|
+
FileUtils.mkdir_p(File.join(lib_dir,File.basename(path)))
|
62
|
+
FileUtils.cp(template_path,extension_path)
|
63
|
+
end
|
66
64
|
end
|
67
|
-
end
|
68
65
|
|
66
|
+
end
|
69
67
|
end
|
70
68
|
end
|
71
69
|
end
|
@@ -22,48 +22,46 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
require 'ronin/ui/command_line/command'
|
25
|
+
require 'ronin/ui/command_line/command_line'
|
25
26
|
|
26
27
|
module Ronin
|
27
28
|
module UI
|
28
29
|
module CommandLine
|
29
|
-
|
30
|
+
module Commands
|
31
|
+
class Help < Command
|
30
32
|
|
31
|
-
|
33
|
+
def define_options(opts)
|
34
|
+
opts.usage = '[COMMAND]'
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
opts.arguments(
|
37
|
+
'COMMAND' => 'The command to view'
|
38
|
+
)
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
opts.summary %{
|
41
|
+
View a list of supported commands or information on a
|
42
|
+
specific command
|
43
|
+
}
|
44
|
+
end
|
39
45
|
|
40
|
-
|
41
|
-
|
46
|
+
def arguments(*args)
|
47
|
+
if args.length > 1
|
48
|
+
fail('only one command maybe specified')
|
49
|
+
end
|
42
50
|
|
43
|
-
|
44
|
-
if args.length > 1
|
45
|
-
fail('only one command maybe specified')
|
46
|
-
end
|
51
|
+
topic = args.first
|
47
52
|
|
48
|
-
|
53
|
+
if topic
|
54
|
+
CommandLine.run(topic,'--help')
|
55
|
+
else
|
56
|
+
puts 'Available commands:'
|
49
57
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
rescue UnknownCommand => exp
|
54
|
-
CommandLine.fail(exp)
|
58
|
+
CommandLine.commands.keys.sort.each do |name|
|
59
|
+
puts " #{name}"
|
60
|
+
end
|
55
61
|
end
|
56
|
-
else
|
57
|
-
puts 'Available commands:'
|
58
|
-
|
59
|
-
CommandLine.commands.sort_by { |cmd|
|
60
|
-
cmd.command_names.first
|
61
|
-
}.each { |cmd|
|
62
|
-
puts " #{cmd.command_names.join(', ')}"
|
63
|
-
}
|
64
62
|
end
|
65
|
-
end
|
66
63
|
|
64
|
+
end
|
67
65
|
end
|
68
66
|
end
|
69
67
|
end
|
@@ -27,51 +27,51 @@ require 'ronin/platform/overlay'
|
|
27
27
|
module Ronin
|
28
28
|
module UI
|
29
29
|
module CommandLine
|
30
|
-
|
30
|
+
module Commands
|
31
|
+
class Install < Command
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@media = nil
|
33
|
+
def defaults
|
34
|
+
@cache = nil
|
35
|
+
@media = nil
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
def define_options(opts)
|
39
|
+
opts.usage = 'URI [options]'
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
opts.options do
|
42
|
+
opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
|
43
|
+
@cache = dir
|
44
|
+
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
opts.on('-m','--media [MEDIA]','Spedify the media-type of the overlay') do |media|
|
47
|
+
@media = media
|
48
|
+
end
|
47
49
|
end
|
48
50
|
|
49
|
-
opts.
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
opts.arguments(
|
55
|
-
'URI' => 'The URI of the overlay to install'
|
56
|
-
)
|
51
|
+
opts.arguments(
|
52
|
+
'URI' => 'The URI of the overlay to install'
|
53
|
+
)
|
57
54
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
def arguments(args)
|
62
|
-
unless args.length == 1
|
63
|
-
fail('only one overlay URI maybe specified')
|
55
|
+
opts.summary %{
|
56
|
+
Installs the overlay located at the specified URI
|
57
|
+
}
|
64
58
|
end
|
65
59
|
|
66
|
-
|
60
|
+
def arguments(args)
|
61
|
+
unless args.length == 1
|
62
|
+
fail('only one overlay URI maybe specified')
|
63
|
+
end
|
64
|
+
|
65
|
+
uri = args.first
|
67
66
|
|
68
|
-
|
67
|
+
Platform.load_overlays(@cache) if @cache
|
69
68
|
|
70
|
-
|
71
|
-
|
69
|
+
Platform.install(:uri => uri, :media => @media) do |overlay|
|
70
|
+
puts "Overlay #{overlay.name.dump} has been installed."
|
71
|
+
end
|
72
72
|
end
|
73
|
-
end
|
74
73
|
|
74
|
+
end
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|