ronin-exploits 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 (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
@@ -1,77 +0,0 @@
1
- #
2
- #--
3
- # Ronin Exploits - A Ruby library for Ronin that provides exploitation and
4
- # payload crafting functionality.
5
- #
6
- # Copyright (c) 2006-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/extensions/meta'
25
-
26
- module Ronin
27
- module Exploits
28
- module Exploitable
29
- def self.included(base)
30
- base.metaclass_eval do
31
- #
32
- # Returns the Hash of the exploit names and the +Proc+
33
- # objects used to generate various Exploit objects.
34
- #
35
- def exploit_generators
36
- @ronin_exploit_generators ||= {}
37
- end
38
-
39
- def each_exploit_generator(&block)
40
- self.class.ancestors.each do |super_class|
41
- if super_class.include?(Ronin::Exploits::Exploitable)
42
- super_class.exploit_generators.each(&block)
43
- end
44
- end
45
- end
46
-
47
- #
48
- # Registers a new exploit generator with the specified _name_
49
- # and the specified _block_ which will return an Array of
50
- # exploits.
51
- #
52
- # has_exploits :lfi do |url|
53
- # ...
54
- # end
55
- #
56
- def has_exploits(name,&block)
57
- self.exploit_generators[name.to_sym] = block
58
-
59
- return self
60
- end
61
- end
62
- end
63
-
64
- def exploits
65
- viable_exploits = []
66
-
67
- self.class.each_exploit_generator do |name,block|
68
- viable_exploits += block.call(self).select do |exp|
69
- exp.vulnerable?
70
- end
71
- end
72
-
73
- return viable_exploits
74
- end
75
- end
76
- end
77
- end
@@ -1,88 +0,0 @@
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/format_string_target'
25
- require 'ronin/exploits/binary_exploit'
26
-
27
- module Ronin
28
- module Exploits
29
- class FormatString < BinaryExploit
30
-
31
- objectify :ronin_format_string
32
-
33
- # Targets of the format string
34
- has n, :targets, :class_name => 'FormatStringTarget'
35
-
36
- #
37
- # Adds a new FormatStringTarget with the given _attributes_. If a
38
- # _block_ is given, it will be passed the new FormatStringTarget
39
- # object.
40
- #
41
- def target(attributes={},&block)
42
- self.targets << FormatStringTarget.new(
43
- attributes.merge(:exploit => self),
44
- &block
45
- )
46
- end
47
-
48
- #
49
- # Builds the format string with the given _options_.
50
- #
51
- def build_format_string(options={})
52
- target = (options[:target] || selected_target)
53
- payload = (options[:payload] || @payload).to_s
54
-
55
- buffer = target.overwrite.pack(target.platform.arch)+(target.overwrite+(target.platform.arch.address_length/2)).pack(target.platform.arch)
56
-
57
- low_mask = 0xff
58
- (target.platform.arch.address_length/2).times do
59
- low_mask <<= 8
60
- low_mask |= 0xff
61
- end
62
-
63
- high_mask = low_mask << (target.platform.arch.address_length*4)
64
- high = (target.address & high_mask) >> (target.platform.arch.address_length/2)
65
- low = target.address & low_mask
66
-
67
- if low<high
68
- low -= (target.platform.arch.address_length*2)
69
- buffer += format("%%.%ud%%%lu$hn%%.%ud%%%lu$hn",low,target.pop_length,high-low,target.pop_length+1)
70
- else
71
- high -= (target.platform.arch.address_length*2)
72
- buffer += format("%%.%ud%%%lu$hn%%.%ud%%%lu$hn",high,target.pop_length+1,low-high,target.pop_length)
73
- end
74
- buffer += payload
75
-
76
- return buffer
77
- end
78
-
79
- #
80
- # The default builder method, simply calls build_format_string.
81
- #
82
- def builder
83
- @exploit = build_format_string
84
- end
85
-
86
- end
87
- end
88
- end
@@ -1,38 +0,0 @@
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/vuln/behavior'
25
- require 'ronin/exploits/requirement'
26
- require 'ronin/exploits/impact'
27
- require 'ronin/exploits/exploit_author'
28
- require 'ronin/exploits/exploit_target'
29
- require 'ronin/exploits/exploit'
30
- require 'ronin/exploits/binary_exploit'
31
- require 'ronin/exploits/buffer_overflow_target'
32
- require 'ronin/exploits/buffer_overflow'
33
- require 'ronin/exploits/format_string_target'
34
- require 'ronin/exploits/format_string'
35
- require 'ronin/payloads/ability'
36
- require 'ronin/payloads/payload_author'
37
- require 'ronin/payloads/payload'
38
- require 'ronin/payloads/binary_payload'
@@ -1,96 +0,0 @@
1
- #
2
- #--
3
- # Ronin - A Ruby platform designed for information security and data
4
- # exploration tasks.
5
- #
6
- # Copyright (c) 2006-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/translators/translator'
25
- require 'ronin/chars'
26
-
27
- module Ronin
28
- module Translators
29
- class XOR < Translator
30
-
31
- # Set of characters to allow in the encoded data
32
- attr_accessor :allow
33
-
34
- #
35
- # Creates a new XOR Translator object using the given _options_.
36
- # If a _block_ is given it will be passed the newly created
37
- # Translator object.
38
- #
39
- # _options_ may include the following keys:
40
- # <tt>:allow</tt>:: The set of characters allowed in the encoded
41
- # result. Defaults to <tt>(1..255)</tt>.
42
- # <tt>:disallow</tt>:: The set of characters that are not allowed
43
- # in the encoded result.
44
- #
45
- def initialize(options={},&block)
46
- @allow = Chars::CharSet.new(options[:allow] || (1..255))
47
-
48
- if options[:disallow]
49
- @allow -= options[:disallow]
50
- end
51
-
52
- super(&block)
53
- end
54
-
55
- #
56
- # XOR encodes the specified _data_ prefixing the XOR key to the
57
- # encoded data. If a _block_ is given, it will be passed the encoded
58
- # data.
59
- #
60
- def encode(data,&block)
61
- alphabet = Chars.all.select { |b| data.include?(b.chr) }
62
- excluded = (Chars.all - alphabet)
63
-
64
- key = excluded.select { |b|
65
- @allow.include?(b) && alphabet.all? { |i|
66
- @allow.include?(i ^ b)
67
- }
68
- }.last
69
-
70
- text = ''
71
-
72
- text << key.chr
73
- data.each_byte { |b| text << (b ^ key).chr }
74
-
75
- block.call(text) if block
76
- return text
77
- end
78
-
79
- #
80
- # XOR decodes the specified _text_. If a _block_ is given, it will be
81
- # passed the decoded data.
82
- #
83
- def decode(text,&block)
84
- data = ''
85
- key = text[0]
86
-
87
- text[1..-1].each_byte do |b|
88
- data << (b ^ key).chr
89
- end
90
-
91
- return data
92
- end
93
-
94
- end
95
- end
96
- end
@@ -1,21 +0,0 @@
1
- require 'ronin/exploits/exploitable'
2
-
3
- require 'spec_helper'
4
-
5
- describe Exploits::Exploitable do
6
- before(:all) do
7
- class Vulnerable
8
-
9
- include Exploits::Exploitable
10
-
11
- has_exploits :test do |obj|
12
- [Exploits::Exploit.new(:name => :first_generated)]
13
- end
14
-
15
- has_exploits :test_two do |obj|
16
- [Exploits::BinaryExploit.new(:name => :second_generated)]
17
- end
18
-
19
- end
20
- end
21
- end
@@ -1,26 +0,0 @@
1
- require 'ronin/translators/xor'
2
-
3
- require 'spec_helper'
4
-
5
- describe Ronin do
6
- describe Translators::XOR do
7
- before(:all) do
8
- @data = "\x00\x01\x90ABC123[]{}'"
9
- end
10
-
11
- it "should encode-out unwanted characters" do
12
- disallow = [0x00, 0x01, 0x90]
13
- xor = Translators::XOR.new(:disallow => disallow)
14
-
15
- xor.encode(@data).each_byte do |b|
16
- disallow.include?(b).should_not == true
17
- end
18
- end
19
-
20
- it "should decode XOR encoded data" do
21
- xor = Translators::XOR.new
22
-
23
- xor.decode(xor.encode(@data)).should == @data
24
- end
25
- end
26
- end