ronin 0.1.4 → 0.2.0

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 (73) hide show
  1. data/History.txt +50 -0
  2. data/Manifest.txt +31 -19
  3. data/README.txt +27 -19
  4. data/Rakefile +1 -1
  5. data/TODO.txt +1 -7
  6. data/lib/ronin.rb +1 -11
  7. data/lib/ronin/database/database.rb +1 -1
  8. data/lib/ronin/{cache/config.rb → environment.rb} +10 -8
  9. data/lib/ronin/formatting.rb +0 -1
  10. data/lib/ronin/formatting/extensions.rb +0 -1
  11. data/lib/ronin/formatting/extensions/binary/integer.rb +10 -0
  12. data/lib/ronin/formatting/extensions/binary/string.rb +11 -0
  13. data/lib/ronin/formatting/extensions/http/string.rb +1 -1
  14. data/lib/ronin/network/extensions/http/net.rb +8 -0
  15. data/lib/ronin/objectify/objectify.rb +0 -47
  16. data/lib/ronin/os.rb +89 -0
  17. data/lib/ronin/platform.rb +4 -77
  18. data/lib/ronin/{cache → platform}/exceptions.rb +2 -2
  19. data/lib/ronin/{cache → platform}/exceptions/extension_not_found.rb +1 -1
  20. data/lib/ronin/{cache → platform}/exceptions/overlay_cached.rb +1 -1
  21. data/lib/ronin/{cache → platform}/exceptions/overlay_not_found.rb +1 -1
  22. data/lib/ronin/{cache → platform}/extension.rb +68 -177
  23. data/lib/ronin/{cache → platform}/extension_cache.rb +9 -7
  24. data/lib/ronin/{cache → platform}/maintainer.rb +1 -1
  25. data/lib/ronin/platform/object_cache.rb +94 -0
  26. data/lib/ronin/platform/overlay.rb +274 -0
  27. data/lib/ronin/platform/overlay_cache.rb +318 -0
  28. data/lib/ronin/platform/platform.rb +195 -0
  29. data/lib/ronin/{cache → platform}/ronin.rb +7 -6
  30. data/lib/ronin/target.rb +5 -5
  31. data/lib/ronin/ui.rb +4 -1
  32. data/lib/ronin/ui/command_line/command_line.rb +0 -1
  33. data/lib/ronin/ui/command_line/commands/add.rb +21 -6
  34. data/lib/ronin/ui/command_line/commands/default.rb +6 -1
  35. data/lib/ronin/ui/command_line/commands/extension.rb +3 -3
  36. data/lib/ronin/ui/command_line/commands/install.rb +16 -5
  37. data/lib/ronin/ui/command_line/commands/list.rb +31 -8
  38. data/lib/ronin/ui/command_line/commands/overlay.rb +10 -9
  39. data/lib/ronin/ui/command_line/commands/remove.rb +16 -5
  40. data/lib/ronin/ui/command_line/commands/uninstall.rb +16 -5
  41. data/lib/ronin/ui/command_line/commands/update.rb +16 -3
  42. data/lib/ronin/ui/console.rb +81 -77
  43. data/lib/ronin/ui/diagnostics.rb +73 -0
  44. data/lib/ronin/version.rb +1 -1
  45. data/spec/chars/chars_spec.rb +1 -3
  46. data/spec/formatting/binary/integer_spec.rb +48 -36
  47. data/spec/formatting/binary/string_spec.rb +66 -4
  48. data/spec/os_spec.rb +24 -0
  49. data/spec/platform/extension_cache_spec.rb +42 -0
  50. data/spec/platform/extension_spec.rb +62 -0
  51. data/spec/platform/helpers/overlays.rb +18 -0
  52. data/spec/platform/helpers/overlays.yaml.erb +10 -0
  53. data/spec/platform/helpers/overlays/hello/hello/extension.rb +7 -0
  54. data/spec/platform/helpers/overlays/hello/ronin.xml +26 -0
  55. data/spec/platform/helpers/overlays/test1/ronin.xml +26 -0
  56. data/spec/platform/helpers/overlays/test1/test/extension.rb +7 -0
  57. data/spec/platform/helpers/overlays/test2/ronin.xml +26 -0
  58. data/spec/platform/helpers/overlays/test2/test/extension.rb +7 -0
  59. data/spec/platform/overlay_cache_spec.rb +63 -0
  60. data/spec/platform/platform_spec.rb +14 -0
  61. data/spec/platform/ronin_spec.rb +22 -0
  62. data/spec/target_spec.rb +1 -1
  63. data/spec/ui/diagnostics_spec.rb +17 -0
  64. metadata +34 -22
  65. data/lib/ronin/cache.rb +0 -27
  66. data/lib/ronin/cache/cache.rb +0 -78
  67. data/lib/ronin/cache/overlay.rb +0 -470
  68. data/lib/ronin/cache/overlay_cache.rb +0 -216
  69. data/lib/ronin/formatting/extensions/html.rb +0 -24
  70. data/lib/ronin/formatting/extensions/html/string.rb +0 -75
  71. data/lib/ronin/formatting/html.rb +0 -24
  72. data/spec/formatting/html_spec.rb +0 -46
  73. data/spec/platform_spec.rb +0 -24
@@ -22,7 +22,7 @@
22
22
  #
23
23
 
24
24
  require 'ronin/ui/command_line/command'
25
- require 'ronin/cache/overlay'
25
+ require 'ronin/platform/overlay'
26
26
  require 'ronin/version'
27
27
 
28
28
  require 'fileutils'
@@ -38,7 +38,7 @@ module Ronin
38
38
  command :overlay
39
39
 
40
40
  def initialize
41
- @name = nil
41
+ @title = nil
42
42
  @source = nil
43
43
  @source_view = nil
44
44
  @website = nil
@@ -53,8 +53,8 @@ module Ronin
53
53
  opts.usage = '[options] PATH'
54
54
 
55
55
  opts.options do
56
- opts.on('-n','--name NAME','Name of the Overlay') do |name|
57
- @name = name
56
+ opts.on('-t','--title NAME','Name of the Overlay') do |title|
57
+ @title = title
58
58
  end
59
59
 
60
60
  opts.on('-S','--source URL','The URL where the source of the Overlay will be hosted') do |url|
@@ -101,14 +101,15 @@ module Ronin
101
101
 
102
102
  path = File.expand_path(args.first)
103
103
 
104
- @name ||= File.basename(path).gsub(/[_\s]+/,' ').capitalize
104
+ @title ||= File.basename(path).gsub(/[_\s]+/,' ').capitalize
105
105
  @source_view ||= @source
106
106
  @website ||= @source_view
107
107
 
108
108
  FileUtils.mkdir_p(path)
109
+ FileUtils.mkdir_p(File.join(path,'lib'))
109
110
  FileUtils.mkdir_p(File.join(path,'objects'))
110
111
 
111
- File.open(File.join(path,Cache::Overlay::METADATA_FILE),'w') do |file|
112
+ File.open(File.join(path,Platform::Overlay::METADATA_FILE),'w') do |file|
112
113
  doc = Document.new
113
114
  doc.add(XMLDecl.new)
114
115
  doc.add(Instruction.new('xml-stylesheet','type="text/xsl" href="http://ronin.rubyforge.org/dist/overlay.xsl"'))
@@ -116,9 +117,9 @@ module Ronin
116
117
  root = Element.new('ronin-overlay')
117
118
  root.attributes['version'] = Ronin::VERSION
118
119
 
119
- name_tag = Element.new('name')
120
- name_tag.text = @name
121
- root.add_element(name_tag)
120
+ title_tag = Element.new('title')
121
+ title_tag.text = @title
122
+ root.add_element(title_tag)
122
123
 
123
124
  if @source
124
125
  source_tag = Element.new('source')
@@ -22,7 +22,7 @@
22
22
  #
23
23
 
24
24
  require 'ronin/ui/command_line/command'
25
- require 'ronin/cache/overlay'
25
+ require 'ronin/platform/overlay'
26
26
 
27
27
  module Ronin
28
28
  module UI
@@ -31,10 +31,21 @@ module Ronin
31
31
 
32
32
  command :remove, :rm
33
33
 
34
+ def initialize
35
+ @cache = nil
36
+ @verbose = false
37
+
38
+ super
39
+ end
40
+
34
41
  def define_options(opts)
35
42
  opts.usage = 'NAME [...] [options]'
36
43
 
37
44
  opts.options do
45
+ opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
46
+ @cache = dir
47
+ end
48
+
38
49
  opts.on('-v','--verbose','Enable verbose output') do
39
50
  @verbose = true
40
51
  end
@@ -48,11 +59,11 @@ module Ronin
48
59
  end
49
60
 
50
61
  def arguments(*args)
62
+ Platform.load_overlays(@cache) if @cache
63
+
51
64
  args.each do |name|
52
- Cache::Overlay.save_cache do
53
- Cache::Overlay.remove(name) do |overlay|
54
- puts "Removing #{overlay.name.dump} ..."
55
- end
65
+ Platform.remove(name) do |overlay|
66
+ puts "Removing #{overlay.name.dump} ..."
56
67
  end
57
68
  end
58
69
  end
@@ -22,7 +22,7 @@
22
22
  #
23
23
 
24
24
  require 'ronin/ui/command_line/command'
25
- require 'ronin/cache/overlay'
25
+ require 'ronin/platform/overlay'
26
26
 
27
27
  module Ronin
28
28
  module UI
@@ -31,10 +31,21 @@ module Ronin
31
31
 
32
32
  command :uninstall
33
33
 
34
+ def initialize
35
+ @cache = nil
36
+ @verbose = false
37
+
38
+ super
39
+ end
40
+
34
41
  def define_options(opts)
35
42
  opts.usage = 'NAME [NAME ...] [options]'
36
43
 
37
44
  opts.options do
45
+ opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
46
+ @cache = dir
47
+ end
48
+
38
49
  opts.on('-v','--verbose','Enable verbose output') do
39
50
  @verbose = true
40
51
  end
@@ -48,11 +59,11 @@ module Ronin
48
59
  end
49
60
 
50
61
  def arguments(*args)
62
+ Platform.load_overlays(@cache) if @cache
63
+
51
64
  args.each do |name|
52
- Cache::Overlay.save_cache do
53
- Cache::Overlay.uninstall(name) do |overlay|
54
- puts "Uninstalling #{overlay.name.dump} ..."
55
- end
65
+ Platform.uninstall(name) do |overlay|
66
+ puts "Uninstalling #{overlay.name.dump} ..."
56
67
  end
57
68
  end
58
69
  end
@@ -22,7 +22,7 @@
22
22
  #
23
23
 
24
24
  require 'ronin/ui/command_line/command'
25
- require 'ronin/cache/overlay'
25
+ require 'ronin/platform/overlay'
26
26
 
27
27
  module Ronin
28
28
  module UI
@@ -31,10 +31,21 @@ module Ronin
31
31
 
32
32
  command :update, :up
33
33
 
34
+ def initialize
35
+ @cache = nil
36
+ @verbose = false
37
+
38
+ super
39
+ end
40
+
34
41
  def define_options(opts)
35
42
  opts.usage = '[NAME ...] [options]'
36
43
 
37
44
  opts.options do
45
+ opts.on('-C','--cache DIR','Specify an alternate overlay cache') do |dir|
46
+ @cache = dir
47
+ end
48
+
38
49
  opts.on('-v','--verbose','Enable verbose output') do
39
50
  @verbose = true
40
51
  end
@@ -48,10 +59,12 @@ module Ronin
48
59
  end
49
60
 
50
61
  def arguments(*args)
62
+ Platform.load_overlays(@cache) if @cache
63
+
51
64
  if args.empty?
52
- Cache::Overlay.each { |overlay| overlay.update }
65
+ Platform.overlays.each_overlay { |overlay| overlay.update }
53
66
  else
54
- args.each { |name| Cache::Overlay.update(name) }
67
+ args.each { |name| Platform.overlays.update(name) }
55
68
  end
56
69
  end
57
70
 
@@ -27,101 +27,105 @@ require 'irb'
27
27
  require 'irb/completion'
28
28
 
29
29
  module Ronin
30
- module Console
31
- #
32
- # Returns the default Console prompt style
33
- #
34
- def Console.prompt
35
- @@ronin_console_prompt ||= :SIMPLE
36
- end
30
+ module UI
31
+ module Console
32
+ #
33
+ # Returns the default Console prompt style
34
+ #
35
+ def Console.prompt
36
+ @@ronin_console_prompt ||= :SIMPLE
37
+ end
37
38
 
38
- #
39
- # Sets the default Console prompt style to the specified _style_.
40
- #
41
- def Console.prompt=(style)
42
- @@ronin_console_prompt = style
43
- end
39
+ #
40
+ # Sets the default Console prompt style to the specified _style_.
41
+ #
42
+ def Console.prompt=(style)
43
+ @@ronin_console_prompt = style
44
+ end
44
45
 
45
- #
46
- # Returns the default Console indent setting.
47
- #
48
- def Console.indent
49
- @@ronin_console_indent ||= true
50
- end
46
+ #
47
+ # Returns the default Console indent setting.
48
+ #
49
+ def Console.indent
50
+ @@ronin_console_indent ||= true
51
+ end
51
52
 
52
- #
53
- # Sets the default Console indent setting.
54
- #
55
- def Console.indent=(value)
56
- @@ronin_console_indent = value
57
- end
53
+ #
54
+ # Sets the default Console indent setting.
55
+ #
56
+ def Console.indent=(value)
57
+ @@ronin_console_indent = value
58
+ end
58
59
 
59
- #
60
- # Returns the Array of files to require when the Console starts.
61
- #
62
- def Console.auto_load
63
- @@ronin_console_auto_load ||= []
64
- end
60
+ #
61
+ # Returns the Array of files to require when the Console starts.
62
+ #
63
+ def Console.auto_load
64
+ @@ronin_console_auto_load ||= []
65
+ end
65
66
 
66
- #
67
- # Calls the specified _block_ from within the Console after it is
68
- # started.
69
- #
70
- def Console.setup(&block)
71
- Console.setup_blocks << block if block
72
- end
67
+ #
68
+ # Calls the specified _block_ from within the Console after it is
69
+ # started.
70
+ #
71
+ def Console.setup(&block)
72
+ Console.setup_blocks << block if block
73
+ end
73
74
 
74
- #
75
- # Starts a Console with the given _script_. If a _block_ is given, it
76
- # will be called from within the Console.
77
- #
78
- def Console.start(script=nil,&block)
79
- IRB.setup(script)
75
+ #
76
+ # Starts a Console with the given _script_. If a _block_ is given, it
77
+ # will be called from within the Console.
78
+ #
79
+ def Console.start(script=nil,&block)
80
+ IRB.setup(script)
80
81
 
81
- IRB.conf[:IRB_NAME] = 'ronin'
82
- IRB.conf[:PROMPT_MODE] = Console.prompt
83
- IRB.conf[:AUTO_INDENT] = Console.indent
84
- IRB.conf[:LOAD_MODULES] = Console.auto_load
82
+ IRB.conf[:IRB_NAME] = 'ronin'
83
+ IRB.conf[:PROMPT_MODE] = Console.prompt
84
+ IRB.conf[:AUTO_INDENT] = Console.indent
85
85
 
86
- irb = IRB::Irb.new(nil,script)
86
+ irb = IRB::Irb.new(nil,script)
87
87
 
88
- # configure the irb workspace
89
- irb.context.main.instance_eval do
90
- require 'ronin'
91
- require 'pp'
88
+ # configure the irb workspace
89
+ irb.context.main.instance_eval do
90
+ require 'ronin/environment'
92
91
 
93
- include Ronin
94
- end
92
+ Ronin::UI::Console.auto_load.each do |path|
93
+ require path
94
+ end
95
95
 
96
- Console.setup_blocks.each do |setup_block|
97
- irb.context.main.instance_eval(&setup_block)
98
- end
96
+ include Ronin
97
+ end
99
98
 
100
- # Load console configuration block is given
101
- irb.context.main.instance_eval(&block) if block
99
+ Console.setup_blocks.each do |setup_block|
100
+ irb.context.main.instance_eval(&setup_block)
101
+ end
102
102
 
103
- IRB.conf[:MAIN_CONTEXT] = irb.context
103
+ # Load console configuration block is given
104
+ irb.context.main.instance_eval(&block) if block
104
105
 
105
- trap('SIGINT') do
106
- irb.signal_handle
107
- end
106
+ IRB.conf[:MAIN_CONTEXT] = irb.context
108
107
 
109
- catch(:IRB_EXIT) do
110
- irb.eval_input
111
- end
108
+ trap('SIGINT') do
109
+ irb.signal_handle
110
+ end
112
111
 
113
- print "\n"
114
- return nil
115
- end
112
+ catch(:IRB_EXIT) do
113
+ irb.eval_input
114
+ end
116
115
 
117
- protected
116
+ putc "\n"
117
+ return nil
118
+ end
118
119
 
119
- #
120
- # Returns the Array of setup_blocks to run within the Console after it
121
- # is started.
122
- #
123
- def Console.setup_blocks
124
- @@console_setup_blocks ||= []
120
+ protected
121
+
122
+ #
123
+ # Returns the Array of setup_blocks to run within the Console after it
124
+ # is started.
125
+ #
126
+ def Console.setup_blocks
127
+ @@console_setup_blocks ||= []
128
+ end
125
129
  end
126
130
  end
127
131
  end
@@ -0,0 +1,73 @@
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
+ module Ronin
25
+ module UI
26
+ module Diagnostics
27
+ def Diagnostics.enable!
28
+ @@ronin_diagnostics = true
29
+ end
30
+
31
+ def Diagnostics.enabled?
32
+ (@@ronin_diagnostics ||= false) == true
33
+ end
34
+
35
+ def Diagnostics.disable!
36
+ @@ronin_diagnostics = false
37
+ end
38
+
39
+ def Diagnostics.disabled?
40
+ (@@ronin_diagnostics ||= false) == false
41
+ end
42
+
43
+ protected
44
+
45
+ #
46
+ # Prints the given _messages_ as info diagnostics.
47
+ #
48
+ def print_info(*messages)
49
+ if Diagnostics.enabled?
50
+ STDERR.puts(*(messages.map { |mesg| "[-] #{mesg}" }))
51
+ end
52
+ end
53
+
54
+ #
55
+ # Prints the given _messages_ as warning diagnostics.
56
+ #
57
+ def print_warning(*messages)
58
+ if Diagnostics.enabled?
59
+ STDERR.puts(*(messages.map { |mesg| "[*] #{mesg}" }))
60
+ end
61
+ end
62
+
63
+ #
64
+ # Prints the given _messages_ as error diagnostics.
65
+ #
66
+ def print_error(*messages)
67
+ if Diagnostics.enabled?
68
+ STDERR.puts(*(messages.map { |mesg| "[!] #{mesg}" }))
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end