ronin 0.2.1 → 0.2.2

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 (80) hide show
  1. data/History.txt +25 -0
  2. data/Manifest.txt +36 -11
  3. data/README.txt +6 -8
  4. data/Rakefile +2 -1
  5. data/lib/ronin/config.rb +0 -3
  6. data/lib/ronin/environment.rb +1 -1
  7. data/lib/ronin/extensions/string.rb +0 -11
  8. data/lib/ronin/formatting/extensions/binary/integer.rb +24 -12
  9. data/lib/ronin/formatting/extensions/binary/string.rb +166 -0
  10. data/lib/ronin/formatting/extensions/text/string.rb +4 -4
  11. data/lib/ronin/license.rb +42 -12
  12. data/lib/ronin/os.rb +3 -2
  13. data/lib/ronin/platform/extension.rb +11 -141
  14. data/lib/ronin/platform/extension_cache.rb +11 -0
  15. data/lib/ronin/platform/overlay.rb +56 -25
  16. data/lib/ronin/platform/overlay_cache.rb +1 -1
  17. data/lib/ronin/platform/platform.rb +14 -3
  18. data/lib/ronin/platform/ronin.rb +20 -1
  19. data/lib/ronin/platform/tasks/spec.rb +9 -0
  20. data/lib/ronin/{chars.rb → static.rb} +2 -2
  21. data/lib/ronin/static/finders.rb +144 -0
  22. data/lib/ronin/static/static.rb +53 -0
  23. data/lib/ronin/ui/command_line/commands/add.rb +21 -5
  24. data/lib/ronin/ui/command_line/commands/install.rb +19 -3
  25. data/lib/ronin/ui/command_line/commands/rm.rb +1 -1
  26. data/lib/ronin/ui/command_line/commands/uninstall.rb +1 -1
  27. data/lib/ronin/ui/command_line/commands/update.rb +9 -2
  28. data/lib/ronin/version.rb +1 -1
  29. data/spec/extensions/string_spec.rb +0 -10
  30. data/spec/formatting/binary/helpers/hexdumps.rb +14 -0
  31. data/spec/formatting/binary/helpers/hexdumps/hexdump_decimal_shorts.txt +17 -0
  32. data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_bytes.txt +17 -0
  33. data/spec/formatting/binary/helpers/hexdumps/hexdump_hex_shorts.txt +17 -0
  34. data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_bytes.txt +17 -0
  35. data/spec/formatting/binary/helpers/hexdumps/hexdump_octal_shorts.txt +17 -0
  36. data/spec/formatting/binary/helpers/hexdumps/hexdump_repeated.txt +6 -0
  37. data/spec/formatting/binary/helpers/hexdumps/od_decimal_bytes.txt +17 -0
  38. data/spec/formatting/binary/helpers/hexdumps/od_decimal_ints.txt +17 -0
  39. data/spec/formatting/binary/helpers/hexdumps/od_decimal_quads.txt +17 -0
  40. data/spec/formatting/binary/helpers/hexdumps/od_decimal_shorts.txt +17 -0
  41. data/spec/formatting/binary/helpers/hexdumps/od_hex_bytes.txt +17 -0
  42. data/spec/formatting/binary/helpers/hexdumps/od_hex_ints.txt +17 -0
  43. data/spec/formatting/binary/helpers/hexdumps/od_hex_quads.txt +17 -0
  44. data/spec/formatting/binary/helpers/hexdumps/od_hex_shorts.txt +17 -0
  45. data/spec/formatting/binary/helpers/hexdumps/od_octal_bytes.txt +17 -0
  46. data/spec/formatting/binary/helpers/hexdumps/od_octal_ints.txt +17 -0
  47. data/spec/formatting/binary/helpers/hexdumps/od_octal_quads.txt +17 -0
  48. data/spec/formatting/binary/helpers/hexdumps/od_octal_shorts.txt +17 -0
  49. data/spec/formatting/binary/helpers/hexdumps/od_repeated.txt +6 -0
  50. data/spec/formatting/binary/helpers/hexdumps/repeated.bin +1 -0
  51. data/spec/formatting/binary/integer_spec.rb +61 -1
  52. data/spec/formatting/binary/string_spec.rb +166 -9
  53. data/spec/platform/extension_cache_spec.rb +8 -0
  54. data/spec/platform/helpers/overlays.yaml.erb +3 -0
  55. data/spec/platform/helpers/overlays/hello/ronin.xml +1 -1
  56. data/spec/platform/helpers/overlays/random/random/extension.rb +7 -0
  57. data/spec/platform/helpers/overlays/random/ronin.xml +26 -0
  58. data/spec/platform/helpers/overlays/test1/ronin.xml +2 -2
  59. data/spec/platform/helpers/overlays/test2/ronin.xml +2 -2
  60. data/spec/platform/overlay_cache_spec.rb +5 -3
  61. data/spec/platform/overlay_spec.rb +35 -0
  62. data/spec/platform/ronin_spec.rb +13 -1
  63. data/spec/static/finders_spec.rb +55 -0
  64. data/spec/static/helpers/static.rb +11 -0
  65. data/spec/static/helpers/static1/dir/two.txt +0 -0
  66. data/spec/static/helpers/static1/one.txt +0 -0
  67. data/spec/static/helpers/static2/dir/two.txt +0 -0
  68. data/spec/static/helpers/static_class.rb +7 -0
  69. data/spec/static/static_spec.rb +24 -0
  70. data/static/{overlay.xsl → ronin/platform/overlay.xsl} +0 -0
  71. metadata +50 -17
  72. data/bin/ronin-ext +0 -12
  73. data/bin/ronin-overlay +0 -12
  74. data/lib/ronin/chars/char_set.rb +0 -198
  75. data/lib/ronin/chars/chars.rb +0 -190
  76. data/lib/ronin/ui/command_line/commands/ext.rb +0 -70
  77. data/lib/ronin/ui/command_line/commands/overlay.rb +0 -189
  78. data/spec/chars/char_set_spec.rb +0 -175
  79. data/spec/chars/chars_spec.rb +0 -107
  80. data/static/extension.rb +0 -9
@@ -286,7 +286,7 @@ module Ronin
286
286
  descriptions = overlays.map do |overlay|
287
287
  {
288
288
  :path => overlay.path,
289
- :media => overlay.media_type,
289
+ :media => overlay.media,
290
290
  :uri => overlay.uri
291
291
  }
292
292
  end
@@ -96,10 +96,21 @@ module Ronin
96
96
  # <tt>:media</tt>:: The media of the overlay.
97
97
  #
98
98
  def Platform.install(options={},&block)
99
- options = options.merge(:into => OverlayCache::CACHE_DIR)
99
+ unless options[:uri]
100
+ raise(ArgumentError,":uri must be passed to Platform.install",caller)
101
+ end
100
102
 
101
- Repertoire.checkout(options) do |path,media,uri|
102
- return Platform.add(:path => path, :media => media, :uri => uri)
103
+ uri = options[:uri].to_s
104
+ host = (URI(uri).host || 'localhost')
105
+ host_dir = File.join(OverlayCache::CACHE_DIR,host)
106
+ options = options.merge(:into => host_dir)
107
+
108
+ Repertoire.checkout(options) do |repo|
109
+ return Platform.add(
110
+ :path => repo.path,
111
+ :media => repo.media_name,
112
+ :uri => uri
113
+ )
103
114
  end
104
115
  end
105
116
 
@@ -23,11 +23,30 @@
23
23
 
24
24
  require 'ronin/platform/platform'
25
25
 
26
+ require 'extlib'
27
+
26
28
  module Ronin
27
29
  protected
28
30
 
29
31
  #
30
- # Provides transparent access to Platform.extension.
32
+ # Provides transparent access to Platform.extension via constants.
33
+ #
34
+ # Ronin::Shellcode
35
+ # # => #<Ronin::Platform::Extension: ...>
36
+ #
37
+ def Ronin.const_missing(name)
38
+ name = name.to_s
39
+ ext_name = name.snake_case
40
+
41
+ if Platform.has_extension?(ext_name)
42
+ return Platform.extension(ext_name)
43
+ end
44
+
45
+ return super(name)
46
+ end
47
+
48
+ #
49
+ # Provides transparent access to Platform.extension via methods.
31
50
  #
32
51
  # Ronin.shellcode
33
52
  # # => #<Ronin::Platform::Extension: ...>
@@ -0,0 +1,9 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ desc "Run all specifications"
4
+ Spec::Rake::SpecTask.new(:spec) do |t|
5
+ t.libs += ['lib'] + Dir['**/lib'] + ['spec']
6
+ t.spec_opts = ['--colour', '--format', 'specdoc']
7
+ end
8
+
9
+ task :default => :spec
@@ -21,5 +21,5 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/chars/char_set'
25
- require 'ronin/chars/chars'
24
+ require 'ronin/static/static'
25
+ require 'ronin/static/finders'
@@ -0,0 +1,144 @@
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/static/static'
25
+
26
+ module Ronin
27
+ module Static
28
+ module Finders
29
+ #
30
+ # Passes all possible static paths for the specified _path_,
31
+ # within the static directories, to the specified _block_.
32
+ #
33
+ def static_paths(path,&block)
34
+ Static.static_dirs.each do |dir|
35
+ block.call(File.join(dir,path))
36
+ end
37
+ end
38
+
39
+ #
40
+ # Returns the first matching static path for the specified _path_.
41
+ # If no matching static path can be found, +nil+ will be returned.
42
+ #
43
+ def static_find(path)
44
+ static_paths(path) do |full_path|
45
+ return full_path if File.exists?(full_path)
46
+ end
47
+
48
+ return nil
49
+ end
50
+
51
+ #
52
+ # Returns the first matching static file for the specified _path_.
53
+ # If no matching static file can be found, +nil+ will be returned.
54
+ #
55
+ def find_static_file(path)
56
+ static_paths(path) do |full_path|
57
+ return full_path if File.file?(full_path)
58
+ end
59
+
60
+ return nil
61
+ end
62
+
63
+ #
64
+ # Returns the first matching static directory for the specified
65
+ # _path_. If no matching static directory can be found, +nil+ will be
66
+ # returned.
67
+ #
68
+ def find_static_dir(path)
69
+ static_paths(path) do |full_path|
70
+ return full_path if File.directory?(full_path)
71
+ end
72
+
73
+ return nil
74
+ end
75
+
76
+ #
77
+ # Returns the first set of matching static paths for the specified
78
+ # _pattern_. If no matching static paths can be found, an empty
79
+ # Array will be returned.
80
+ #
81
+ def static_glob(pattern)
82
+ static_paths(pattern) do |full_path|
83
+ paths = Dir[full_path]
84
+
85
+ return paths unless paths.empty?
86
+ end
87
+
88
+ return []
89
+ end
90
+
91
+ #
92
+ # Returns all matching static paths for the specified _path_.
93
+ #
94
+ def static_find_all(path)
95
+ paths = []
96
+
97
+ static_paths(path) do |full_path|
98
+ paths << full_path if File.exists?(full_path)
99
+ end
100
+
101
+ return paths
102
+ end
103
+
104
+ #
105
+ # Returns all matching static files for the specified _path_.
106
+ #
107
+ def find_static_files(path)
108
+ paths = []
109
+
110
+ static_paths(path) do |full_path|
111
+ paths << full_path if File.file?(full_path)
112
+ end
113
+
114
+ return paths
115
+ end
116
+
117
+ #
118
+ # Returns all matching static directories for the specified _path_.
119
+ #
120
+ def find_static_dirs(path)
121
+ paths = []
122
+
123
+ static_paths(path) do |full_path|
124
+ paths << full_path if File.directory?(full_path)
125
+ end
126
+
127
+ return paths
128
+ end
129
+
130
+ #
131
+ # Returns all matching static paths for the specified _pattern_.
132
+ #
133
+ def static_glob_all(pattern)
134
+ paths = []
135
+
136
+ static_paths(pattern) do |full_path|
137
+ paths += Dir[full_path]
138
+ end
139
+
140
+ return paths
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,53 @@
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 'set'
25
+
26
+ module Ronin
27
+ module Static
28
+ #
29
+ # The Set of directories which contain static content.
30
+ #
31
+ def Static.static_dirs
32
+ @@ronin_static_dirs ||= Set[]
33
+ end
34
+
35
+ #
36
+ # Adds the specified _path_ to the Set of static directories.
37
+ #
38
+ def Static.directory(path)
39
+ path = File.expand_path(path)
40
+
41
+ unless File.directory?(path)
42
+ raise("#{path.dump} must be a directory")
43
+ end
44
+
45
+ Static.static_dirs << path
46
+ return path
47
+ end
48
+
49
+ protected
50
+
51
+ Static.directory(File.join(File.dirname(__FILE__),'..','..','..','static'))
52
+ end
53
+ end
@@ -45,15 +45,31 @@ module Ronin
45
45
  end
46
46
 
47
47
  opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
48
- @media = media
48
+ @media = media.to_sym
49
49
  end
50
50
 
51
- opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri|
52
- @uri = uri
51
+ opts.on('-L','--local','Similiar to: -m local') do
52
+ @media = nil
53
+ end
54
+
55
+ opts.on('--rsync','Alias for -m rsync') do
56
+ @media = :rsync
57
+ end
58
+
59
+ opts.on('--svn','Alias for -m svn') do
60
+ @media = :svn
53
61
  end
54
62
 
55
- opts.on('-L','--local','Similiar to: --media local') do
56
- @media = :local
63
+ opts.on('--hg','Alias for -m hg') do
64
+ @media = :hg
65
+ end
66
+
67
+ opts.on('--git','Alias for -m git') do
68
+ @media = :git
69
+ end
70
+
71
+ opts.on('-U','--uri URI','Specify the source URI of the overlay') do |uri|
72
+ @uri = uri
57
73
  end
58
74
  end
59
75
 
@@ -43,8 +43,24 @@ module Ronin
43
43
  @cache = dir
44
44
  end
45
45
 
46
- opts.on('-m','--media [MEDIA]','Spedify the media-type of the overlay') do |media|
47
- @media = media
46
+ opts.on('-m','--media MEDIA','Spedify the media-type of the overlay') do |media|
47
+ @media = media.to_sym
48
+ end
49
+
50
+ opts.on('--rsync','Alias for -m rsync') do
51
+ @media = :rsync
52
+ end
53
+
54
+ opts.on('--svn','Alias for -m svn') do
55
+ @media = :svn
56
+ end
57
+
58
+ opts.on('--hg','Alias for -m hg') do
59
+ @media = :hg
60
+ end
61
+
62
+ opts.on('--git','Alias for -m git') do
63
+ @media = :git
48
64
  end
49
65
  end
50
66
 
@@ -57,7 +73,7 @@ module Ronin
57
73
  }
58
74
  end
59
75
 
60
- def arguments(args)
76
+ def arguments(*args)
61
77
  unless args.length == 1
62
78
  fail('only one overlay URI maybe specified')
63
79
  end
@@ -60,7 +60,7 @@ module Ronin
60
60
 
61
61
  args.each do |name|
62
62
  Platform.remove(name) do |overlay|
63
- puts "Removing #{overlay.name.dump} ..."
63
+ puts "Removing Overlay #{overlay.name.dump} ..."
64
64
  end
65
65
  end
66
66
  end
@@ -60,7 +60,7 @@ module Ronin
60
60
 
61
61
  args.each do |name|
62
62
  Platform.uninstall(name) do |overlay|
63
- puts "Uninstalling #{overlay.name.dump} ..."
63
+ puts "Uninstalling Overlay #{overlay.name.dump} ..."
64
64
  end
65
65
  end
66
66
  end
@@ -58,10 +58,17 @@ module Ronin
58
58
  def arguments(*args)
59
59
  Platform.load_overlays(@cache) if @cache
60
60
 
61
+ update = lambda { |overlay|
62
+ puts "Updating Overlay #{overlay.name.dump} ..."
63
+ overlay.update
64
+ }
65
+
61
66
  if args.empty?
62
- Platform.overlays.each_overlay { |overlay| overlay.update }
67
+ Platform.overlays.each_overlay(&update)
63
68
  else
64
- args.each { |name| Platform.overlays.update(name) }
69
+ args.each do |name|
70
+ update.call(Platform.overlays.update(name))
71
+ end
65
72
  end
66
73
  end
67
74
 
data/lib/ronin/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
 
24
24
  module Ronin
25
25
  # Ronin version
26
- VERSION = '0.2.1'
26
+ VERSION = '0.2.2'
27
27
  end
@@ -3,16 +3,6 @@ require 'ronin/extensions/string'
3
3
  require 'spec_helper'
4
4
 
5
5
  describe String do
6
- describe "to_method_name" do
7
- it "should be able to convert proper names to method names" do
8
- "Proper Name".to_method_name.should == 'proper_name'
9
- end
10
-
11
- it "should be able to convert Class names to method names" do
12
- "Namespace::Test".to_method_name.should == 'namespace_test'
13
- end
14
- end
15
-
16
6
  describe "common_prefix" do
17
7
  it "should find the common prefix between two Strings" do
18
8
  one = 'What is puzzling you is the nature of my game'
@@ -0,0 +1,14 @@
1
+ def load_binary_data(name)
2
+ path = File.join(File.dirname(__FILE__),'hexdumps',"#{name}.bin")
3
+ buffer = []
4
+
5
+ File.open(path) do |file|
6
+ file.each_byte { |b| buffer << b }
7
+ end
8
+
9
+ return buffer
10
+ end
11
+
12
+ def load_hexdump(name)
13
+ File.read(File.join(File.dirname(__FILE__),'hexdumps',"#{name}.txt"))
14
+ end
@@ -0,0 +1,17 @@
1
+ 0000000 00256 00770 01284 01798 02312 02826 03340 03854
2
+ 0000010 04368 04882 05396 05910 06424 06938 07452 07966
3
+ 0000020 08480 08994 09508 10022 10536 11050 11564 12078
4
+ 0000030 12592 13106 13620 14134 14648 15162 15676 16190
5
+ 0000040 16704 17218 17732 18246 18760 19274 19788 20302
6
+ 0000050 20816 21330 21844 22358 22872 23386 23900 24414
7
+ 0000060 24928 25442 25956 26470 26984 27498 28012 28526
8
+ 0000070 29040 29554 30068 30582 31096 31610 32124 32638
9
+ 0000080 33152 33666 34180 34694 35208 35722 36236 36750
10
+ 0000090 37264 37778 38292 38806 39320 39834 40348 40862
11
+ 00000a0 41376 41890 42404 42918 43432 43946 44460 44974
12
+ 00000b0 45488 46002 46516 47030 47544 48058 48572 49086
13
+ 00000c0 49600 50114 50628 51142 51656 52170 52684 53198
14
+ 00000d0 53712 54226 54740 55254 55768 56282 56796 57310
15
+ 00000e0 57824 58338 58852 59366 59880 60394 60908 61422
16
+ 00000f0 61936 62450 62964 63478 63992 64506 65020 65534
17
+ 0000100