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.
Files changed (47) hide show
  1. data/History.txt +21 -0
  2. data/Manifest.txt +17 -6
  3. data/README.txt +3 -2
  4. data/Rakefile +1 -0
  5. data/bin/ronin-add +12 -0
  6. data/bin/ronin-console +12 -0
  7. data/bin/ronin-ext +12 -0
  8. data/bin/ronin-help +12 -0
  9. data/bin/ronin-install +12 -0
  10. data/bin/ronin-ls +12 -0
  11. data/bin/ronin-overlay +12 -0
  12. data/bin/ronin-rm +12 -0
  13. data/bin/ronin-uninstall +12 -0
  14. data/bin/ronin-update +12 -0
  15. data/lib/ronin/extensions/string.rb +5 -3
  16. data/lib/ronin/platform/extension.rb +8 -2
  17. data/lib/ronin/platform/overlay.rb +16 -32
  18. data/lib/ronin/ui.rb +1 -1
  19. data/lib/ronin/ui/command_line.rb +1 -1
  20. data/lib/ronin/ui/command_line/command.rb +42 -60
  21. data/lib/ronin/ui/command_line/command_line.rb +28 -50
  22. data/lib/ronin/ui/command_line/commands/add.rb +41 -40
  23. data/lib/ronin/ui/command_line/commands/{default.rb → console.rb} +28 -21
  24. data/lib/ronin/ui/command_line/commands/{extension.rb → ext.rb} +25 -27
  25. data/lib/ronin/ui/command_line/commands/help.rb +26 -28
  26. data/lib/ronin/ui/command_line/commands/install.rb +32 -32
  27. data/lib/ronin/ui/command_line/commands/ls.rb +123 -0
  28. data/lib/ronin/ui/command_line/commands/overlay.rb +115 -114
  29. data/lib/ronin/ui/command_line/commands/{remove.rb → rm.rb} +27 -29
  30. data/lib/ronin/ui/command_line/commands/uninstall.rb +27 -29
  31. data/lib/ronin/ui/command_line/commands/update.rb +28 -30
  32. data/lib/ronin/ui/command_line/options.rb +0 -12
  33. data/lib/ronin/ui/command_line/param_parser.rb +34 -14
  34. data/lib/ronin/ui/console.rb +1 -0
  35. data/lib/ronin/ui/diagnostics.rb +5 -19
  36. data/lib/ronin/ui/{command_line/commands.rb → verbose.rb} +19 -11
  37. data/lib/ronin/version.rb +1 -1
  38. data/spec/arch_spec.rb +24 -24
  39. data/spec/chars/chars_spec.rb +49 -13
  40. data/spec/extensions/string_spec.rb +6 -6
  41. data/spec/spec_helper.rb +1 -1
  42. data/spec/ui/command_line/helpers/example_command.rb +21 -0
  43. data/spec/ui/command_line/param_parser_spec.rb +9 -18
  44. data/spec/ui/verbose_spec.rb +17 -0
  45. metadata +39 -8
  46. data/lib/ronin/ui/command_line/commands/list.rb +0 -122
  47. data/spec/ui/diagnostics_spec.rb +0 -17
@@ -0,0 +1,123 @@
1
+ #
2
+ #--
3
+ # Ronin - A Ruby platform designed for information security and data
4
+ # exploration tasks.
5
+ #
6
+ # Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
7
+ #
8
+ # This program is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program; if not, write to the Free Software
20
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ #++
22
+ #
23
+
24
+ require 'ronin/ui/command_line/command'
25
+ require 'ronin/platform/overlay'
26
+
27
+ module Ronin
28
+ module UI
29
+ module CommandLine
30
+ module Commands
31
+ class LS < Command
32
+
33
+ def defaults
34
+ @cache = nil
35
+ @verbose = false
36
+ end
37
+
38
+ def define_options(opts)
39
+ opts.usage = '[NAME ...] [options]'
40
+
41
+ opts.options do
42
+ opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
43
+ @cache = dir
44
+ end
45
+
46
+ opts.on('-v','--verbose','Enable verbose output') do
47
+ @verbose = true
48
+ end
49
+ end
50
+
51
+ opts.arguments(
52
+ 'NAME' => 'Overlay to display'
53
+ )
54
+
55
+ opts.summary %{
56
+ Display all or the specified repositories within the Overlay
57
+ cache
58
+ }
59
+ end
60
+
61
+ def arguments(*args)
62
+ Platform.load_overlays(@cache) if @cache
63
+
64
+ if args.empty?
65
+ # list all overlays by name
66
+ Platform.overlays.each_overlay do |overlay|
67
+ puts " #{overlay}"
68
+ end
69
+
70
+ return
71
+ end
72
+
73
+ # list specified overlays
74
+ args.each do |name|
75
+ overlay = Platform.overlays.get(name)
76
+
77
+ puts "[ #{overlay.name} ]\n\n"
78
+
79
+ puts " Path: #{overlay.path}"
80
+ puts " Media: #{overlay.media}" if overlay.media
81
+ puts " URI: #{overlay.uri}" if overlay.uri
82
+
83
+ if @verbose
84
+ putc "\n"
85
+
86
+ if overlay.title
87
+ puts " Title: #{overlay.title}"
88
+ end
89
+
90
+ if overlay.source
91
+ puts " Source URI: #{overlay.source}"
92
+ end
93
+
94
+ if overlay.source_view
95
+ puts " Source View: #{overlay.source_view}"
96
+ end
97
+
98
+ if overlay.website
99
+ puts " Website: #{overlay.website}"
100
+ end
101
+
102
+ unless overlay.extensions.empty?
103
+ puts " Extensions:\n\n"
104
+ overlay.extensions.each { |ext| puts " #{ext}" }
105
+ putc "\n"
106
+ end
107
+
108
+ if overlay.description
109
+ puts " Description:\n\n #{overlay.description}\n\n"
110
+ else
111
+ putc "\n"
112
+ end
113
+ else
114
+ putc "\n"
115
+ end
116
+ end
117
+ end
118
+
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
@@ -26,162 +26,163 @@ require 'ronin/platform/overlay'
26
26
  require 'ronin/version'
27
27
 
28
28
  require 'fileutils'
29
- require 'rexml/document'
29
+ require 'nokogiri'
30
30
 
31
31
  module Ronin
32
32
  module UI
33
33
  module CommandLine
34
- class OverlayCommand < Command
34
+ module Commands
35
+ class Overlay < Command
36
+
37
+ include Nokogiri
38
+
39
+ def defaults
40
+ @title = nil
41
+ @source = nil
42
+ @source_view = nil
43
+ @website = nil
44
+ @license = nil
45
+ @maintainers = []
46
+ @description = nil
47
+ end
35
48
 
36
- include REXML
49
+ def define_options(opts)
50
+ opts.usage = '[options] PATH'
37
51
 
38
- command :overlay
52
+ opts.options do
53
+ opts.on('-t','--title NAME','Name of the Overlay') do |title|
54
+ @title = title
55
+ end
39
56
 
40
- def initialize
41
- @title = nil
42
- @source = nil
43
- @source_view = nil
44
- @website = nil
45
- @license = nil
46
- @maintainers = []
47
- @description = nil
57
+ opts.on('-S','--source URL','The URL where the source of the Overlay will be hosted') do |url|
58
+ @source = url
59
+ end
48
60
 
49
- super
50
- end
61
+ opts.on('-V','--source-view URL','The URL for viewing the contents of the Overlay') do |url|
62
+ @source_view = url
63
+ end
51
64
 
52
- def define_options(opts)
53
- opts.usage = '[options] PATH'
65
+ opts.on('-U','--website URL','The URL of the website of the Overlay') do |url|
66
+ @website = url
67
+ end
54
68
 
55
- opts.options do
56
- opts.on('-t','--title NAME','Name of the Overlay') do |title|
57
- @title = title
58
- end
69
+ opts.on('-L','--license LICENSE','The license of the contents of the Overlay') do |license|
70
+ @license = license
71
+ end
59
72
 
60
- opts.on('-S','--source URL','The URL where the source of the Overlay will be hosted') do |url|
61
- @source = url
62
- end
73
+ opts.on('-m','--maintainer "NAME <EMAIL>"','Name of a maintainer of the Overlay') do |text|
74
+ name = text.scan(/^[^<]+[^<\s]/).first
75
+ email = text.scan(/<([^<>]+)>\s*$/).first
63
76
 
64
- opts.on('-V','--source-view URL','The URL for viewing the contents of the Overlay') do |url|
65
- @source_view = url
66
- end
77
+ email = email.first if email
67
78
 
68
- opts.on('-U','--website URL','The URL of the website of the Overlay') do |url|
69
- @website = url
70
- end
79
+ @maintainers << {:name => name, :email => email}
80
+ end
71
81
 
72
- opts.on('-L','--license LICENSE','The license of the contents of the Overlay') do |license|
73
- @license = license
82
+ opts.on('-D','--description TEXT','The description for the Overlay') do |text|
83
+ @description = text
84
+ end
74
85
  end
75
86
 
76
- opts.on('-m','--maintainer "NAME <EMAIL>"','Name of a maintainer of the Overlay') do |text|
77
- name = text.scan(/^[^<]+[^<\s]/).first
78
- email = text.scan(/<([^<>]+)>\s*$/).first
87
+ opts.arguments(
88
+ 'PATH' => 'The PATH of the Overlay to be created'
89
+ )
79
90
 
80
- email = email.first if email
81
-
82
- @maintainers << {:name => name, :email => email}
83
- end
84
-
85
- opts.on('-D','--description TEXT','The description for the Overlay') do |text|
86
- @description = text
87
- end
91
+ opts.summary('Create an empty Overlay at the specified PATH')
88
92
  end
89
93
 
90
- opts.arguments(
91
- 'PATH' => 'The PATH of the Overlay to be created'
92
- )
93
-
94
- opts.summary('Create an empty Overlay at the specified PATH')
95
- end
94
+ def arguments(*args)
95
+ unless args.length == 1
96
+ fail('only one Overlay path maybe specified')
97
+ end
96
98
 
97
- def arguments(*args)
98
- unless args.length == 1
99
- fail('only one Overlay path maybe specified')
100
- end
99
+ path = File.expand_path(args.first)
101
100
 
102
- path = File.expand_path(args.first)
101
+ @title ||= File.basename(path).gsub(/[_\s]+/,' ').capitalize
102
+ @source_view ||= @source
103
+ @website ||= @source_view
103
104
 
104
- @title ||= File.basename(path).gsub(/[_\s]+/,' ').capitalize
105
- @source_view ||= @source
106
- @website ||= @source_view
105
+ FileUtils.mkdir_p(path)
106
+ FileUtils.mkdir_p(File.join(path,'lib'))
107
+ FileUtils.mkdir_p(File.join(path,'objects'))
107
108
 
108
- FileUtils.mkdir_p(path)
109
- FileUtils.mkdir_p(File.join(path,'lib'))
110
- FileUtils.mkdir_p(File.join(path,'objects'))
109
+ File.open(File.join(path,Platform::Overlay::METADATA_FILE),'w') do |file|
110
+ doc = XML::Document.new
111
+ doc << XML::ProcessingInstruction.new(
112
+ doc,
113
+ 'xml-stylesheet',
114
+ 'type="text/xsl" href="http://ronin.rubyforge.org/dist/overlay.xsl"'
115
+ )
111
116
 
112
- File.open(File.join(path,Platform::Overlay::METADATA_FILE),'w') do |file|
113
- doc = Document.new
114
- doc.add(XMLDecl.new)
115
- doc.add(Instruction.new('xml-stylesheet','type="text/xsl" href="http://ronin.rubyforge.org/dist/overlay.xsl"'))
117
+ root = XML::Node.new('ronin-overlay',doc)
118
+ root['version'] = Ronin::VERSION
116
119
 
117
- root = Element.new('ronin-overlay')
118
- root.attributes['version'] = Ronin::VERSION
120
+ title_tag = XML::Node.new('title',doc)
121
+ title_tag << XML::Text.new(@title,doc)
122
+ root << title_tag
119
123
 
120
- title_tag = Element.new('title')
121
- title_tag.text = @title
122
- root.add_element(title_tag)
124
+ if @source
125
+ source_tag = XML::Node.new('source',doc)
126
+ source_tag << XML::Text.new(@source,doc)
127
+ root << source_tag
128
+ end
123
129
 
124
- if @source
125
- source_tag = Element.new('source')
126
- source_tag.text = @source
127
- root.add_element(source_tag)
128
- end
130
+ if @source_view
131
+ source_view_tag = XML::Node.new('source-view',doc)
132
+ source_view_tag << XML::Text.new(@source_view,doc)
133
+ root << source_view_tag
134
+ end
129
135
 
130
- if @source_view
131
- source_view_tag = Element.new('source-view')
132
- source_view_tag.text = @source_view
133
- root.add_element(source_view_tag)
134
- end
136
+ if @website
137
+ url_tag = XML::Node.new('website',doc)
138
+ url_tag << XML::Text.new(@website,doc)
139
+ root << url_tag
140
+ end
135
141
 
136
- if @website
137
- url_tag = Element.new('website')
138
- url_tag.text = @website
139
- root.add_element(url_tag)
140
- end
142
+ if @license
143
+ license_tag = XML::Node.new('license',doc)
144
+ license_tag << XML::Text.new(@license,doc)
145
+ root << license_tag
146
+ end
141
147
 
142
- if @license
143
- license_tag = Element.new('license')
144
- license_tag.text = @license
145
- root.add_element(license_tag)
146
- end
148
+ unless @maintainers.empty?
149
+ maintainers_tag = XML::Node.new('maintainers',doc)
147
150
 
148
- unless @maintainers.empty?
149
- maintainers_tag = Element.new('maintainers')
151
+ @maintainers.each do |author|
152
+ if (author[:name] || author[:email])
153
+ maintainer_tag = XML::Node.new('maintainer',doc)
150
154
 
151
- @maintainers.each do |author|
152
- if (author[:name] || author[:email])
153
- maintainer_tag = Element.new('maintainer')
155
+ if author[:name]
156
+ name_tag = XML::Node.new('name',doc)
157
+ name_tag << XML::Text.new(author[:name],doc)
158
+ maintainer_tag << name_tag
159
+ end
154
160
 
155
- if author[:name]
156
- name_tag = Element.new('name')
157
- name_tag.text = author[:name]
158
- maintainer_tag.add_element(name_tag)
159
- end
161
+ if author[:email]
162
+ email_tag = XML::Node.new('email',doc)
163
+ email_tag << XML::Text.new(author[:email],doc)
164
+ maintainer_tag << email_tag
165
+ end
160
166
 
161
- if author[:email]
162
- email_tag = Element.new('email')
163
- email_tag.text = author[:email]
164
- maintainer_tag.add_element(email_tag)
167
+ maintainers_tag << maintainer_tag
165
168
  end
166
-
167
- maintainers_tag.add_element(maintainer_tag)
168
169
  end
170
+
171
+ root << maintainers_tag
169
172
  end
170
173
 
171
- root.add_element(maintainers_tag)
172
- end
174
+ if @description
175
+ description_tag = XML::Node.new('description',doc)
176
+ description_tag << XML::Text.new(@description,doc)
177
+ root << description_tag
178
+ end
173
179
 
174
- if @description
175
- description_tag = Element.new('description')
176
- description_tag.text = @description
177
- root.add_element(description_tag)
180
+ doc << root
181
+ doc.write_xml_to(file)
178
182
  end
179
-
180
- doc.add_element(root)
181
- doc.write(file,2)
182
183
  end
183
- end
184
184
 
185
+ end
185
186
  end
186
187
  end
187
188
  end
@@ -27,47 +27,45 @@ require 'ronin/platform/overlay'
27
27
  module Ronin
28
28
  module UI
29
29
  module CommandLine
30
- class RemoveCommand < Command
30
+ module Commands
31
+ class RM < Command
31
32
 
32
- command :remove, :rm
33
-
34
- def initialize
35
- @cache = nil
36
- @verbose = false
37
-
38
- super
39
- end
33
+ def defaults
34
+ @cache = nil
35
+ @verbose = false
36
+ end
40
37
 
41
- def define_options(opts)
42
- opts.usage = 'NAME [...] [options]'
38
+ def define_options(opts)
39
+ opts.usage = 'NAME [...] [options]'
43
40
 
44
- opts.options do
45
- opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
46
- @cache = dir
47
- end
41
+ opts.options do
42
+ opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
43
+ @cache = dir
44
+ end
48
45
 
49
- opts.on('-v','--verbose','Enable verbose output') do
50
- @verbose = true
46
+ opts.on('-v','--verbose','Enable verbose output') do
47
+ @verbose = true
48
+ end
51
49
  end
52
- end
53
50
 
54
- opts.arguments(
55
- 'NAME' => 'The overlay to remove'
56
- )
51
+ opts.arguments(
52
+ 'NAME' => 'The overlay to remove'
53
+ )
57
54
 
58
- opts.summary('Remove the specified repositories')
59
- end
55
+ opts.summary('Remove the specified repositories')
56
+ end
60
57
 
61
- def arguments(*args)
62
- Platform.load_overlays(@cache) if @cache
58
+ def arguments(*args)
59
+ Platform.load_overlays(@cache) if @cache
63
60
 
64
- args.each do |name|
65
- Platform.remove(name) do |overlay|
66
- puts "Removing #{overlay.name.dump} ..."
61
+ args.each do |name|
62
+ Platform.remove(name) do |overlay|
63
+ puts "Removing #{overlay.name.dump} ..."
64
+ end
67
65
  end
68
66
  end
69
- end
70
67
 
68
+ end
71
69
  end
72
70
  end
73
71
  end