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
@@ -0,0 +1,34 @@
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/exploit'
25
+
26
+ module Ronin
27
+ module Exploits
28
+ class Remote < Exploit
29
+
30
+ contextify :ronin_remote_exploit
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,70 @@
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'
25
+ require 'ronin/sessions/tcp'
26
+
27
+ module Ronin
28
+ module Exploits
29
+ class RemoteTCP < Remote
30
+
31
+ include Sessions::TCP
32
+
33
+ contextify :ronin_remote_tcp_exploit
34
+
35
+ # Default port to connect to
36
+ property :default_port, Integer
37
+
38
+ # remote host to connect to
39
+ parameter :host, :description => 'TCP remote host'
40
+
41
+ # remote port to connect to
42
+ parameter :port, :description => 'TCP remote port'
43
+
44
+ # local host to bind to
45
+ parameter :local_host, :description => 'TCP local host'
46
+
47
+ # local port to bind to
48
+ parameter :local_port, :description => 'TCP local port'
49
+
50
+ #
51
+ # Verifies the TCP remote exploit is ready to be deployed.
52
+ #
53
+ def verify!
54
+ require_params :host, :port
55
+
56
+ return super
57
+ end
58
+
59
+ #
60
+ # Verifies and deploys the TCP remote exploit.
61
+ #
62
+ def deploy!(&block)
63
+ @port ||= self.default_port
64
+
65
+ super(&block)
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,70 @@
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'
25
+ require 'ronin/sessions/udp'
26
+
27
+ module Ronin
28
+ module Exploits
29
+ class RemoteUDP < Remote
30
+
31
+ include Sessions::UDP
32
+
33
+ contextify :ronin_remote_udp_exploit
34
+
35
+ # Default port to connect to
36
+ property :default_port, Integer
37
+
38
+ # remote host to connect to
39
+ parameter :host, :description => 'UDP remote host'
40
+
41
+ # remote port to connect to
42
+ parameter :port, :description => 'UDP remote port'
43
+
44
+ # local host to bind to
45
+ parameter :local_host, :description => 'UDP local host'
46
+
47
+ # local port to bind to
48
+ parameter :local_port, :description => 'UDP local port'
49
+
50
+ #
51
+ # Verifies the UDP remote exploit is ready to be deployed.
52
+ #
53
+ def verify!
54
+ require_params :host, :port
55
+
56
+ return super
57
+ end
58
+
59
+ #
60
+ # Verifies and deploys the UDP remote exploit.
61
+ #
62
+ def deploy!(&block)
63
+ @port ||= self.default_port
64
+
65
+ super(&block)
66
+ end
67
+
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,134 @@
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/model/targets_arch'
26
+ require 'ronin/model/targets_os'
27
+ require 'ronin/model'
28
+ require 'ronin/targeted_product'
29
+
30
+ require 'dm-types/yaml'
31
+
32
+ module Ronin
33
+ module Exploits
34
+ class Target
35
+
36
+ include Model
37
+ include Model::TargetsArch
38
+ include Model::TargetsOS
39
+
40
+ # Primary key
41
+ property :id, Serial
42
+
43
+ # Target comments
44
+ property :description, String
45
+
46
+ # Targeted product
47
+ belongs_to :product,
48
+ :child_key => [:product_id],
49
+ :class_name => 'Ronin::TargetedProduct'
50
+
51
+ # The exploit the target belongs to
52
+ belongs_to :exploit
53
+
54
+ # The extra target data to use for the exploit
55
+ property :data, Yaml, :default => {}
56
+
57
+ #
58
+ # Creates a new ExploitTarget object with the given _attributes_
59
+ # and the given _block_.
60
+ #
61
+ def initialize(attributes={},&block)
62
+ super(attributes)
63
+
64
+ block.call(self) if block
65
+ end
66
+
67
+ #
68
+ # Returns the TargetedProduct if no _arguments_ are given. If
69
+ # _arguments_ are given, a new TargetedProduct object will be created
70
+ # from the given _arguments_ and associated with the target.
71
+ #
72
+ # target.product
73
+ # # => nil
74
+ #
75
+ # target.product(:name => 'Apache', :version => '1.3.3.7')
76
+ # # => #<Ronin::TargetedProduct type=Ronin::TargetedProduct
77
+ # # id=nil name="Apache" version="1.3.3.7" vendor="Apache">
78
+ #
79
+ def product(*arguments)
80
+ unless arguments.empty?
81
+ return self.product = TargetedProduct.first_or_create(*arguments)
82
+ else
83
+ return product_association
84
+ end
85
+ end
86
+
87
+ #
88
+ # Returns +true+ if the target contains data with the specified
89
+ # _name_, returns +false+ otherwise.
90
+ #
91
+ def has?(name)
92
+ self.data.has_key?(name.to_sym)
93
+ end
94
+
95
+ #
96
+ # Returns the target data with the specified _name_.
97
+ #
98
+ def [](name)
99
+ self.data[name.to_sym]
100
+ end
101
+
102
+ #
103
+ # Sets the target data with the specified _name_ and _value_.
104
+ #
105
+ def []=(name,value)
106
+ self.data[name.to_sym] = value
107
+ end
108
+
109
+ protected
110
+
111
+ #
112
+ # Provides transparent access to the target data Hash.
113
+ #
114
+ def method_missing(name,*arguments,&block)
115
+ unless block
116
+ name = name.to_s
117
+
118
+ if (name[-1..-1] == '=' && arguments.length == 1)
119
+ return self[name.chop] = arguments.first
120
+ elsif arguments.length == 0
121
+ unless has?(name)
122
+ raise(TargetDataMissing,"the target is missing data for #{name.dump}",caller)
123
+ end
124
+
125
+ return self[name]
126
+ end
127
+ end
128
+
129
+ super(name,*arguments,&block)
130
+ end
131
+
132
+ end
133
+ end
134
+ end
@@ -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
+ require 'ronin/exploits/targets/buffer_overflow'
25
+ require 'ronin/exploits/targets/format_string'
26
+
27
+ require 'reverse_require'
28
+
29
+ require_for 'ronin-exploits', 'ronin/exploits/targets'
@@ -21,26 +21,28 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/exploits/exploit_target'
24
+ require 'ronin/exploits/target'
25
25
 
26
26
  module Ronin
27
27
  module Exploits
28
- class BufferOverflowTarget < ExploitTarget
28
+ module Targets
29
+ class BufferOverflow < Target
29
30
 
30
- # Buffer length
31
- property :buffer_length, Integer, :default => 0
31
+ # Buffer Length
32
+ property :buffer_length, Integer, :default => 0
32
33
 
33
- # Return length
34
- property :return_length, Integer, :default => 1
34
+ # Stack Base Pointer
35
+ property :bp, Integer
35
36
 
36
- # Instruction Pointer
37
- property :ip, Integer, :default => 0x0
37
+ # Instruction Pointer
38
+ property :ip, Integer
38
39
 
39
- # Stack base pointer
40
- property :bp, Integer
40
+ # Repeat stack frames n times
41
+ property :frame_repeat, Integer, :default => 1
41
42
 
42
- belongs_to :buffer_overflow
43
+ validates_present :ip
43
44
 
45
+ end
44
46
  end
45
47
  end
46
48
  end
@@ -21,28 +21,25 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/target'
25
- require 'ronin/product'
24
+ require 'ronin/exploits/target'
26
25
 
27
26
  module Ronin
28
27
  module Exploits
29
- class ExploitTarget < Target
28
+ module Targets
29
+ class FormatString < Target
30
30
 
31
- # Target comments
32
- property :description, String
31
+ # Overwrite
32
+ property :overwrite, Integer
33
33
 
34
- # Targeted architecture
35
- belongs_to :arch
34
+ # Address
35
+ property :address, Integer
36
36
 
37
- # Targeted platform
38
- belongs_to :platform
37
+ # Length in bytes to pop
38
+ property :pop_length, Integer
39
39
 
40
- # Targeted product
41
- belongs_to :product
42
-
43
- # The exploit the target belongs to
44
- belongs_to :exploit, :class_name => 'BinaryExploit'
40
+ validates_present :arch_id, :overwrite, :address, :pop_length
45
41
 
42
+ end
46
43
  end
47
44
  end
48
45
  end
@@ -24,6 +24,6 @@
24
24
  module Ronin
25
25
  module Exploits
26
26
  # Ronin Exploits version
27
- VERSION = '0.1.1'
27
+ VERSION = '0.2.0'
28
28
  end
29
29
  end
@@ -21,7 +21,7 @@
21
21
  #++
22
22
  #
23
23
 
24
- require 'ronin/exploits/exploit'
24
+ require 'ronin/exploits/remote'
25
25
  require 'ronin/sessions/http'
26
26
  require 'ronin/extensions/uri/http'
27
27
 
@@ -29,11 +29,11 @@ require 'uri'
29
29
 
30
30
  module Ronin
31
31
  module Exploits
32
- class WebExploit < Exploit
32
+ class Web < Remote
33
33
 
34
34
  include Sessions::HTTP
35
35
 
36
- objectify :ronin_web_exploit
36
+ contextify :ronin_web_exploit
37
37
 
38
38
  # The targeted URL path
39
39
  property :url_path, String