ronin-exploits 0.1.1 → 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 (89) hide show
  1. data/History.txt +80 -2
  2. data/Manifest.txt +63 -16
  3. data/README.txt +89 -2
  4. data/Rakefile +1 -1
  5. data/TODO.txt +1 -1
  6. data/bin/ronin-exploits +12 -0
  7. data/bin/ronin-payload +12 -0
  8. data/bin/ronin-payloads +12 -0
  9. data/lib/ronin/exploits.rb +13 -10
  10. data/lib/ronin/exploits/{impact.rb → allow.rb} +9 -4
  11. data/lib/ronin/exploits/exceptions.rb +3 -0
  12. data/lib/ronin/exploits/exceptions/target_data_missing.rb +29 -0
  13. data/lib/ronin/exploits/exceptions/target_unspecified.rb +29 -0
  14. data/lib/ronin/exploits/exceptions/unknown_helper.rb +29 -0
  15. data/lib/ronin/exploits/exploit.rb +330 -77
  16. data/lib/ronin/exploits/{format_string_target.rb → ftp.rb} +5 -11
  17. data/lib/ronin/exploits/helpers.rb +27 -0
  18. data/lib/ronin/exploits/helpers/binary.rb +44 -0
  19. data/lib/ronin/exploits/helpers/buffer_overflow.rb +102 -0
  20. data/lib/ronin/exploits/helpers/format_string.rb +107 -0
  21. data/lib/ronin/exploits/helpers/padding.rb +84 -0
  22. data/lib/ronin/exploits/http.rb +37 -0
  23. data/lib/ronin/exploits/{requirement.rb → local.rb} +2 -14
  24. data/lib/ronin/exploits/remote.rb +34 -0
  25. data/lib/ronin/exploits/remote_tcp.rb +70 -0
  26. data/lib/ronin/exploits/remote_udp.rb +70 -0
  27. data/lib/ronin/exploits/target.rb +134 -0
  28. data/lib/ronin/exploits/targets.rb +29 -0
  29. data/lib/ronin/exploits/{buffer_overflow_target.rb → targets/buffer_overflow.rb} +13 -11
  30. data/lib/ronin/exploits/{exploit_target.rb → targets/format_string.rb} +11 -14
  31. data/lib/ronin/exploits/version.rb +1 -1
  32. data/lib/ronin/exploits/{web_exploit.rb → web.rb} +3 -3
  33. data/lib/ronin/model/targets_arch.rb +59 -0
  34. data/lib/ronin/model/targets_os.rb +59 -0
  35. data/lib/ronin/payloads.rb +7 -3
  36. data/lib/ronin/payloads/binary_payload.rb +3 -7
  37. data/lib/ronin/payloads/{ability.rb → control.rb} +7 -2
  38. data/lib/ronin/payloads/encoder.rb +78 -0
  39. data/lib/ronin/payloads/encoders.rb +33 -0
  40. data/lib/ronin/payloads/encoders/xor.rb +81 -0
  41. data/lib/ronin/payloads/exceptions.rb +24 -0
  42. data/lib/ronin/payloads/exceptions/unknown_helper.rb +29 -0
  43. data/lib/ronin/payloads/helpers.rb +26 -0
  44. data/lib/ronin/payloads/helpers/exceptions.rb +24 -0
  45. data/lib/ronin/payloads/helpers/exceptions/program_not_found.rb +31 -0
  46. data/lib/ronin/payloads/helpers/exceptions/unimplemented.rb +31 -0
  47. data/lib/ronin/payloads/helpers/file_system.rb +187 -0
  48. data/lib/ronin/payloads/helpers/rpc.rb +83 -0
  49. data/lib/ronin/payloads/helpers/shell.rb +91 -0
  50. data/lib/ronin/payloads/nops.rb +32 -0
  51. data/lib/ronin/payloads/payload.rb +90 -53
  52. data/lib/ronin/payloads/shellcode.rb +1 -1
  53. data/lib/ronin/payloads/web_payload.rb +2 -1
  54. data/lib/ronin/targeted_arch.rb +38 -0
  55. data/lib/ronin/targeted_os.rb +38 -0
  56. data/lib/ronin/targeted_product.rb +34 -0
  57. data/lib/ronin/ui/command_line/commands/exploits.rb +77 -0
  58. data/lib/ronin/ui/command_line/commands/payload.rb +106 -0
  59. data/lib/ronin/ui/command_line/commands/payloads.rb +73 -0
  60. data/spec/exploits/binary_exploit_spec.rb +44 -0
  61. data/spec/exploits/buffer_overflow_exploit_spec.rb +70 -0
  62. data/spec/exploits/exploit_spec.rb +122 -25
  63. data/spec/exploits/format_string_exploit_spec.rb +32 -0
  64. data/spec/exploits/ftp_spec.rb +17 -0
  65. data/spec/exploits/http_spec.rb +17 -0
  66. data/spec/exploits/padding_exploit_spec.rb +44 -0
  67. data/spec/exploits/remote_tcp_spec.rb +24 -0
  68. data/spec/exploits/remote_udp_spec.rb +24 -0
  69. data/spec/exploits/target_spec.rb +91 -0
  70. data/spec/exploits/targets/buffer_overflow_spec.rb +18 -0
  71. data/spec/exploits/{web_exploit_spec.rb → web_spec.rb} +5 -5
  72. data/spec/helpers/database.rb +5 -0
  73. data/spec/helpers/objects.rb +22 -0
  74. data/spec/objects/exploits/test.rb +28 -0
  75. data/spec/objects/payloads/example.rb +19 -0
  76. data/spec/objects/payloads/test.rb +11 -0
  77. data/spec/payloads/encoder_spec.rb +26 -0
  78. data/spec/payloads/encoders/xor_spec.rb +20 -0
  79. data/spec/payloads/payload_spec.rb +48 -13
  80. data/spec/spec_helper.rb +3 -5
  81. metadata +71 -22
  82. data/lib/ronin/exploits/binary_exploit.rb +0 -139
  83. data/lib/ronin/exploits/buffer_overflow.rb +0 -80
  84. data/lib/ronin/exploits/exploitable.rb +0 -77
  85. data/lib/ronin/exploits/format_string.rb +0 -88
  86. data/lib/ronin/models.rb +0 -38
  87. data/lib/ronin/translators/xor.rb +0 -96
  88. data/spec/exploits/exploitable_spec.rb +0 -21
  89. data/spec/translators/xor_spec.rb +0 -26
@@ -21,22 +21,16 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/exploits/exploit_target'
24
+ require 'ronin/exploits/remote_tcp'
25
25
 
26
26
  module Ronin
27
27
  module Exploits
28
- class FormatStringTarget < ExploitTarget
28
+ class FTP < RemoteTCP
29
29
 
30
- # Pop length
31
- property :pop_length, Integer, :default => 0
30
+ contextify :ronin_ftp_exploit
32
31
 
33
- # Address
34
- property :address, Integer, :default => 0x0
35
-
36
- # Overwrite
37
- property :overwrite, Integer, :default => 0x0
38
-
39
- belongs_to :format_string
32
+ # Default port to connect to
33
+ property :default_port, Integer, :default => 21
40
34
 
41
35
  end
42
36
  end
@@ -0,0 +1,27 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-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/exploits/helpers/binary'
25
+ require 'ronin/exploits/helpers/padding'
26
+ require 'ronin/exploits/helpers/buffer_overflow'
27
+ require 'ronin/exploits/helpers/format_string'
@@ -0,0 +1,44 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-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/exploits/exceptions/target_data_missing'
25
+ require 'ronin/formatting/binary'
26
+
27
+ module Ronin
28
+ module Exploits
29
+ module Helpers
30
+ module Binary
31
+ #
32
+ # Packs the specified _integer_ using the current targeted arch
33
+ # and the given _address_length_. The _address_length_ will
34
+ # default to the address length of the currently targeted arch.
35
+ #
36
+ def pack(integer,address_length=nil)
37
+ verify_arch!
38
+
39
+ return integer.pack(arch,(address_length || arch.address_length))
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,102 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-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/exploits/exceptions/payload_size'
25
+ require 'ronin/exploits/targets/buffer_overflow'
26
+ require 'ronin/exploits/helpers/binary'
27
+ require 'ronin/exploits/helpers/padding'
28
+
29
+ module Ronin
30
+ module Exploits
31
+ module Helpers
32
+ 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
+ def self.extended(obj)
47
+ obj.instance_eval do
48
+ extend Ronin::Exploits::Helpers::Binary
49
+ 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
+ end
58
+ end
59
+
60
+ #
61
+ # Adds a new Targets::BufferOverflow with the given _attributes_
62
+ # and _block_.
63
+ #
64
+ def targeting(attributes={},&block)
65
+ self.targets << Targets::BufferOverflow.new(attributes,&block)
66
+ end
67
+
68
+ protected
69
+
70
+ #
71
+ # Builds the buffer with the current target and payload to be
72
+ # used in the buffer overflow exploit.
73
+ #
74
+ def build_buffer
75
+ verify_target!
76
+
77
+ if encoded_payload.length > target.buffer_length
78
+ raise(PayloadSize,"the specified payload is too large for the target's buffer length",caller)
79
+ end
80
+
81
+ buffer = pad(target.buffer_length - encoded_payload.length) + encoded_payload
82
+ ip_packed = pack(target.ip)
83
+
84
+ if target.bp
85
+ buffer << ((pack(target.bp) + ip_packed) * target.frame_repeat)
86
+ else
87
+ buffer << ((ip_packed * 2) * target.frame_repeat)
88
+ end
89
+
90
+ return buffer
91
+ end
92
+
93
+ #
94
+ # Default builder method which simply calls build_buffer.
95
+ #
96
+ def build
97
+ @buffer = build_buffer
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,107 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-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/exploits/targets/format_string'
25
+ require 'ronin/exploits/helpers/binary'
26
+
27
+ module Ronin
28
+ module Exploits
29
+ module Helpers
30
+ 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
+ def self.extended(obj)
44
+ obj.instance_eval do
45
+ 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
+ end
54
+ end
55
+
56
+ #
57
+ # Adds a new Targets::FormatString with the given _attributes_
58
+ # and _block_.
59
+ #
60
+ def targeting(attributes={},&block)
61
+ self.targets << Targets::FormatString.new(attributes,&block)
62
+ end
63
+
64
+ protected
65
+
66
+ #
67
+ # Builds a format string using the current target and payload to
68
+ # be used in the format string exploit.
69
+ #
70
+ def build_format_string
71
+ verify_target!
72
+
73
+ buffer = pack(target.overwrite) +
74
+ pack(target.overwrite + (target.arch.address_length / 2))
75
+
76
+ low_mask = 0xff
77
+ (target.arch.address_length/2).times do
78
+ low_mask <<= 8
79
+ low_mask |= 0xff
80
+ end
81
+
82
+ high_mask = low_mask << (target.arch.address_length*4)
83
+ high = (target.address & high_mask) >> (target.arch.address_length/2)
84
+ low = target.address & low_mask
85
+
86
+ if low < high
87
+ low -= (target.arch.address_length*2)
88
+ buffer += format("%%.%ud%%%u$hn%%.%ud%%%u$hn",low,target.pop_length,high-low,target.pop_length+1)
89
+ else
90
+ high -= (target.arch.address_length*2)
91
+ buffer += format("%%.%ud%%%u$hn%%.%ud%%%u$hn",high,target.pop_length+1,low-high,target.pop_length)
92
+ end
93
+
94
+ buffer << encoded_payload
95
+ return buffer
96
+ end
97
+
98
+ #
99
+ # The default builder method, simply calls build_format_string.
100
+ #
101
+ def build
102
+ @format_string = build_format_string
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,84 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-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/formatting/text'
25
+
26
+ module Ronin
27
+ module Exploits
28
+ module Helpers
29
+ 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
+ def self.extended(obj)
40
+ obj.instance_eval do
41
+ # String to pad extra space with
42
+ parameter :padding,
43
+ :default => 'A',
44
+ :description => 'padding string'
45
+ end
46
+ end
47
+
48
+ protected
49
+
50
+ #
51
+ # Returns padding with the specified _max_length_.
52
+ #
53
+ # pad(28)
54
+ # # => "AAAAAAAAAAAAAAAAAAAAAAAAAAAA"
55
+ #
56
+ def pad(max_length)
57
+ ''.pad(@padding.to_s,max_length)
58
+ end
59
+
60
+ #
61
+ # Pads the specified _data_ to the left up to the specified
62
+ # _max_length_.
63
+ #
64
+ # pad_left("\xff\xff",48)
65
+ # # => "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\xff\xff"
66
+ #
67
+ def pad_left(data,max_length)
68
+ pad(max_length - data.length) + data
69
+ end
70
+
71
+ #
72
+ # Pads the specified _data_ to the right up to the specified
73
+ # _max_length_.
74
+ #
75
+ # pad_right("\xff\xff",48)
76
+ # # => "\xff\xffAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
77
+ #
78
+ def pad_right(data,max_length)
79
+ data.to_s.pad(@padding,max_length)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,37 @@
1
+ #
2
+ #--
3
+ # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
+ # payload crafting functionality.
5
+ #
6
+ # Copyright (c) 2007-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/exploits/remote_tcp'
25
+
26
+ module Ronin
27
+ module Exploits
28
+ class HTTP < RemoteTCP
29
+
30
+ contextify :ronin_http_exploit
31
+
32
+ # Default port to connect to
33
+ property :default_port, Integer, :default => 80
34
+
35
+ end
36
+ end
37
+ end
@@ -21,25 +21,13 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/vuln/behavior'
25
24
  require 'ronin/exploits/exploit'
26
25
 
27
- require 'ronin/model'
28
-
29
26
  module Ronin
30
27
  module Exploits
31
- class Requirement
32
-
33
- include Model
34
-
35
- # The behavior which is required
36
- belongs_to :behavior, :class_name => 'Vuln::Behavior'
37
-
38
- # The exploit which requires the behavior
39
- belongs_to :exploit
28
+ class Local < Exploit
40
29
 
41
- # Validates
42
- validates_present :behavior_id, :exploit_id
30
+ contextify :ronin_local_exploit
43
31
 
44
32
  end
45
33
  end