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
@@ -0,0 +1,59 @@
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/targeted_arch'
25
+
26
+ module Ronin
27
+ module Model
28
+ module TargetsArch
29
+ def self.included(base)
30
+ base.module_eval do
31
+ # The payloads targeted architecture
32
+ belongs_to :arch,
33
+ :child_key => [:arch_id],
34
+ :class_name => 'Ronin::TargetedArch'
35
+
36
+ #
37
+ # Returns the current targeted arch if no _name_ is given. If a
38
+ # _name_ is given, a new TargetedArch object will be created
39
+ # with the given _name_ and associated with the target.
40
+ #
41
+ # target.arch
42
+ # # => nil
43
+ #
44
+ # target.arch :i686
45
+ # # => #<Ronin::TargetedArch type=Ronin::TargetedArch id=nil
46
+ # # name="i686" endian="little" address_length=4>
47
+ #
48
+ def arch(name=nil)
49
+ if name
50
+ return self.arch = TargetedArch[name]
51
+ else
52
+ return arch_association
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,59 @@
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/targeted_os'
25
+
26
+ module Ronin
27
+ module Model
28
+ module TargetsOS
29
+ def self.included(base)
30
+ base.module_eval do
31
+ # The payloads targeted OS
32
+ belongs_to :os,
33
+ :child_key => [:os_id],
34
+ :class_name => 'Ronin::TargetedOS'
35
+
36
+ #
37
+ # Returns the current targeted OS if no _arguments_ are given. If
38
+ # _arguments_ are given, a new TargetedOS object will be created
39
+ # from the given _arguments_ and associated with the target.
40
+ #
41
+ # target.os
42
+ # # => nil
43
+ #
44
+ # target.os(:name => 'FreeBSD', :version => '7.1')
45
+ # # => #<Ronin::TargetedOS type=Ronin::TargetedOS id=nil
46
+ # # name="FreeBSD" version="7.1">
47
+ #
48
+ def os(*arguments)
49
+ unless arguments.empty?
50
+ return self.os = TargetedOS.first_or_create(*arguments)
51
+ else
52
+ return os_association
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -21,13 +21,17 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/payloads/ability'
25
- require 'ronin/payloads/payload_author'
24
+ require 'ronin/payloads/encoders'
26
25
  require 'ronin/payloads/payload'
27
26
  require 'ronin/payloads/binary_payload'
27
+ require 'ronin/payloads/nops'
28
+ require 'ronin/payloads/shellcode'
29
+ require 'ronin/database'
28
30
 
29
31
  require 'reverse_require'
30
32
 
33
+ require_for 'ronin-exploits', 'ronin/exploits'
34
+
31
35
  module Ronin
32
- require_for 'ronin', 'ronin/payloads'
36
+ Database.update!
33
37
  end
@@ -22,18 +22,14 @@
22
22
  #
23
23
 
24
24
  require 'ronin/payloads/payload'
25
+ require 'ronin/arch'
26
+ require 'ronin/os'
25
27
 
26
28
  module Ronin
27
29
  module Payloads
28
30
  class BinaryPayload < Payload
29
31
 
30
- objectify :ronin_binary_payload
31
-
32
- # The payloads targeted architecture
33
- belongs_to :arch
34
-
35
- # The payloads targeted platform
36
- belongs_to :platform
32
+ contextify :ronin_binary_payload
37
33
 
38
34
  end
39
35
  end
@@ -28,12 +28,17 @@ require 'ronin/model'
28
28
 
29
29
  module Ronin
30
30
  module Payloads
31
- class Ability
31
+ class Control
32
32
 
33
33
  include Model
34
34
 
35
+ # The primary key of the control
36
+ property :id, Serial
37
+
35
38
  # The behavior the ability provides
36
- belongs_to :behavior, :class_name => 'Vuln::Behavior'
39
+ belongs_to :behavior,
40
+ :child_key => [:behavior_id],
41
+ :class_name => 'Vuln::Behavior'
37
42
 
38
43
  # The payload which has this ability
39
44
  belongs_to :payload
@@ -0,0 +1,78 @@
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/model/targets_arch'
25
+ require 'ronin/model/targets_os'
26
+ require 'ronin/cacheable'
27
+
28
+ require 'parameters'
29
+
30
+ module Ronin
31
+ module Payloads
32
+ class Encoder
33
+
34
+ include Parameters
35
+ include Cacheable
36
+ include Model::TargetsArch
37
+ include Model::TargetsOS
38
+
39
+ contextify :ronin_payload_encoder
40
+
41
+ # Primary key of the payload
42
+ property :id, Serial
43
+
44
+ # Name of the specific payload
45
+ property :name, String, :index => true
46
+
47
+ # Description of the payload
48
+ property :description, Text
49
+
50
+ # Validations
51
+ validates_present :name
52
+
53
+ #
54
+ # Finds all payloads with names like the specified _name_.
55
+ #
56
+ def self.named(name)
57
+ self.all(:name.like => "%#{name}%")
58
+ end
59
+
60
+ #
61
+ # Finds all payloads with descriptions like the specified
62
+ # _description_.
63
+ #
64
+ def self.describing(description)
65
+ self.all(:description.like => "%#{description}%")
66
+ end
67
+
68
+ #
69
+ # Default method which will encode the specified _data_.
70
+ # Returns the specified _data_ by default.
71
+ #
72
+ def call(data)
73
+ data
74
+ end
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,33 @@
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/payloads/encoders/xor'
25
+ require 'ronin/database'
26
+
27
+ require 'reverse_require'
28
+
29
+ require_for 'ronin-exploits', 'ronin/payloads/encoders'
30
+
31
+ module Ronin
32
+ Database.update!
33
+ end
@@ -0,0 +1,81 @@
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/payloads/encoder'
25
+
26
+ require 'chars'
27
+
28
+ module Ronin
29
+ module Payloads
30
+ module Encoders
31
+ class XOR < Encoder
32
+
33
+ # Set of characters to allow in the encoded data
34
+ attr_accessor :allow
35
+
36
+ #
37
+ # Creates a new XOR Encoder object using the given _options_.
38
+ # If a _block_ is given it will be passed the newly created
39
+ # Encoder object.
40
+ #
41
+ # _options_ may include the following keys:
42
+ # <tt>:allow</tt>:: The set of characters allowed in the encoded
43
+ # result. Defaults to <tt>(1..255)</tt>.
44
+ # <tt>:disallow</tt>:: The set of characters that are not allowed
45
+ # in the encoded result.
46
+ #
47
+ def initialize(options={},&block)
48
+ @allow = Chars::CharSet.new(options[:allow] || (1..255))
49
+
50
+ if options[:disallow]
51
+ @allow -= options[:disallow]
52
+ end
53
+
54
+ super(&block)
55
+ end
56
+
57
+ #
58
+ # XOR encodes the specified _data_ prefixing the XOR key to the
59
+ # encoded data.
60
+ #
61
+ def call(data)
62
+ alphabet = Chars.all.select { |b| data.include?(b.chr) }
63
+ excluded = (Chars.all - alphabet)
64
+
65
+ key = excluded.select { |b|
66
+ @allow.include?(b) && alphabet.all? { |i|
67
+ @allow.include?(i ^ b)
68
+ }
69
+ }.last
70
+
71
+ text = ''
72
+
73
+ text << key.chr
74
+ data.each_byte { |b| text << (b ^ key).chr }
75
+ return text
76
+ end
77
+
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,24 @@
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/payloads/exceptions/unknown_helper'
@@ -0,0 +1,29 @@
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
+ module Ronin
25
+ module Payloads
26
+ class UnknownHelper < RuntimeError
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
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/payloads/helpers/file_system'
25
+ require 'ronin/payloads/helpers/shell'
26
+ require 'ronin/payloads/helpers/rpc'