ronin-gen 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +14 -0
  3. data/Manifest.txt +4 -4
  4. data/README.txt +32 -30
  5. data/Rakefile +11 -1
  6. data/bin/ronin-gen +2 -2
  7. data/bin/ronin-gen-extension +1 -1
  8. data/bin/ronin-gen-overlay +1 -1
  9. data/lib/ronin/generators.rb +0 -2
  10. data/lib/ronin/generators/dir_generator.rb +38 -7
  11. data/lib/ronin/generators/generator.rb +93 -88
  12. data/lib/ronin/generators/platform/extension.rb +7 -11
  13. data/lib/ronin/generators/platform/overlay.rb +91 -106
  14. data/lib/ronin/generators/platform/static.rb +0 -2
  15. data/lib/ronin/generators/version.rb +1 -3
  16. data/lib/ronin/ui/command_line/commands/gen.rb +8 -19
  17. data/lib/ronin/ui/command_line/commands/gen_extension.rb +1 -24
  18. data/lib/ronin/ui/command_line/commands/gen_overlay.rb +1 -65
  19. data/spec/generated_overlay_examples.rb +6 -0
  20. data/spec/generators/classes/dir_generator.rb +2 -4
  21. data/spec/generators/classes/file_generator.rb +4 -4
  22. data/spec/generators/classes/templated_generator.rb +3 -7
  23. data/spec/generators/classes/touch_generator.rb +1 -3
  24. data/spec/generators/generator_spec.rb +8 -10
  25. data/spec/generators/helpers/static/generators/templated.txt.erb +1 -1
  26. data/spec/generators/platform/extension_spec.rb +1 -4
  27. data/spec/generators/platform/overlay_spec.rb +2 -4
  28. data/spec/spec_helper.rb +1 -1
  29. data/spec/ui/command_line/commands/gen_extension_spec.rb +1 -1
  30. data/spec/ui/command_line/commands/gen_overlay_spec.rb +4 -4
  31. data/static/ronin/generators/platform/Rakefile.erb +5 -0
  32. data/static/ronin/{platform/generators → generators/platform}/extension.rb +0 -0
  33. data/static/ronin/{platform/generators → generators/platform}/spec/spec_helper.rb +1 -1
  34. data/tasks/spec.rb +1 -0
  35. data/tasks/yard.rb +13 -0
  36. metadata +33 -14
  37. metadata.gz.sig +0 -0
  38. data/TODO.txt +0 -3
  39. data/lib/ronin/generators/platform/spec.rb +0 -46
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,17 @@
1
+ === 0.2.0 / 2009-09-24
2
+
3
+ * Require ronin >= 0.3.0.
4
+ * Require rspec >= 1.2.8.
5
+ * Require yard >= 0.2.3.5.
6
+ * Updated the project summary and 3-point description of Ronin Gen.
7
+ * Moved to YARD based documentation.
8
+ * Refactored Ronin::Generators::Generator to inherit from Thor.
9
+ * Refactored Ronin::Generators::DirGenerator.
10
+ * Refactored Ronin::Generators::Platform::Extension.
11
+ * Refactored Ronin::Generators::Platform::Overlay.
12
+ * Rewrote the Ronin::UI::CommandLine generator commands to simply inherit
13
+ from the new Thor based generator classes within Ronin::Generators.
14
+
1
15
  === 0.1.1 / 2009-07-02
2
16
 
3
17
  * Use Hoe >= 2.0.0.
@@ -3,7 +3,6 @@ COPYING.txt
3
3
  Manifest.txt
4
4
  README.txt
5
5
  Rakefile
6
- TODO.txt
7
6
  bin/ronin-gen
8
7
  bin/ronin-gen-overlay
9
8
  bin/ronin-gen-extension
@@ -14,12 +13,12 @@ lib/ronin/generators/version.rb
14
13
  lib/ronin/generators/platform/static.rb
15
14
  lib/ronin/generators/platform/overlay.rb
16
15
  lib/ronin/generators/platform/extension.rb
17
- lib/ronin/generators/platform/spec.rb
18
16
  lib/ronin/generators/platform/extension.rb
19
17
  lib/ronin/ui/command_line/commands/gen.rb
20
18
  lib/ronin/ui/command_line/commands/gen_overlay.rb
21
19
  lib/ronin/ui/command_line/commands/gen_extension.rb
22
20
  tasks/spec.rb
21
+ tasks/yard.rb
23
22
  spec/spec_helper.rb
24
23
  spec/generated_overlay_examples.rb
25
24
  spec/generated_extension_examples.rb
@@ -35,5 +34,6 @@ spec/generators/platform/overlay_spec.rb
35
34
  spec/generators/platform/extension_spec.rb
36
35
  spec/ui/command_line/commands/gen_overlay_spec.rb
37
36
  spec/ui/command_line/commands/gen_extension_spec.rb
38
- static/ronin/platform/generators/extension.rb
39
- static/ronin/platform/generators/spec/spec_helper.rb
37
+ static/ronin/generators/platform/Rakefile.erb
38
+ static/ronin/generators/platform/extension.rb
39
+ static/ronin/generators/platform/spec/spec_helper.rb
data/README.txt CHANGED
@@ -2,61 +2,63 @@
2
2
 
3
3
  * http://ronin.rubyforge.org/gen/
4
4
  * http://github.com/postmodern/ronin-gen
5
- * irc.freenode.net ##ronin
5
+ * irc.freenode.net #ronin
6
6
  * Postmodern (postmodern.mod3 at gmail.com)
7
7
 
8
8
  == DESCRIPTION:
9
9
 
10
10
  Ronin Gen is a Ruby library for Ronin that provides various generators.
11
11
 
12
- Ronin is a Ruby platform designed for information security and data
13
- exploration tasks. Ronin allows for the rapid development and distribution
14
- of code over many of the common Source-Code-Management (SCM) systems.
12
+ Ronin is a Ruby platform for exploit development and security research.
13
+ Ronin allows for the rapid development and distribution of code, exploits
14
+ or payloads over many common Source-Code-Management (SCM) systems.
15
15
 
16
- === Free
16
+ === Ruby
17
17
 
18
- All source code within Ronin is licensed under the GPL-2, therefore no user
19
- will ever have to pay for Ronin or updates to Ronin. Not only is the
20
- source code free, the Ronin project will not sell enterprise grade security
21
- snake-oil solutions, give private training classes or later turn Ronin into
22
- commercial software.
18
+ Ronin's Ruby environment allows security researchers to leverage Ruby with
19
+ ease. The Ruby environment contains a multitude of convenience methods
20
+ for working with data in Ruby, a Ruby Object Database, a customized Ruby
21
+ Console and an extendable command-line interface.
23
22
 
24
- === Modular
23
+ === Extend
25
24
 
26
- Ronin was not designed as one monolithic framework but instead as a
27
- collection of libraries which can be individually installed. This allows
28
- users to pick and choose what functionality they want in Ronin.
25
+ Ronin's more specialized features are provided by additional Ronin
26
+ libraries, which users can choose to install. These libraries can allow
27
+ one to write and run Exploits and Payloads, scan for PHP vulnerabilities,
28
+ perform Google Dorks or run 3rd party scanners.
29
29
 
30
- === Decentralized
30
+ === Publish
31
31
 
32
- Ronin does not have a central repository of exploits and payloads which
33
- all developers contribute to. Instead Ronin has Overlays, repositories of
34
- code that can be hosted on any CVS/SVN/Git/Rsync server. Users can then use
35
- Ronin to quickly install or update Overlays. This allows developers and
36
- users to form their own communities, independent of the main developers
37
- of Ronin.
32
+ Ronin allows users to publish and share code, exploits, payloads or other
33
+ data via Overlays. Overlays are directories of code and data that can be
34
+ hosted on any SVN, Hg, Git or Rsync server. Ronin makes it easy to create,
35
+ install or update Overlays.
38
36
 
39
37
  == FEATURES:
40
38
 
39
+ * Provides {Ronin::Generators::Generator}, a Thor based generator class that
40
+ can be used to create new generators.
41
+ * Provides {Ronin::Generators::DirGenerator}, a Thor based generator that
42
+ can be used to create new directory generators.
41
43
  * Generators for Overlays and Extensions.
42
44
 
43
- == REQUIREMENTS:
45
+ == SYNOPSIS:
44
46
 
45
- * {ronin}[http://ronin.rubyforge.org/] >= 0.2.2
47
+ * Generate a skeleton Overlay:
46
48
 
47
- == INSTALL:
49
+ $ ronin-gen overlay PATH [options]
48
50
 
49
- $ sudo gem install ronin-gem
51
+ * Generate a skeleton Extension:
50
52
 
51
- == SYNOPSIS:
53
+ $ ronin-gen extension PATH
52
54
 
53
- * Generate a skeleton Overlay:
55
+ == REQUIREMENTS:
54
56
 
55
- $ ronin-gen overlay [options] PATH
57
+ * {ronin}[http://ronin.rubyforge.org/] >= 0.3.0
56
58
 
57
- * Generate a skeleton Extension:
59
+ == INSTALL:
58
60
 
59
- $ ronin-gen extension PATH
61
+ $ sudo gem install ronin-gen
60
62
 
61
63
  == LICENSE:
62
64
 
data/Rakefile CHANGED
@@ -4,12 +4,22 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
  require 'hoe/signing'
6
6
  require './tasks/spec.rb'
7
+ require './tasks/yard.rb'
7
8
 
8
9
  Hoe.spec('ronin-gen') do
9
10
  self.rubyforge_name = 'ronin'
10
11
  self.developer('Postmodern', 'postmodern.mod3@gmail.com')
11
12
  self.remote_rdoc_dir = 'docs/ronin-gen'
12
- self.extra_deps = [['ronin', '>=0.2.4']]
13
+ self.extra_deps = [
14
+ ['ronin', '>=0.3.0']
15
+ ]
16
+
17
+ self.extra_dev_deps = [
18
+ ['rspec', '>=1.2.8'],
19
+ ['yard', '>=0.2.3.5']
20
+ ]
21
+
22
+ self.spec_extras = {:has_rdoc => 'yard'}
13
23
  end
14
24
 
15
25
  # vim: syntax=Ruby
@@ -13,7 +13,7 @@ require 'ronin/ui/command_line'
13
13
  if (ARGV.length > 0 && ARGV.first[0..0] != '-')
14
14
  ARGV[0] = "gen_#{ARGV.first}"
15
15
 
16
- Ronin::UI::CommandLine.run(*ARGV)
16
+ Ronin::UI::CommandLine.start
17
17
  else
18
- Ronin::UI::CommandLine::Commands::Gen.run(*ARGV)
18
+ Ronin::UI::CommandLine::Commands::Gen.start
19
19
  end
@@ -9,4 +9,4 @@ end
9
9
 
10
10
  require 'ronin/ui/command_line/commands/gen_extension'
11
11
 
12
- Ronin::UI::CommandLine::Commands::GenExtension.run(*ARGV)
12
+ Ronin::UI::CommandLine::Commands::GenExtension.start
@@ -9,4 +9,4 @@ end
9
9
 
10
10
  require 'ronin/ui/command_line/commands/gen_overlay'
11
11
 
12
- Ronin::UI::CommandLine::Commands::GenOverlay.run(*ARGV)
12
+ Ronin::UI::CommandLine::Commands::GenOverlay.start
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Gen - A Ruby library for Ronin that provides various generators.
4
3
  #
5
4
  # Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
@@ -17,7 +16,6 @@
17
16
  # You should have received a copy of the GNU General Public License
18
17
  # along with this program; if not, write to the Free Software
19
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
- #++
21
19
  #
22
20
 
23
21
  require 'ronin/generators/generator'
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Gen - A Ruby library for Ronin that provides various generators.
4
3
  #
5
4
  # Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at gmail.com)
@@ -17,24 +16,56 @@
17
16
  # You should have received a copy of the GNU General Public License
18
17
  # along with this program; if not, write to the Free Software
19
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
- #++
21
19
  #
22
20
 
23
21
  require 'ronin/generators/generator'
24
22
 
23
+ require 'fileutils'
24
+
25
25
  module Ronin
26
26
  module Generators
27
27
  class DirGenerator < Generator
28
28
 
29
+ argument :path, :type => :string, :require => true
30
+
31
+ #
32
+ # Invokes the generator.
33
+ #
34
+ # @param [String] path
35
+ # The directory to generate within.
36
+ #
37
+ # @param [Hash] options
38
+ # Additional command-line options for the generator.
29
39
  #
30
- # Creates a directory at the specified _path_ then runs the
31
- # generator.
40
+ # @param [Array] arguments
41
+ # Additional command-line arguments for the generator.
32
42
  #
33
- def run(path)
43
+ # @example
44
+ # gen.generate('path/to/dir')
45
+ #
46
+ def self.generate(path,options={},arguments=[])
34
47
  path = File.expand_path(path)
35
- FileUtils.mkdir_p(path)
36
48
 
37
- return super(path)
49
+ generator = self.new([path] + arguments, options)
50
+ generator.invoke()
51
+ end
52
+
53
+ no_tasks do
54
+ #
55
+ # Invokes the tasks of the generator.
56
+ #
57
+ # @param [Array] names
58
+ # The task names to invoke.
59
+ #
60
+ def invoke(*names,&block)
61
+ if self.path
62
+ self.destination_root = self.path
63
+ end
64
+
65
+ inside() do |path|
66
+ super(*names,&block)
67
+ end
68
+ end
38
69
  end
39
70
 
40
71
  end
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Gen - A Ruby library for Ronin that provides various generators.
4
3
  #
5
4
  # Copyright (c) 2009 Hal Brodigan (postmodern.mod3 at example.com)
@@ -17,141 +16,147 @@
17
16
  # You should have received a copy of the GNU General Public License
18
17
  # along with this program; if not, write to the Free Software
19
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
- #++
21
19
  #
22
20
 
21
+ require 'ronin/templates/template'
23
22
  require 'ronin/static/finders'
24
- require 'ronin/templates/erb'
25
23
 
26
- require 'fileutils'
24
+ require 'extlib'
25
+ require 'erb'
26
+ require 'thor'
27
27
 
28
28
  module Ronin
29
29
  module Generators
30
- class Generator
30
+ class Generator < Thor::Group
31
31
 
32
+ include Thor::Actions
33
+ include Templates::Template
32
34
  include Static::Finders
33
- include Templates::Erb
34
35
 
35
- #
36
- # Runs the generator with the specified _path_.
37
- #
38
- def run(path)
39
- path = File.expand_path(path)
40
- @path = path
41
-
42
- generate!
43
-
44
- @path = nil
45
- return path
36
+ def self.inherited(super_class)
37
+ class_name = super_class.name.split('::').last.snake_case
38
+ super_class.namespace("ronin #{class_name}")
46
39
  end
47
40
 
48
- protected
49
-
50
41
  #
51
- # Default method which invokes the generator.
42
+ # Defines the default source root of the generator as the current
43
+ # working directory.
52
44
  #
53
- def generate!
45
+ # @since 0.2.0
46
+ #
47
+ def self.source_root
48
+ Dir.pwd
54
49
  end
55
50
 
56
51
  #
57
- # Returns the absolute form of the specified _path_, with respect to
58
- # the +path+ instance variable.
52
+ # Invokes the generator.
59
53
  #
60
- def expand_path(sub_path)
61
- return @path if (sub_path.nil? || sub_path == @path)
62
- return File.expand_path(File.join(@path,sub_path))
63
- end
64
-
54
+ # @param [Hash] options
55
+ # Class options to use with the generator.
65
56
  #
66
- # Prints the specified _sub_path_.
57
+ # @param [Array] arguments
58
+ # Additional arguments for the generator.
67
59
  #
68
- def print_path(sub_path)
69
- full_path = expand_path(sub_path)
70
-
71
- sub_path = File.join('.',sub_path)
72
- sub_path << File::SEPARATOR if File.directory?(full_path)
73
-
74
- puts " #{sub_path}"
60
+ # @example
61
+ # gen.generate
62
+ #
63
+ # @since 0.2.0
64
+ #
65
+ def self.generate(options={},arguments=[])
66
+ generator = self.new(arguments, options)
67
+ generator.invoke()
75
68
  end
76
69
 
70
+ desc "default generator task"
71
+
77
72
  #
78
- # Touches the file at the specified _sub_path_.
73
+ # Default generator method.
79
74
  #
80
- # touch 'init.rb'
75
+ # @since 0.2.0
81
76
  #
82
- def touch(sub_path)
83
- FileUtils.touch(expand_path(sub_path))
84
-
85
- print_path(sub_path)
86
- return sub_path
77
+ def generate
87
78
  end
88
79
 
80
+ protected
81
+
89
82
  #
90
- # Opens the file at the specified _sub_path_. If a _block_ is given,
91
- # it will be passed a newly created File object.
83
+ # Touches a file.
92
84
  #
93
- # file('metadata.xml') do |file|
94
- # ...
95
- # end
85
+ # @param [String] destination
86
+ # The relative path to the file to touch.
96
87
  #
97
- def file(sub_path,&block)
98
- File.open(expand_path(sub_path),'w',&block)
99
-
100
- print_path(sub_path)
101
- return sub_path
88
+ # @example
89
+ # touch 'TODO.txt'
90
+ #
91
+ # @since 0.2.0
92
+ #
93
+ def touch(destination)
94
+ create_file(destination)
102
95
  end
103
96
 
104
97
  #
105
- # Creates a directory at the specified _sub_path_. If a _block_ is
106
- # given, it will be passed the _sub_path_ after the directory has
107
- # been created.
98
+ # Creates an empty directory.
108
99
  #
109
- # directory 'objects'
110
- # # => "objects"
100
+ # @param [String] destination
101
+ # The relative path of the directory to create.
111
102
  #
112
- def directory(sub_path,&block)
113
- FileUtils.mkdir_p(expand_path(sub_path))
114
-
115
- print_path(sub_path)
116
- block.call(sub_path) if block
117
- return sub_path
103
+ # @example
104
+ # directory 'sub/dir'
105
+ #
106
+ # @since 0.2.0
107
+ #
108
+ def mkdir(destination)
109
+ empty_directory(destination)
118
110
  end
119
111
 
120
112
  #
121
- # Copies the _static_file_ to the specified _sub_path_.
113
+ # Copies a static-file.
122
114
  #
123
- # copy 'ronin/platform/generators/extension.rb', 'myext/extension.rb'
124
- # # => "myext/extension.rb"
115
+ # @param [String] static_file
116
+ # The relative path to the static file.
125
117
  #
126
- def copy(static_file,sub_path)
127
- static_file = find_static_file(static_file)
128
-
129
- FileUtils.cp(static_file,expand_path(sub_path))
130
-
131
- print_path(sub_path)
132
- return sub_path
133
- end
134
-
118
+ # @param [String] destination
119
+ # The destination to copy the static file to.
135
120
  #
136
- # Renders the ERB template using the specified _static_file_.
121
+ # @example
122
+ # copy_file 'ronin/platform/generators/extension.rb',
123
+ # 'myext/extension.rb'
137
124
  #
138
- # render_template 'ronin/platform/generators/Rakefile.erb'
139
- # # => "..."
125
+ # @since 0.2.0
140
126
  #
141
- def render_template(static_file)
142
- erb_file(find_static_file(static_file))
127
+ def copy_file(static_file,destination)
128
+ super(find_static_file(static_file),destination)
143
129
  end
144
130
 
145
131
  #
146
- # Renders the ERB template using the specified _static_file_,
147
- # saving the result to the specified _sub_path_.
132
+ # Renders the ERB template at the specified _template_path_ and
133
+ # saves the result at the given _destination_.
134
+ #
135
+ # @param [String] template_path
136
+ # The relative path to the template.
137
+ #
138
+ # @param [String, nil] destination
139
+ # The destination to write the result of the rendered template to.
140
+ #
141
+ # @return [nil, String]
142
+ # If destination is +nil+, the result of the rendered template
143
+ # will be returned.
144
+ #
145
+ # @example
146
+ # template 'ronin/platform/generators/Rakefile.erb', 'Rakefile.erb'
147
+ #
148
+ # @example
149
+ # template '_helpers.erb'
148
150
  #
149
- # render_file 'ronin/platform/generators/Rakefile.erb', 'Rakefile'
150
- # # => nil
151
+ # @since 0.2.0
151
152
  #
152
- def render_file(static_file,sub_path)
153
- file(sub_path) do |file|
154
- file.write(render_template(static_file))
153
+ def template(template_path,destination=nil)
154
+ enter_template(template_path) do |path|
155
+ if destination
156
+ super(path,destination)
157
+ else
158
+ ERB.new(File.read(path)).result(binding).chomp
159
+ end
155
160
  end
156
161
  end
157
162