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.
- data.tar.gz.sig +0 -0
- data/History.txt +122 -0
- data/Manifest.txt +110 -20
- data/README.txt +112 -31
- data/Rakefile +12 -1
- data/bin/ronin-exploit +12 -0
- data/bin/ronin-exploits +1 -1
- data/bin/ronin-gen-binary-payload +12 -0
- data/bin/ronin-gen-exploit +12 -0
- data/bin/ronin-gen-ftp-exploit +12 -0
- data/bin/ronin-gen-http-exploit +12 -0
- data/bin/ronin-gen-local-exploit +12 -0
- data/bin/ronin-gen-nops +12 -0
- data/bin/ronin-gen-payload +12 -0
- data/bin/ronin-gen-remote-exploit +12 -0
- data/bin/ronin-gen-remote-tcp-exploit +12 -0
- data/bin/ronin-gen-remote-udp-exploit +12 -0
- data/bin/ronin-gen-shellcode +12 -0
- data/bin/ronin-gen-web-exploit +12 -0
- data/bin/ronin-payload +1 -1
- data/bin/ronin-payloads +1 -1
- data/lib/ronin/controls.rb +23 -0
- data/lib/ronin/controls/behaviors.rb +133 -0
- data/lib/ronin/{payloads/helpers → controls}/exceptions.rb +2 -4
- data/lib/ronin/{payloads/arch.rb → controls/exceptions/not_implemented.rb} +3 -8
- data/lib/ronin/controls/exceptions/program_not_found.rb +27 -0
- data/lib/ronin/controls/file_system.rb +145 -0
- data/lib/ronin/{exploits/os.rb → controls/helpers.rb} +12 -13
- data/lib/ronin/controls/helpers/command_exec.rb +143 -0
- data/lib/ronin/controls/helpers/dir_create.rb +42 -0
- data/lib/ronin/controls/helpers/dir_listing.rb +62 -0
- data/lib/ronin/controls/helpers/dir_remove.rb +42 -0
- data/lib/ronin/controls/helpers/file_ctime.rb +52 -0
- data/lib/ronin/controls/helpers/file_mtime.rb +53 -0
- data/lib/ronin/controls/helpers/file_ownership.rb +53 -0
- data/lib/ronin/controls/helpers/file_read.rb +62 -0
- data/lib/ronin/controls/helpers/file_remove.rb +51 -0
- data/lib/ronin/controls/helpers/file_write.rb +62 -0
- data/lib/ronin/controls/helpers/memory_read.rb +39 -0
- data/lib/ronin/controls/helpers/memory_write.rb +39 -0
- data/lib/ronin/exploits.rb +0 -2
- data/lib/ronin/exploits/{allow.rb → control.rb} +5 -9
- data/lib/ronin/exploits/exceptions.rb +1 -2
- data/lib/ronin/exploits/exceptions/exception.rb +27 -0
- data/lib/ronin/exploits/exceptions/exploit_not_built.rb +3 -3
- data/lib/ronin/exploits/exceptions/payload_size.rb +3 -3
- data/lib/ronin/exploits/exceptions/restricted_char.rb +3 -3
- data/lib/ronin/exploits/exceptions/target_data_missing.rb +3 -3
- data/lib/ronin/exploits/exceptions/target_unspecified.rb +3 -3
- data/lib/ronin/exploits/exceptions/unknown_helper.rb +3 -3
- data/lib/ronin/exploits/exploit.rb +449 -92
- data/lib/ronin/exploits/exploit_author.rb +2 -3
- data/lib/ronin/exploits/ftp.rb +7 -2
- data/lib/ronin/exploits/helpers.rb +0 -2
- data/lib/ronin/exploits/helpers/binary.rb +11 -5
- data/lib/ronin/exploits/helpers/buffer_overflow.rb +38 -25
- data/lib/ronin/exploits/helpers/file_based.rb +29 -30
- data/lib/ronin/exploits/helpers/format_string.rb +34 -24
- data/lib/ronin/exploits/helpers/padding.rb +33 -16
- data/lib/ronin/exploits/http.rb +9 -4
- data/lib/ronin/exploits/local.rb +8 -2
- data/lib/ronin/exploits/remote.rb +8 -2
- data/lib/ronin/exploits/remote_tcp.rb +26 -8
- data/lib/ronin/exploits/remote_udp.rb +26 -8
- data/lib/ronin/exploits/target.rb +41 -30
- data/lib/ronin/exploits/targets.rb +0 -2
- data/lib/ronin/exploits/targets/buffer_overflow.rb +0 -2
- data/lib/ronin/exploits/targets/format_string.rb +0 -2
- data/lib/ronin/exploits/verifiers.rb +45 -16
- data/lib/ronin/exploits/version.rb +1 -3
- data/lib/ronin/exploits/web.rb +18 -6
- data/lib/ronin/generators/exploits.rb +23 -0
- data/lib/ronin/generators/exploits/exploit.rb +70 -0
- data/lib/ronin/generators/exploits/ftp.rb +42 -0
- data/lib/ronin/generators/exploits/http.rb +42 -0
- data/lib/ronin/generators/exploits/local.rb +42 -0
- data/lib/ronin/generators/exploits/remote.rb +42 -0
- data/lib/ronin/generators/exploits/remote_tcp.rb +44 -0
- data/lib/ronin/generators/exploits/remote_udp.rb +44 -0
- data/lib/ronin/{exploits/arch.rb → generators/exploits/static.rb} +5 -9
- data/lib/ronin/generators/exploits/web.rb +45 -0
- data/lib/ronin/generators/payloads.rb +23 -0
- data/lib/ronin/generators/payloads/binary_payload.rb +42 -0
- data/lib/ronin/generators/payloads/nops.rb +42 -0
- data/lib/ronin/generators/payloads/payload.rb +66 -0
- data/lib/ronin/generators/payloads/shellcode.rb +42 -0
- data/lib/ronin/generators/payloads/static.rb +30 -0
- data/lib/ronin/model/has_default_port.rb +6 -6
- data/lib/ronin/model/targets_arch.rb +18 -7
- data/lib/ronin/model/targets_os.rb +18 -8
- data/lib/ronin/model/targets_product.rb +68 -0
- data/lib/ronin/payloads.rb +0 -2
- data/lib/ronin/payloads/asm_payload.rb +8 -2
- data/lib/ronin/payloads/binary_payload.rb +8 -2
- data/lib/ronin/payloads/control.rb +1 -5
- data/lib/ronin/payloads/encoders.rb +1 -2
- data/lib/ronin/payloads/encoders/encoder.rb +92 -0
- data/lib/ronin/payloads/encoders/xor.rb +4 -6
- data/lib/ronin/payloads/exceptions.rb +1 -2
- data/lib/ronin/payloads/{helpers/exceptions/not_implemented.rb → exceptions/exception.rb} +1 -5
- data/lib/ronin/payloads/{helpers/exceptions/program_not_found.rb → exceptions/not_implemented.rb} +3 -5
- data/lib/ronin/payloads/exceptions/unknown_helper.rb +3 -3
- data/lib/ronin/payloads/has_payload.rb +111 -0
- data/lib/ronin/payloads/helpers.rb +1 -4
- data/lib/ronin/payloads/helpers/chained.rb +61 -0
- data/lib/ronin/payloads/helpers/rpc.rb +31 -21
- data/lib/ronin/payloads/nops.rb +7 -2
- data/lib/ronin/payloads/payload.rb +144 -85
- data/lib/ronin/payloads/payload_author.rb +2 -3
- data/lib/ronin/payloads/shellcode.rb +8 -5
- data/lib/ronin/payloads/web_payload.rb +8 -2
- data/lib/ronin/ui/command_line/commands/exploit.rb +193 -0
- data/lib/ronin/ui/command_line/commands/exploits.rb +102 -25
- data/lib/ronin/ui/command_line/commands/gen_binary_payload.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_ftp_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_http_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_local_exploit.rb +34 -0
- data/lib/ronin/{exploits/license.rb → ui/command_line/commands/gen_nops.rb} +8 -8
- data/lib/ronin/ui/command_line/commands/gen_payload.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_remote_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_remote_tcp_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_remote_udp_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_shellcode.rb +34 -0
- data/lib/ronin/ui/command_line/commands/gen_web_exploit.rb +34 -0
- data/lib/ronin/ui/command_line/commands/payload.rb +73 -50
- data/lib/ronin/ui/command_line/commands/payloads.rb +78 -23
- data/lib/ronin/vuln/behavior.rb +101 -28
- data/spec/controls/behaviors_examples.rb +38 -0
- data/spec/exploits/exploit_spec.rb +177 -23
- data/spec/exploits/file_based_exploit_spec.rb +16 -7
- data/spec/exploits/remote_tcp_spec.rb +1 -1
- data/spec/exploits/remote_udp_spec.rb +1 -1
- data/spec/generators/exploits/exploit_examples.rb +24 -0
- data/spec/generators/exploits/exploit_spec.rb +42 -0
- data/spec/generators/exploits/ftp_spec.rb +42 -0
- data/spec/generators/exploits/http_spec.rb +42 -0
- data/spec/generators/exploits/local_spec.rb +42 -0
- data/spec/generators/exploits/remote_spec.rb +42 -0
- data/spec/generators/exploits/remote_tcp_spec.rb +47 -0
- data/spec/generators/exploits/remote_udp_spec.rb +47 -0
- data/spec/generators/exploits/web_spec.rb +52 -0
- data/spec/generators/payloads/binary_payload_spec.rb +31 -0
- data/spec/generators/payloads/nops_spec.rb +31 -0
- data/spec/generators/payloads/payload_examples.rb +16 -0
- data/spec/generators/payloads/payload_spec.rb +31 -0
- data/spec/generators/payloads/shellcode_spec.rb +31 -0
- data/spec/model/models/targets_product_model.rb +11 -0
- data/spec/model/targets_arch_spec.rb +11 -1
- data/spec/model/targets_os_spec.rb +11 -1
- data/spec/model/targets_product_spec.rb +35 -0
- data/spec/objects/exploits/{test.rb → simple.rb} +1 -1
- data/spec/objects/payloads/{test.rb → simple.rb} +6 -2
- data/spec/payloads/encoders/encoder_spec.rb +30 -0
- data/spec/payloads/encoders/xor_spec.rb +1 -1
- data/spec/payloads/payload_spec.rb +41 -43
- data/spec/spec_helper.rb +4 -1
- data/static/ronin/generators/exploits/_cache.erb +14 -0
- data/static/ronin/generators/exploits/_header.erb +1 -0
- data/static/ronin/generators/exploits/_helpers.erb +4 -0
- data/static/ronin/generators/exploits/exploit.erb +24 -0
- data/static/ronin/generators/exploits/ftp.erb +24 -0
- data/static/ronin/generators/exploits/http.erb +26 -0
- data/static/ronin/generators/exploits/local.erb +24 -0
- data/static/ronin/generators/exploits/remote.erb +24 -0
- data/static/ronin/generators/exploits/remote_tcp.erb +26 -0
- data/static/ronin/generators/exploits/remote_udp.erb +26 -0
- data/static/ronin/generators/exploits/web.erb +28 -0
- data/static/ronin/generators/payloads/_cache.erb +10 -0
- data/static/ronin/generators/payloads/_header.erb +1 -0
- data/static/ronin/generators/payloads/_helpers.erb +2 -0
- data/static/ronin/generators/payloads/binary_payload.erb +25 -0
- data/static/ronin/generators/payloads/nops.erb +19 -0
- data/static/ronin/generators/payloads/payload.erb +25 -0
- data/static/ronin/generators/payloads/shellcode.erb +25 -0
- data/tasks/spec.rb +1 -0
- data/tasks/yard.rb +13 -0
- metadata +162 -30
- metadata.gz.sig +0 -0
- data/TODO.txt +0 -22
- data/lib/ronin/exploits/product.rb +0 -34
- data/lib/ronin/payloads/encoder.rb +0 -84
- data/lib/ronin/payloads/helpers/file_system.rb +0 -187
- data/lib/ronin/payloads/helpers/shell.rb +0 -91
- data/lib/ronin/payloads/license.rb +0 -34
- data/lib/ronin/payloads/os.rb +0 -34
- 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,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/author'
|
@@ -27,7 +25,8 @@ module Ronin
|
|
27
25
|
module Exploits
|
28
26
|
class ExploitAuthor < Author
|
29
27
|
|
30
|
-
|
28
|
+
# The exploit the author wrote
|
29
|
+
belongs_to :exploit, :nullable => true
|
31
30
|
|
32
31
|
end
|
33
32
|
end
|
data/lib/ronin/exploits/ftp.rb
CHANGED
@@ -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/exploits/remote_tcp'
|
@@ -30,6 +28,13 @@ module Ronin
|
|
30
28
|
# Default port to connect to
|
31
29
|
DEFAULT_PORT = 21
|
32
30
|
|
31
|
+
#
|
32
|
+
# Creates a new Ronin::Exploits::FTP object using the given _block_.
|
33
|
+
#
|
34
|
+
# ronin_ftp_exploit do
|
35
|
+
# ...
|
36
|
+
# end
|
37
|
+
#
|
33
38
|
contextify :ronin_ftp_exploit
|
34
39
|
|
35
40
|
# Default port to connect to
|
@@ -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/exploits/helpers/file_based'
|
@@ -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/exploits/exceptions/target_data_missing'
|
@@ -29,9 +27,17 @@ module Ronin
|
|
29
27
|
module Helpers
|
30
28
|
module Binary
|
31
29
|
#
|
32
|
-
# Packs
|
33
|
-
# and the
|
34
|
-
#
|
30
|
+
# Packs an integer using the current targeted architecture
|
31
|
+
# and the address-length.
|
32
|
+
#
|
33
|
+
# @param [Integer] integer
|
34
|
+
# The integer to pack.
|
35
|
+
#
|
36
|
+
# @param [Integer] address_length
|
37
|
+
# The address-length to pack the integer into.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
# The packed integer.
|
35
41
|
#
|
36
42
|
def pack(integer,address_length=nil)
|
37
43
|
verify_arch!
|
@@ -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,59 +17,72 @@
|
|
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/exploits/exceptions/payload_size'
|
25
23
|
require 'ronin/exploits/targets/buffer_overflow'
|
26
24
|
require 'ronin/exploits/helpers/binary'
|
27
25
|
require 'ronin/exploits/helpers/padding'
|
26
|
+
require 'ronin/payloads/shellcode'
|
28
27
|
|
29
28
|
module Ronin
|
30
29
|
module Exploits
|
31
30
|
module Helpers
|
32
31
|
module BufferOverflow
|
33
|
-
def self.included(base)
|
34
|
-
base.module_eval do
|
35
|
-
include Ronin::Exploits::Helpers::Binary
|
36
|
-
include Ronin::Exploits::Helpers::Padding
|
37
|
-
|
38
|
-
has n, :targets,
|
39
|
-
:class_name => 'Ronin::Exploits::Targets::BufferOverflow'
|
40
|
-
|
41
|
-
# The buffer to use for the buffer overflow
|
42
|
-
attr_reader :buffer
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
32
|
def self.extended(obj)
|
47
33
|
obj.instance_eval do
|
48
34
|
extend Ronin::Exploits::Helpers::Binary
|
49
35
|
extend Ronin::Exploits::Helpers::Padding
|
50
|
-
|
51
|
-
#
|
52
|
-
# Returns the buffer to use for the buffer overflow.
|
53
|
-
#
|
54
|
-
def buffer
|
55
|
-
@buffer
|
56
|
-
end
|
57
36
|
end
|
58
37
|
end
|
59
38
|
|
60
39
|
#
|
61
|
-
#
|
62
|
-
#
|
40
|
+
# @return [String]
|
41
|
+
# The buffer to use for the buffer overflow.
|
42
|
+
#
|
43
|
+
def buffer
|
44
|
+
@buffer ||= ''
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Adds a new target to the exploit.
|
49
|
+
#
|
50
|
+
# @param [Hash] attributes
|
51
|
+
# Additional attributes to create the new target with.
|
52
|
+
#
|
53
|
+
# @yield [target]
|
54
|
+
# If a block is given, it will be passed the newly created target.
|
55
|
+
#
|
56
|
+
# @yieldparam [Targets::BufferOverflow] target
|
57
|
+
# The new target.
|
63
58
|
#
|
64
59
|
def targeting(attributes={},&block)
|
65
60
|
self.targets << Targets::BufferOverflow.new(attributes,&block)
|
66
61
|
end
|
67
62
|
|
63
|
+
#
|
64
|
+
# @return [Payloads::Shellcode]
|
65
|
+
# The model which will be searched for acceptable payloads.
|
66
|
+
#
|
67
|
+
# @since 0.3.0
|
68
|
+
#
|
69
|
+
def use_payload_class
|
70
|
+
Payloads::Shellcode
|
71
|
+
end
|
72
|
+
|
68
73
|
protected
|
69
74
|
|
70
75
|
#
|
71
76
|
# Builds the buffer with the current target and payload to be
|
72
77
|
# used in the buffer overflow exploit.
|
73
78
|
#
|
79
|
+
# @return [String]
|
80
|
+
# The built buffer.
|
81
|
+
#
|
82
|
+
# @raise [PayloadSize]
|
83
|
+
# The encoded payload is too large to fit within the targeted
|
84
|
+
# buffer length.
|
85
|
+
#
|
74
86
|
def build_buffer
|
75
87
|
verify_target!
|
76
88
|
|
@@ -91,7 +103,8 @@ module Ronin
|
|
91
103
|
end
|
92
104
|
|
93
105
|
#
|
94
|
-
# Default builder method which simply calls build_buffer
|
106
|
+
# Default builder method which simply calls build_buffer and sets
|
107
|
+
# the +@buffer+ instance variable..
|
95
108
|
#
|
96
109
|
def build
|
97
110
|
@buffer = build_buffer
|
@@ -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/config'
|
@@ -30,32 +28,19 @@ module Ronin
|
|
30
28
|
module Exploits
|
31
29
|
module Helpers
|
32
30
|
module FileBased
|
33
|
-
def self.included(base)
|
34
|
-
base.module_eval do
|
35
|
-
parameter :output_dir,
|
36
|
-
:default => Config::TMP_DIR,
|
37
|
-
:description => 'Directory to save built file in'
|
38
|
-
|
39
|
-
parameter :file_name,
|
40
|
-
:default => 'exploit',
|
41
|
-
:description => 'Name of the file'
|
42
|
-
|
43
|
-
parameter :clean_file,
|
44
|
-
:default => true,
|
45
|
-
:description => 'Delete the file on exit'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
31
|
def self.extended(obj)
|
50
32
|
obj.instance_eval do
|
33
|
+
# The output directory for file creation
|
51
34
|
parameter :output_dir,
|
52
35
|
:default => Config::TMP_DIR,
|
53
36
|
:description => 'Directory to save built file in'
|
54
37
|
|
55
|
-
|
38
|
+
# The name of the output file
|
39
|
+
parameter :output_file_name,
|
56
40
|
:default => 'exploit',
|
57
41
|
:description => 'Name of the file'
|
58
42
|
|
43
|
+
# Whether or not to delete the output file at exit
|
59
44
|
parameter :clean_file,
|
60
45
|
:default => true,
|
61
46
|
:description => 'Delete the file on exit'
|
@@ -63,15 +48,20 @@ module Ronin
|
|
63
48
|
end
|
64
49
|
|
65
50
|
#
|
66
|
-
# List of files to delete
|
51
|
+
# List of files to delete upon exit.
|
52
|
+
#
|
53
|
+
# @return [Set]
|
54
|
+
# The list of files to delete upon exit.
|
67
55
|
#
|
68
56
|
def FileBased.clean_files
|
69
57
|
@@ronin_exploits_file_based_clean_files ||= Set[]
|
70
58
|
end
|
71
59
|
|
72
60
|
#
|
73
|
-
# Will forcibly delete the files listed in FileBased.clean_files
|
74
|
-
#
|
61
|
+
# Will forcibly delete the files listed in FileBased.clean_files.
|
62
|
+
#
|
63
|
+
# @return [true]
|
64
|
+
# The all files were successfully deleted.
|
75
65
|
#
|
76
66
|
def FileBased.clean!
|
77
67
|
FileBased.clean_files.each do |path|
|
@@ -85,24 +75,33 @@ module Ronin
|
|
85
75
|
at_exit(&FileBased.method(:clean!))
|
86
76
|
|
87
77
|
#
|
88
|
-
#
|
78
|
+
# @return [String]
|
79
|
+
# The absolute path of the file to be built.
|
89
80
|
#
|
90
|
-
def
|
91
|
-
File.expand_path(
|
81
|
+
def output_file_path
|
82
|
+
sanitized_name = File.expand_path(File.join('',@output_file_name))
|
83
|
+
|
84
|
+
return File.expand_path(File.join(@output_dir,sanitized_name))
|
92
85
|
end
|
93
86
|
|
94
87
|
protected
|
95
88
|
|
96
89
|
#
|
97
|
-
# Opens the file to be built
|
98
|
-
#
|
90
|
+
# Opens the file to be built.
|
91
|
+
#
|
92
|
+
# @yield [file]
|
93
|
+
# If a block is given, it will be passed the newly opened file.
|
94
|
+
#
|
95
|
+
# @yieldparam [File] file
|
96
|
+
# The newly opened file.
|
99
97
|
#
|
100
|
-
#
|
98
|
+
# @example
|
99
|
+
# build_file do |file|
|
101
100
|
# file << 'some data'
|
102
101
|
# end
|
103
102
|
#
|
104
|
-
def
|
105
|
-
path = self.
|
103
|
+
def build_file(&block)
|
104
|
+
path = self.output_file_path
|
106
105
|
|
107
106
|
FileBased.clean_files << path if @clean_file
|
108
107
|
return File.open(path,'w',&block)
|
@@ -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,55 +17,65 @@
|
|
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/exploits/targets/format_string'
|
25
23
|
require 'ronin/exploits/helpers/binary'
|
24
|
+
require 'ronin/payloads/shellcode'
|
26
25
|
|
27
26
|
module Ronin
|
28
27
|
module Exploits
|
29
28
|
module Helpers
|
30
29
|
module FormatString
|
31
|
-
def self.included(base)
|
32
|
-
base.module_eval do
|
33
|
-
include Ronin::Exploits::Helpers::Binary
|
34
|
-
|
35
|
-
has n, :targets,
|
36
|
-
:class_name => 'Ronin::Exploits::Targets::FormatString'
|
37
|
-
|
38
|
-
# The built format string
|
39
|
-
attr_reader :format_string
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
30
|
def self.extended(obj)
|
44
31
|
obj.instance_eval do
|
45
32
|
extend Ronin::Exploits::Helpers::Binary
|
46
|
-
|
47
|
-
#
|
48
|
-
# Returns the format string of the exploit.
|
49
|
-
#
|
50
|
-
def format_string
|
51
|
-
@format_string
|
52
|
-
end
|
53
33
|
end
|
54
34
|
end
|
55
35
|
|
56
36
|
#
|
57
|
-
#
|
58
|
-
#
|
37
|
+
# @return [String]
|
38
|
+
# The format string of the exploit.
|
39
|
+
#
|
40
|
+
def format_string
|
41
|
+
@format_string ||= ''
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Adds a new target to the exploit.
|
46
|
+
#
|
47
|
+
# @param [Hash] attributes
|
48
|
+
# Additioanl attributes to create the target with.
|
49
|
+
#
|
50
|
+
# @yield [target]
|
51
|
+
# If a block is given, it will be passed the newly created target.
|
52
|
+
#
|
53
|
+
# @yieldparam [Targets::FormatString] target
|
54
|
+
# The newly created target.
|
59
55
|
#
|
60
56
|
def targeting(attributes={},&block)
|
61
57
|
self.targets << Targets::FormatString.new(attributes,&block)
|
62
58
|
end
|
63
59
|
|
60
|
+
#
|
61
|
+
# @return [Payloads::Shellcode]
|
62
|
+
# The model which will be searched for acceptable payloads.
|
63
|
+
#
|
64
|
+
# @since 0.3.0
|
65
|
+
#
|
66
|
+
def use_payload_class
|
67
|
+
Payload::Shellcode
|
68
|
+
end
|
69
|
+
|
64
70
|
protected
|
65
71
|
|
66
72
|
#
|
67
73
|
# Builds a format string using the current target and payload to
|
68
74
|
# be used in the format string exploit.
|
69
75
|
#
|
76
|
+
# @return [String]
|
77
|
+
# The built format string.
|
78
|
+
#
|
70
79
|
def build_format_string
|
71
80
|
verify_target!
|
72
81
|
|
@@ -96,7 +105,8 @@ module Ronin
|
|
96
105
|
end
|
97
106
|
|
98
107
|
#
|
99
|
-
# The default builder method
|
108
|
+
# The default builder method which simply calls build_format_string
|
109
|
+
# and sets the +@format_string+ instance variable.
|
100
110
|
#
|
101
111
|
def build
|
102
112
|
@format_string = build_format_string
|
@@ -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/formatting/text'
|
@@ -27,15 +25,6 @@ module Ronin
|
|
27
25
|
module Exploits
|
28
26
|
module Helpers
|
29
27
|
module Padding
|
30
|
-
def self.included(base)
|
31
|
-
base.module_eval do
|
32
|
-
# String to pad extra space with
|
33
|
-
parameter :padding,
|
34
|
-
:default => 'A',
|
35
|
-
:description => 'padding string'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
28
|
def self.extended(obj)
|
40
29
|
obj.instance_eval do
|
41
30
|
# String to pad extra space with
|
@@ -48,8 +37,16 @@ module Ronin
|
|
48
37
|
protected
|
49
38
|
|
50
39
|
#
|
51
|
-
#
|
40
|
+
# Creates padding out to a maximum length, using the +padding+
|
41
|
+
# parameter.
|
42
|
+
#
|
43
|
+
# @param [Integer] max_length
|
44
|
+
# The maximum length to pad out to.
|
52
45
|
#
|
46
|
+
# @return [String]
|
47
|
+
# A padded string.
|
48
|
+
#
|
49
|
+
# @example
|
53
50
|
# pad(28)
|
54
51
|
# # => "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
55
52
|
#
|
@@ -58,9 +55,19 @@ module Ronin
|
|
58
55
|
end
|
59
56
|
|
60
57
|
#
|
61
|
-
# Pads the
|
62
|
-
#
|
58
|
+
# Pads the a string on the right-hand side out to a maximum length,
|
59
|
+
# using the +padding+ parameter.
|
60
|
+
#
|
61
|
+
# @param [String] data
|
62
|
+
# The string to add padding to.
|
63
|
+
#
|
64
|
+
# @param [Integer] max_length
|
65
|
+
# The amount of padding to add.
|
66
|
+
#
|
67
|
+
# @return [String]
|
68
|
+
# The left-hand side padded string.
|
63
69
|
#
|
70
|
+
# @example
|
64
71
|
# pad_left("\xff\xff",48)
|
65
72
|
# # => "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\xff\xff"
|
66
73
|
#
|
@@ -69,9 +76,19 @@ module Ronin
|
|
69
76
|
end
|
70
77
|
|
71
78
|
#
|
72
|
-
# Pads the
|
73
|
-
#
|
79
|
+
# Pads the a string on the right-hand side out to a maximum length,
|
80
|
+
# using the +padding+ parameter.
|
81
|
+
#
|
82
|
+
# @param [String] data
|
83
|
+
# The string to add padding to.
|
84
|
+
#
|
85
|
+
# @param [Integer] max_length
|
86
|
+
# The amount of padding to add.
|
87
|
+
#
|
88
|
+
# @return [String]
|
89
|
+
# The right-hand side padded string.
|
74
90
|
#
|
91
|
+
# @example
|
75
92
|
# pad_right("\xff\xff",48)
|
76
93
|
# # => "\xff\xffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
77
94
|
#
|