ronin-exploits 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +122 -0
  3. data/Manifest.txt +110 -20
  4. data/README.txt +112 -31
  5. data/Rakefile +12 -1
  6. data/bin/ronin-exploit +12 -0
  7. data/bin/ronin-exploits +1 -1
  8. data/bin/ronin-gen-binary-payload +12 -0
  9. data/bin/ronin-gen-exploit +12 -0
  10. data/bin/ronin-gen-ftp-exploit +12 -0
  11. data/bin/ronin-gen-http-exploit +12 -0
  12. data/bin/ronin-gen-local-exploit +12 -0
  13. data/bin/ronin-gen-nops +12 -0
  14. data/bin/ronin-gen-payload +12 -0
  15. data/bin/ronin-gen-remote-exploit +12 -0
  16. data/bin/ronin-gen-remote-tcp-exploit +12 -0
  17. data/bin/ronin-gen-remote-udp-exploit +12 -0
  18. data/bin/ronin-gen-shellcode +12 -0
  19. data/bin/ronin-gen-web-exploit +12 -0
  20. data/bin/ronin-payload +1 -1
  21. data/bin/ronin-payloads +1 -1
  22. data/lib/ronin/controls.rb +23 -0
  23. data/lib/ronin/controls/behaviors.rb +133 -0
  24. data/lib/ronin/{payloads/helpers → controls}/exceptions.rb +2 -4
  25. data/lib/ronin/{payloads/arch.rb → controls/exceptions/not_implemented.rb} +3 -8
  26. data/lib/ronin/controls/exceptions/program_not_found.rb +27 -0
  27. data/lib/ronin/controls/file_system.rb +145 -0
  28. data/lib/ronin/{exploits/os.rb → controls/helpers.rb} +12 -13
  29. data/lib/ronin/controls/helpers/command_exec.rb +143 -0
  30. data/lib/ronin/controls/helpers/dir_create.rb +42 -0
  31. data/lib/ronin/controls/helpers/dir_listing.rb +62 -0
  32. data/lib/ronin/controls/helpers/dir_remove.rb +42 -0
  33. data/lib/ronin/controls/helpers/file_ctime.rb +52 -0
  34. data/lib/ronin/controls/helpers/file_mtime.rb +53 -0
  35. data/lib/ronin/controls/helpers/file_ownership.rb +53 -0
  36. data/lib/ronin/controls/helpers/file_read.rb +62 -0
  37. data/lib/ronin/controls/helpers/file_remove.rb +51 -0
  38. data/lib/ronin/controls/helpers/file_write.rb +62 -0
  39. data/lib/ronin/controls/helpers/memory_read.rb +39 -0
  40. data/lib/ronin/controls/helpers/memory_write.rb +39 -0
  41. data/lib/ronin/exploits.rb +0 -2
  42. data/lib/ronin/exploits/{allow.rb → control.rb} +5 -9
  43. data/lib/ronin/exploits/exceptions.rb +1 -2
  44. data/lib/ronin/exploits/exceptions/exception.rb +27 -0
  45. data/lib/ronin/exploits/exceptions/exploit_not_built.rb +3 -3
  46. data/lib/ronin/exploits/exceptions/payload_size.rb +3 -3
  47. data/lib/ronin/exploits/exceptions/restricted_char.rb +3 -3
  48. data/lib/ronin/exploits/exceptions/target_data_missing.rb +3 -3
  49. data/lib/ronin/exploits/exceptions/target_unspecified.rb +3 -3
  50. data/lib/ronin/exploits/exceptions/unknown_helper.rb +3 -3
  51. data/lib/ronin/exploits/exploit.rb +449 -92
  52. data/lib/ronin/exploits/exploit_author.rb +2 -3
  53. data/lib/ronin/exploits/ftp.rb +7 -2
  54. data/lib/ronin/exploits/helpers.rb +0 -2
  55. data/lib/ronin/exploits/helpers/binary.rb +11 -5
  56. data/lib/ronin/exploits/helpers/buffer_overflow.rb +38 -25
  57. data/lib/ronin/exploits/helpers/file_based.rb +29 -30
  58. data/lib/ronin/exploits/helpers/format_string.rb +34 -24
  59. data/lib/ronin/exploits/helpers/padding.rb +33 -16
  60. data/lib/ronin/exploits/http.rb +9 -4
  61. data/lib/ronin/exploits/local.rb +8 -2
  62. data/lib/ronin/exploits/remote.rb +8 -2
  63. data/lib/ronin/exploits/remote_tcp.rb +26 -8
  64. data/lib/ronin/exploits/remote_udp.rb +26 -8
  65. data/lib/ronin/exploits/target.rb +41 -30
  66. data/lib/ronin/exploits/targets.rb +0 -2
  67. data/lib/ronin/exploits/targets/buffer_overflow.rb +0 -2
  68. data/lib/ronin/exploits/targets/format_string.rb +0 -2
  69. data/lib/ronin/exploits/verifiers.rb +45 -16
  70. data/lib/ronin/exploits/version.rb +1 -3
  71. data/lib/ronin/exploits/web.rb +18 -6
  72. data/lib/ronin/generators/exploits.rb +23 -0
  73. data/lib/ronin/generators/exploits/exploit.rb +70 -0
  74. data/lib/ronin/generators/exploits/ftp.rb +42 -0
  75. data/lib/ronin/generators/exploits/http.rb +42 -0
  76. data/lib/ronin/generators/exploits/local.rb +42 -0
  77. data/lib/ronin/generators/exploits/remote.rb +42 -0
  78. data/lib/ronin/generators/exploits/remote_tcp.rb +44 -0
  79. data/lib/ronin/generators/exploits/remote_udp.rb +44 -0
  80. data/lib/ronin/{exploits/arch.rb → generators/exploits/static.rb} +5 -9
  81. data/lib/ronin/generators/exploits/web.rb +45 -0
  82. data/lib/ronin/generators/payloads.rb +23 -0
  83. data/lib/ronin/generators/payloads/binary_payload.rb +42 -0
  84. data/lib/ronin/generators/payloads/nops.rb +42 -0
  85. data/lib/ronin/generators/payloads/payload.rb +66 -0
  86. data/lib/ronin/generators/payloads/shellcode.rb +42 -0
  87. data/lib/ronin/generators/payloads/static.rb +30 -0
  88. data/lib/ronin/model/has_default_port.rb +6 -6
  89. data/lib/ronin/model/targets_arch.rb +18 -7
  90. data/lib/ronin/model/targets_os.rb +18 -8
  91. data/lib/ronin/model/targets_product.rb +68 -0
  92. data/lib/ronin/payloads.rb +0 -2
  93. data/lib/ronin/payloads/asm_payload.rb +8 -2
  94. data/lib/ronin/payloads/binary_payload.rb +8 -2
  95. data/lib/ronin/payloads/control.rb +1 -5
  96. data/lib/ronin/payloads/encoders.rb +1 -2
  97. data/lib/ronin/payloads/encoders/encoder.rb +92 -0
  98. data/lib/ronin/payloads/encoders/xor.rb +4 -6
  99. data/lib/ronin/payloads/exceptions.rb +1 -2
  100. data/lib/ronin/payloads/{helpers/exceptions/not_implemented.rb → exceptions/exception.rb} +1 -5
  101. data/lib/ronin/payloads/{helpers/exceptions/program_not_found.rb → exceptions/not_implemented.rb} +3 -5
  102. data/lib/ronin/payloads/exceptions/unknown_helper.rb +3 -3
  103. data/lib/ronin/payloads/has_payload.rb +111 -0
  104. data/lib/ronin/payloads/helpers.rb +1 -4
  105. data/lib/ronin/payloads/helpers/chained.rb +61 -0
  106. data/lib/ronin/payloads/helpers/rpc.rb +31 -21
  107. data/lib/ronin/payloads/nops.rb +7 -2
  108. data/lib/ronin/payloads/payload.rb +144 -85
  109. data/lib/ronin/payloads/payload_author.rb +2 -3
  110. data/lib/ronin/payloads/shellcode.rb +8 -5
  111. data/lib/ronin/payloads/web_payload.rb +8 -2
  112. data/lib/ronin/ui/command_line/commands/exploit.rb +193 -0
  113. data/lib/ronin/ui/command_line/commands/exploits.rb +102 -25
  114. data/lib/ronin/ui/command_line/commands/gen_binary_payload.rb +34 -0
  115. data/lib/ronin/ui/command_line/commands/gen_exploit.rb +34 -0
  116. data/lib/ronin/ui/command_line/commands/gen_ftp_exploit.rb +34 -0
  117. data/lib/ronin/ui/command_line/commands/gen_http_exploit.rb +34 -0
  118. data/lib/ronin/ui/command_line/commands/gen_local_exploit.rb +34 -0
  119. data/lib/ronin/{exploits/license.rb → ui/command_line/commands/gen_nops.rb} +8 -8
  120. data/lib/ronin/ui/command_line/commands/gen_payload.rb +34 -0
  121. data/lib/ronin/ui/command_line/commands/gen_remote_exploit.rb +34 -0
  122. data/lib/ronin/ui/command_line/commands/gen_remote_tcp_exploit.rb +34 -0
  123. data/lib/ronin/ui/command_line/commands/gen_remote_udp_exploit.rb +34 -0
  124. data/lib/ronin/ui/command_line/commands/gen_shellcode.rb +34 -0
  125. data/lib/ronin/ui/command_line/commands/gen_web_exploit.rb +34 -0
  126. data/lib/ronin/ui/command_line/commands/payload.rb +73 -50
  127. data/lib/ronin/ui/command_line/commands/payloads.rb +78 -23
  128. data/lib/ronin/vuln/behavior.rb +101 -28
  129. data/spec/controls/behaviors_examples.rb +38 -0
  130. data/spec/exploits/exploit_spec.rb +177 -23
  131. data/spec/exploits/file_based_exploit_spec.rb +16 -7
  132. data/spec/exploits/remote_tcp_spec.rb +1 -1
  133. data/spec/exploits/remote_udp_spec.rb +1 -1
  134. data/spec/generators/exploits/exploit_examples.rb +24 -0
  135. data/spec/generators/exploits/exploit_spec.rb +42 -0
  136. data/spec/generators/exploits/ftp_spec.rb +42 -0
  137. data/spec/generators/exploits/http_spec.rb +42 -0
  138. data/spec/generators/exploits/local_spec.rb +42 -0
  139. data/spec/generators/exploits/remote_spec.rb +42 -0
  140. data/spec/generators/exploits/remote_tcp_spec.rb +47 -0
  141. data/spec/generators/exploits/remote_udp_spec.rb +47 -0
  142. data/spec/generators/exploits/web_spec.rb +52 -0
  143. data/spec/generators/payloads/binary_payload_spec.rb +31 -0
  144. data/spec/generators/payloads/nops_spec.rb +31 -0
  145. data/spec/generators/payloads/payload_examples.rb +16 -0
  146. data/spec/generators/payloads/payload_spec.rb +31 -0
  147. data/spec/generators/payloads/shellcode_spec.rb +31 -0
  148. data/spec/model/models/targets_product_model.rb +11 -0
  149. data/spec/model/targets_arch_spec.rb +11 -1
  150. data/spec/model/targets_os_spec.rb +11 -1
  151. data/spec/model/targets_product_spec.rb +35 -0
  152. data/spec/objects/exploits/{test.rb → simple.rb} +1 -1
  153. data/spec/objects/payloads/{test.rb → simple.rb} +6 -2
  154. data/spec/payloads/encoders/encoder_spec.rb +30 -0
  155. data/spec/payloads/encoders/xor_spec.rb +1 -1
  156. data/spec/payloads/payload_spec.rb +41 -43
  157. data/spec/spec_helper.rb +4 -1
  158. data/static/ronin/generators/exploits/_cache.erb +14 -0
  159. data/static/ronin/generators/exploits/_header.erb +1 -0
  160. data/static/ronin/generators/exploits/_helpers.erb +4 -0
  161. data/static/ronin/generators/exploits/exploit.erb +24 -0
  162. data/static/ronin/generators/exploits/ftp.erb +24 -0
  163. data/static/ronin/generators/exploits/http.erb +26 -0
  164. data/static/ronin/generators/exploits/local.erb +24 -0
  165. data/static/ronin/generators/exploits/remote.erb +24 -0
  166. data/static/ronin/generators/exploits/remote_tcp.erb +26 -0
  167. data/static/ronin/generators/exploits/remote_udp.erb +26 -0
  168. data/static/ronin/generators/exploits/web.erb +28 -0
  169. data/static/ronin/generators/payloads/_cache.erb +10 -0
  170. data/static/ronin/generators/payloads/_header.erb +1 -0
  171. data/static/ronin/generators/payloads/_helpers.erb +2 -0
  172. data/static/ronin/generators/payloads/binary_payload.erb +25 -0
  173. data/static/ronin/generators/payloads/nops.erb +19 -0
  174. data/static/ronin/generators/payloads/payload.erb +25 -0
  175. data/static/ronin/generators/payloads/shellcode.erb +25 -0
  176. data/tasks/spec.rb +1 -0
  177. data/tasks/yard.rb +13 -0
  178. metadata +162 -30
  179. metadata.gz.sig +0 -0
  180. data/TODO.txt +0 -22
  181. data/lib/ronin/exploits/product.rb +0 -34
  182. data/lib/ronin/payloads/encoder.rb +0 -84
  183. data/lib/ronin/payloads/helpers/file_system.rb +0 -187
  184. data/lib/ronin/payloads/helpers/shell.rb +0 -91
  185. data/lib/ronin/payloads/license.rb +0 -34
  186. data/lib/ronin/payloads/os.rb +0 -34
  187. data/spec/payloads/encoder_spec.rb +0 -30
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
3
  # payload crafting functionality.
5
4
  #
@@ -18,9 +17,7 @@
18
17
  # You should have received a copy of the GNU General Public License
19
18
  # along with this program; if not, write to the Free Software
20
19
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
20
  #
23
21
 
24
- require 'ronin/payloads/helpers/file_system'
25
- require 'ronin/payloads/helpers/shell'
22
+ require 'ronin/payloads/helpers/chained'
26
23
  require 'ronin/payloads/helpers/rpc'
@@ -0,0 +1,61 @@
1
+ require 'ronin/payloads/has_payload'
2
+
3
+ module Ronin
4
+ module Payloads
5
+ module Helpers
6
+ module Chained
7
+ include HasPayload
8
+
9
+ #
10
+ # Chains the payload to another payload.
11
+ #
12
+ # @param [Payload] sub_payload
13
+ # The payload chained to this payload.
14
+ #
15
+ # @return [Payload]
16
+ # The chained payload.
17
+ #
18
+ def chain(sub_payload)
19
+ self.payload = sub_payload
20
+ end
21
+
22
+ #
23
+ # Builds the chained payload first, then the payload.
24
+ #
25
+ # @see Payload#build!
26
+ #
27
+ def build!(options={},&block)
28
+ @payload.build!() if @payload
29
+
30
+ return super(options,&block)
31
+ end
32
+
33
+ #
34
+ # Verifies the built payload and deploys the payload. After the
35
+ # payload has been deployed, the chained payload will then be
36
+ # deployed.
37
+ #
38
+ # @yield [(payload)]
39
+ # If a block is given, the chained payload will be passed to the
40
+ # block.
41
+ #
42
+ # @yieldparam [Payload] payload
43
+ # The chained payload.
44
+ #
45
+ # @return [Payload]
46
+ # The chained payload.
47
+ #
48
+ # @see Payload#deploy!
49
+ #
50
+ def deploy!(&block)
51
+ if @payload
52
+ super()
53
+ return @payload.deploy!(&block)
54
+ end
55
+
56
+ return super(&block)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
3
  # payload crafting functionality.
5
4
  #
@@ -18,45 +17,54 @@
18
17
  # You should have received a copy of the GNU General Public License
19
18
  # along with this program; if not, write to the Free Software
20
19
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
20
  #
23
21
 
24
- require 'ronin/payloads/helpers/exceptions/not_implemented'
22
+ require 'ronin/payloads/exceptions/not_implemented'
25
23
 
26
24
  module Ronin
27
25
  module Payloads
28
26
  module Helpers
29
- module RPC
30
- def self.included(base)
31
- base.module_eval do
32
- #
33
- # Exposes the method with the specified _name_.
34
- #
35
- def self.expose_method(name)
36
- define_method(name) do |*arguments|
37
- call_method(name,*arguments)
38
- end
39
- end
40
- end
41
- end
42
-
27
+ module Rpc
28
+ #
29
+ # Calls a specific method with additional arguments.
30
+ #
31
+ # @param [Symbol, String] method
32
+ # The method name to call.
33
+ #
34
+ # @param [Array] arguments
35
+ # The arguments to use when calling the method.
36
+ #
37
+ # @return [Object]
38
+ # The result of the method call.
43
39
  #
44
- # Calls the specified _method_ with the given _arguments_.
45
- # Returns the return-value of the method-call.
40
+ # @since 0.3.0
46
41
  #
47
42
  def call_method(method,*arguments)
48
43
  raise(NotImplemented,"the call method is unimplemented",caller)
49
44
  end
50
45
 
51
46
  #
52
- # Evaluates the specified _code_.
47
+ # Evaluates code.
48
+ #
49
+ # @param [String] code
50
+ # The code to evaluate.
51
+ #
52
+ # @return [Object]
53
+ # The result of the code evaluation.
54
+ #
55
+ # @since 0.3.0
53
56
  #
54
57
  def eval(code)
55
58
  call_method(:eval,code)
56
59
  end
57
60
 
58
61
  #
59
- # Exits with the given _status_.
62
+ # Exits the process.
63
+ #
64
+ # @param [Integer] status
65
+ # The status to exit with.
66
+ #
67
+ # @since 0.3.0
60
68
  #
61
69
  def exit(status=0)
62
70
  call_method(:exit,status)
@@ -68,6 +76,8 @@ module Ronin
68
76
  # Provides transparent access to remote methods using the
69
77
  # specified _name_ and given _arguments_.
70
78
  #
79
+ # @since 0.3.0
80
+ #
71
81
  def method_missing(name,*arguments,&block)
72
82
  name = name.to_s
73
83
 
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
3
  # payload crafting functionality.
5
4
  #
@@ -18,7 +17,6 @@
18
17
  # You should have received a copy of the GNU General Public License
19
18
  # along with this program; if not, write to the Free Software
20
19
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
20
  #
23
21
 
24
22
  require 'ronin/payloads/asm_payload'
@@ -27,6 +25,13 @@ module Ronin
27
25
  module Payloads
28
26
  class Nops < ASMPayload
29
27
 
28
+ #
29
+ # Creates a new Ronin::Payloads::Nops object using the given _block_.
30
+ #
31
+ # ronin_nops do
32
+ # ...
33
+ # end
34
+ #
30
35
  contextify :ronin_nops
31
36
 
32
37
  end
@@ -1,5 +1,4 @@
1
1
  #
2
- #--
3
2
  # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
3
  # payload crafting functionality.
5
4
  #
@@ -18,23 +17,21 @@
18
17
  # You should have received a copy of the GNU General Public License
19
18
  # along with this program; if not, write to the Free Software
20
19
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
- #++
22
20
  #
23
21
 
24
22
  require 'ronin/payloads/exceptions/unknown_helper'
25
- require 'ronin/payloads/license'
26
- require 'ronin/payloads/arch'
27
- require 'ronin/payloads/os'
28
23
  require 'ronin/payloads/payload_author'
29
24
  require 'ronin/payloads/control'
25
+ require 'ronin/cacheable'
30
26
  require 'ronin/model/targets_arch'
31
27
  require 'ronin/model/targets_os'
32
28
  require 'ronin/model/has_name'
33
29
  require 'ronin/model/has_description'
34
30
  require 'ronin/model/has_version'
35
31
  require 'ronin/model/has_license'
36
- require 'ronin/ui/diagnostics'
37
- require 'ronin/cacheable'
32
+ require 'ronin/controls/behaviors'
33
+ require 'ronin/ui/output/helpers'
34
+ require 'ronin/extensions/kernel'
38
35
 
39
36
  require 'parameters'
40
37
 
@@ -50,18 +47,27 @@ module Ronin
50
47
  include Model::HasLicense
51
48
  include Model::TargetsArch
52
49
  include Model::TargetsOS
53
- include UI::Diagnostics
50
+ include Controls::Behaviors
51
+ include UI::Output::Helpers
54
52
 
53
+ #
54
+ # Creates a new Ronin::Payloads::Payload object using the given
55
+ # _block_.
56
+ #
57
+ # ronin_payload do
58
+ # ...
59
+ # end
60
+ #
55
61
  contextify :ronin_payload
56
62
 
57
63
  # Primary key of the payload
58
64
  property :id, Serial
59
65
 
60
66
  # Author(s) of the payload
61
- has n, :authors, :class_name => 'Ronin::Payloads::PayloadAuthor'
67
+ has n, :authors, :model => 'Ronin::Payloads::PayloadAuthor'
62
68
 
63
69
  # Controls the payload provides
64
- has n, :controls
70
+ has n, :controls, :model => 'Ronin::Payloads::Control'
65
71
 
66
72
  # Validations
67
73
  validates_present :name
@@ -70,13 +76,18 @@ module Ronin
70
76
  # The exploit to deploy with
71
77
  attr_accessor :exploit
72
78
 
73
- # The built and encoded payload
74
- attr_accessor :payload
79
+ # The raw payload
80
+ attr_accessor :raw_payload
75
81
 
76
82
  #
77
- # Creates a new Payload object with the given _attributes_. If a
78
- # _block_ is given, it will be passed the newly created Payload
79
- # object.
83
+ # Creates a new Payload object.
84
+ #
85
+ # @param [Array] attributes
86
+ # Additional attributes to initialize the payload with.
87
+ #
88
+ # @yield []
89
+ # If a block is given, it will be evaluated in the newly created
90
+ # Payload object.
80
91
  #
81
92
  def initialize(attributes={},&block)
82
93
  super(attributes)
@@ -90,66 +101,103 @@ module Ronin
90
101
  end
91
102
 
92
103
  #
93
- # Adds a new PayloadAuthor with the given _attributes_. If a _block_
94
- # is given, it will be passed to the newly created PayloadAuthor
95
- # object.
104
+ # Finds all payloads written by a specific author.
96
105
  #
97
- # author :name => 'Anonymous',
98
- # :email => 'anon@example.com',
99
- # :organization => 'Anonymous LLC'
106
+ # @param [String] name
107
+ # The name of the author.
100
108
  #
101
- def author(attributes={},&block)
102
- self.authors << PayloadAuthor.new(attributes,&block)
109
+ # @return [Array<Payload>]
110
+ # The payload written by the author.
111
+ #
112
+ def self.written_by(name)
113
+ all(self.authors.name.like => "%#{name}%")
103
114
  end
104
115
 
105
116
  #
106
- # Adds a new Control to the payload that controls the specified
107
- # _behaviors_.
117
+ # Finds all payloads written for a specific organization.
108
118
  #
109
- # controlling :code_exec.
110
- # :file_read,
111
- # :file_write,
112
- # :file_create
119
+ # @param [String] name
120
+ # The name of the organization.
113
121
  #
114
- def controlling(*behaviors)
115
- behaviors.each do |behavior|
116
- self.controls << Control.new(
117
- :behavior => Vuln::Behavior[behavior]
118
- )
119
- end
122
+ # @return [Array<Payload>]
123
+ # The payloads written for the organization.
124
+ #
125
+ def self.written_for(name)
126
+ all(self.authors.organization.like => "%#{name}%")
120
127
  end
121
128
 
122
129
  #
123
- # Returns the behaviors controlled by the payload.
130
+ # Adds a new author to the payload.
131
+ #
132
+ # @param [Hash] attributes
133
+ # Additional attributes to create the PayloadAuthor object with.
134
+ #
135
+ # @yield [author]
136
+ # If a block is given, it will be passed the newly created author
137
+ # object.
138
+ #
139
+ # @yieldparam [PayloadAuthor] author
140
+ # The author object tied to the payload.
124
141
  #
125
- def behaviors
126
- self.controls.map { |control| control.behavior }
142
+ # @example
143
+ # author :name => 'Anonymous',
144
+ # :email => 'anon@example.com',
145
+ # :organization => 'Anonymous LLC'
146
+ #
147
+ def author(attributes={},&block)
148
+ self.authors << PayloadAuthor.new(attributes,&block)
127
149
  end
128
150
 
129
151
  #
130
- # Returns +true+ if the payload is built, returns +false+ otherwise.
152
+ # @return [Boolean]
153
+ # Specifies whether the payload is built.
131
154
  #
132
155
  def built?
133
156
  @built == true
134
157
  end
135
158
 
136
159
  #
137
- # Performs a clean build of the payload with the given _params_.
138
- # If a _block_ is given, it will be passed the built and encoded
139
- # payload.
160
+ # Builds the payload.
161
+ #
162
+ # @param [Hash] options
163
+ # Additional options to build the payload with and use as
164
+ # parameters.
165
+ #
166
+ # @yield [payload]
167
+ # If a block is given, it will be yielded the result of the
168
+ # payload building.
169
+ #
170
+ # @yieldparam [String] payload
171
+ # The built payload.
172
+ #
173
+ # @return [String]
174
+ # The built payload.
140
175
  #
141
176
  def build!(options={},&block)
142
177
  self.params = options
143
178
 
179
+ print_debug "Payload parameters: #{self.params.inspect}"
180
+
144
181
  @built = false
145
- @payload = ''
182
+ @raw_payload = ''
183
+
184
+ print_info "Building payload ..."
146
185
 
147
186
  build()
148
187
 
188
+ print_info "Payload built!"
189
+
149
190
  @built = true
150
191
 
151
- block.call(@payload) if block
152
- return @payload
192
+ if block
193
+ if block.arity == 1
194
+ block.call(self)
195
+ else
196
+ block.call()
197
+ end
198
+ end
199
+
200
+ return self
153
201
  end
154
202
 
155
203
  #
@@ -157,73 +205,75 @@ module Ronin
157
205
  # deployed.
158
206
  #
159
207
  def verify!
208
+ print_info "Verifying payload ..."
209
+
160
210
  verify
211
+
212
+ print_info "Payload verified!"
161
213
  end
162
214
 
163
215
  #
164
- # Returns +true+ if the payload has previously been deployed,
165
- # returns +false+ otherwise.
216
+ # @return [Boolean]
217
+ # Specifies whether the payload has previously been deployed.
166
218
  #
167
219
  def deployed?
168
220
  @deployed == true
169
221
  end
170
222
 
171
223
  #
172
- # Verifies the built payload and deploys the payload. If a _block_
173
- # is given, it will be passed the deployed payload object. If
174
- # an exploit is given, it will be called with the given _options_
175
- # and the built payload before the payload is deployed.
224
+ # Verifies the built payload and deploys the payload.
225
+ #
226
+ # @yield [payload]
227
+ # If a block is given, it will be passed the deployed payload.
228
+ #
229
+ # @yieldparam [Payload] payload
230
+ # The deployed payload.
176
231
  #
177
- def deploy!(options={},&block)
232
+ def deploy!(&block)
178
233
  # verify the payload
179
234
  verify!
180
235
 
181
- if @exploit
182
- # build, verify and deploy the exploit with the built payload
183
- @exploit.call(options.merge(:payload => @payload))
184
- end
185
-
236
+ print_info "Deploying payload ..."
186
237
  @deployed = false
187
238
 
188
239
  deploy()
189
240
 
241
+ print_info "Payload deployed!"
190
242
  @deployed = true
191
243
 
192
- block.call(self) if block
193
- return self
194
- end
195
-
196
- #
197
- # Builds the payload with the given _options_ and deploys it with
198
- # the given _block_. If a _block_ is given, it will be passed the
199
- # deployed payload object.
200
- #
201
- # _options_ may contain the following keys:
202
- # <tt>:exploit</tt>:: The exploit object to use with the payload.
203
- #
204
- def call(options={},&block)
205
- if options[:exploit]
206
- # set the exploit if one is given
207
- @exploit = options.delete(:exploit)
244
+ if block
245
+ if block.arity == 1
246
+ block.call(self)
247
+ else
248
+ block.call()
249
+ end
208
250
  end
209
251
 
210
- # build the payload
211
- build!(options)
212
-
213
- # deploy the payload
214
- return deploy!(options,&block)
252
+ return self
215
253
  end
216
254
 
217
255
  #
218
- # Returns the name and version of the payload.
256
+ # Converts the payload to a String.
257
+ #
258
+ # @return [String]
259
+ # The name and version of the payload.
219
260
  #
220
261
  def to_s
221
- "#{self.name} #{self.version}"
262
+ if (self.name && self.version)
263
+ "#{self.name} #{self.version}"
264
+ elsif self.name
265
+ self.name
266
+ elsif self.version
267
+ self.version
268
+ end
222
269
  end
223
270
 
224
271
  #
225
272
  # Inspects the contents of the payload.
226
273
  #
274
+ # @return [String]
275
+ # The inspected payload.
276
+ #
227
277
  def inspect
228
278
  str = "#{self.class}: #{self}"
229
279
  str << " #{self.params.inspect}" unless self.params.empty?
@@ -235,11 +285,20 @@ module Ronin
235
285
 
236
286
  #
237
287
  # Extends the payload with the helper module defined in
238
- # Ronin::Payloads::Helpers that has the similar specified
239
- # _name_. If no module can be found within
240
- # Ronin::Payloads::Helpers with the similar _name_, an
241
- # UnknownHelper exception will be raised.
288
+ # Ronin::Payloads::Helpers that has the similar name.
289
+ #
290
+ # @param [Symbol, String] name
291
+ # The snake-case name of the payload helper to load and extend the
292
+ # payload with.
293
+ #
294
+ # @return [true]
295
+ # The payload helper was successfully loaded.
296
+ #
297
+ # @raise [UnknownHelper]
298
+ # No valid helper module could be found or loaded with the similar
299
+ # name.
242
300
  #
301
+ # @example
243
302
  # helper :shell
244
303
  #
245
304
  def helper(name)
@@ -247,7 +306,7 @@ module Ronin
247
306
  module_name = name.to_const_string
248
307
 
249
308
  begin
250
- require File.join('ronin','payloads','helpers',name)
309
+ require_within File.join('ronin','payloads','helpers'), name
251
310
  rescue Gem::LoadError => e
252
311
  raise(e)
253
312
  rescue ::LoadError