ronin-exploits 0.2.0 → 0.2.1
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.
- data.tar.gz.sig +0 -0
- data/History.txt +27 -0
- data/Manifest.txt +21 -5
- data/README.txt +40 -3
- data/Rakefile +6 -6
- data/TODO.txt +12 -9
- data/lib/ronin/exploits/allow.rb +1 -1
- data/lib/ronin/{targeted_arch.rb → exploits/arch.rb} +1 -5
- data/lib/ronin/exploits/exploit.rb +59 -144
- data/lib/ronin/exploits/ftp.rb +4 -1
- data/lib/ronin/exploits/helpers.rb +1 -0
- data/lib/ronin/exploits/helpers/file_based.rb +113 -0
- data/lib/ronin/exploits/http.rb +10 -0
- data/lib/ronin/exploits/license.rb +34 -0
- data/lib/ronin/exploits/os.rb +34 -0
- data/lib/ronin/{targeted_product.rb → exploits/product.rb} +1 -1
- data/lib/ronin/exploits/remote_tcp.rb +2 -3
- data/lib/ronin/exploits/remote_udp.rb +2 -3
- data/lib/ronin/exploits/target.rb +8 -10
- data/lib/ronin/exploits/verifiers.rb +92 -0
- data/lib/ronin/exploits/version.rb +1 -1
- data/lib/ronin/exploits/web.rb +21 -1
- data/lib/ronin/model/has_default_port.rb +54 -0
- data/lib/ronin/model/targets_arch.rb +8 -10
- data/lib/ronin/model/targets_os.rb +9 -9
- data/lib/ronin/payloads.rb +1 -0
- data/lib/ronin/payloads/arch.rb +32 -0
- data/lib/ronin/payloads/asm_payload.rb +34 -0
- data/lib/ronin/payloads/encoder.rb +24 -18
- data/lib/ronin/payloads/helpers/exceptions.rb +2 -1
- data/lib/ronin/payloads/helpers/exceptions/{unimplemented.rb → not_implemented.rb} +1 -1
- data/lib/ronin/payloads/helpers/file_system.rb +12 -12
- data/lib/ronin/payloads/helpers/rpc.rb +7 -7
- data/lib/ronin/payloads/helpers/shell.rb +2 -2
- data/lib/ronin/payloads/license.rb +34 -0
- data/lib/ronin/payloads/nops.rb +3 -1
- data/lib/ronin/{targeted_os.rb → payloads/os.rb} +1 -5
- data/lib/ronin/payloads/payload.rb +89 -41
- data/lib/ronin/payloads/shellcode.rb +4 -1
- data/lib/ronin/ui/command_line/commands/exploits.rb +1 -1
- data/lib/ronin/ui/command_line/commands/payload.rb +2 -2
- data/lib/ronin/ui/command_line/commands/payloads.rb +1 -1
- data/spec/exploits/exploit_spec.rb +12 -30
- data/spec/exploits/file_based_exploit_spec.rb +39 -0
- data/spec/exploits/ftp_spec.rb +1 -5
- data/spec/exploits/http_spec.rb +4 -4
- data/spec/exploits/remote_tcp_spec.rb +7 -3
- data/spec/exploits/remote_udp_spec.rb +7 -3
- data/spec/exploits/target_spec.rb +9 -2
- data/spec/exploits/targets/buffer_overflow_spec.rb +6 -2
- data/spec/exploits/web_spec.rb +6 -0
- data/spec/model/has_default_port_spec.rb +27 -0
- data/spec/model/models/default_port_model.rb +13 -0
- data/spec/model/models/non_default_port_model.rb +11 -0
- data/spec/model/models/targets_arch_model.rb +11 -0
- data/spec/model/models/targets_os_model.rb +11 -0
- data/spec/model/targets_arch_spec.rb +22 -0
- data/spec/model/targets_os_spec.rb +23 -0
- data/spec/objects/exploits/example.rb +25 -0
- data/spec/objects/exploits/test.rb +0 -4
- data/spec/objects/payloads/test.rb +5 -1
- data/spec/payloads/encoder_spec.rb +5 -1
- data/spec/payloads/payload_spec.rb +77 -14
- metadata +58 -13
- metadata.gz.sig +0 -0
- data/spec/objects/payloads/example.rb +0 -19
data/spec/exploits/ftp_spec.rb
CHANGED
@@ -4,11 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Exploits::FTP do
|
6
6
|
before(:all) do
|
7
|
-
@exploit = Exploits::FTP.
|
8
|
-
self.name = 'example_ftp'
|
9
|
-
end
|
10
|
-
|
11
|
-
@exploit.save!
|
7
|
+
@exploit = Exploits::FTP.create(:name => 'example_ftp')
|
12
8
|
end
|
13
9
|
|
14
10
|
it "should have a default port of 21" do
|
data/spec/exploits/http_spec.rb
CHANGED
@@ -4,11 +4,11 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Exploits::HTTP do
|
6
6
|
before(:all) do
|
7
|
-
@exploit = Exploits::HTTP.
|
8
|
-
|
9
|
-
end
|
7
|
+
@exploit = Exploits::HTTP.create(:name => 'example_httpd')
|
8
|
+
end
|
10
9
|
|
11
|
-
|
10
|
+
it "should initialize all parameters by default" do
|
11
|
+
@exploit.params.should_not be_empty
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should have a default port of 80" do
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Exploits::RemoteTCP do
|
6
6
|
before(:all) do
|
7
|
-
@
|
7
|
+
@exploit = Exploits::RemoteTCP.new(
|
8
8
|
:default_port => 22,
|
9
9
|
:host => '127.0.0.1'
|
10
10
|
)
|
@@ -14,10 +14,14 @@ describe Exploits::RemoteTCP do
|
|
14
14
|
Exploits::RemoteTCP.include?(Sessions::TCP).should == true
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should initialize all parameters by default" do
|
18
|
+
@exploit.params.should_not be_empty
|
19
|
+
end
|
20
|
+
|
17
21
|
it "should default the port to the default_port before deploying" do
|
18
|
-
@
|
22
|
+
@exploit.build!
|
19
23
|
|
20
|
-
@
|
24
|
+
@exploit.deploy! do |exp|
|
21
25
|
exp.port.should == 22
|
22
26
|
end
|
23
27
|
end
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Exploits::RemoteUDP do
|
6
6
|
before(:all) do
|
7
|
-
@
|
7
|
+
@exploit = Exploits::RemoteUDP.new(
|
8
8
|
:default_port => 22,
|
9
9
|
:host => '127.0.0.1'
|
10
10
|
)
|
@@ -14,10 +14,14 @@ describe Exploits::RemoteUDP do
|
|
14
14
|
Exploits::RemoteUDP.include?(Sessions::UDP).should == true
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should initialize all parameters by default" do
|
18
|
+
@exploit.params.should_not be_empty
|
19
|
+
end
|
20
|
+
|
17
21
|
it "should default the port to the default_port before deploying" do
|
18
|
-
@
|
22
|
+
@exploit.build!
|
19
23
|
|
20
|
-
@
|
24
|
+
@exploit.deploy! do |exp|
|
21
25
|
exp.port.should == 22
|
22
26
|
end
|
23
27
|
end
|
@@ -3,9 +3,14 @@ require 'ronin/exploits/target'
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Exploits::Target do
|
6
|
+
before(:all) do
|
7
|
+
@exploit = Exploits::Exploit.create(:name => 'exploit with targets')
|
8
|
+
end
|
9
|
+
|
6
10
|
before(:each) do
|
7
11
|
@target = Exploits::Target.new(
|
8
|
-
:data => {:var => 1, :test => 'hello'}
|
12
|
+
:data => {:var => 1, :test => 'hello'},
|
13
|
+
:exploit => @exploit
|
9
14
|
)
|
10
15
|
end
|
11
16
|
|
@@ -68,9 +73,11 @@ describe Exploits::Target do
|
|
68
73
|
end
|
69
74
|
|
70
75
|
it "should be able to serialize and deserialize it's target data" do
|
71
|
-
@target.save
|
76
|
+
@target.save
|
72
77
|
|
73
78
|
target = Exploits::Target.get(@target.id)
|
79
|
+
target.should_not be_nil
|
80
|
+
|
74
81
|
target.data[:var].should == 1
|
75
82
|
target.data[:test].should == 'hello'
|
76
83
|
end
|
@@ -3,8 +3,12 @@ require 'ronin/exploits/targets/buffer_overflow'
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Exploits::Targets::BufferOverflow do
|
6
|
+
before(:all) do
|
7
|
+
@exploit = Exploits::Exploit.create(:name => 'buffer overflow exploit')
|
8
|
+
end
|
9
|
+
|
6
10
|
it "should require an ip to overwrite with" do
|
7
|
-
target = Exploits::Targets::BufferOverflow.new
|
11
|
+
target = Exploits::Targets::BufferOverflow.new(:exploit => @exploit)
|
8
12
|
target.should_not be_valid
|
9
13
|
|
10
14
|
target.ip = 0xffffeeee
|
@@ -12,7 +16,7 @@ describe Exploits::Targets::BufferOverflow do
|
|
12
16
|
end
|
13
17
|
|
14
18
|
it "should have a default frame_repeat of 1" do
|
15
|
-
target = Exploits::Targets::BufferOverflow.new
|
19
|
+
target = Exploits::Targets::BufferOverflow.new(:exploit => @exploit)
|
16
20
|
target.frame_repeat.should == 1
|
17
21
|
end
|
18
22
|
end
|
data/spec/exploits/web_spec.rb
CHANGED
@@ -4,6 +4,12 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Exploits::Web do
|
6
6
|
describe "targeted_url" do
|
7
|
+
it "should initialize all parameters by default" do
|
8
|
+
exploit = Exploits::Web.new
|
9
|
+
|
10
|
+
exploit.params.should_not be_empty
|
11
|
+
end
|
12
|
+
|
7
13
|
it "should create a targeted URL using the host param" do
|
8
14
|
host = 'www.example.com'
|
9
15
|
exploit = Exploits::Web.new(:host => host)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'ronin/model/has_default_port'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'model/models/default_port_model'
|
5
|
+
require 'model/models/non_default_port_model'
|
6
|
+
|
7
|
+
describe Model::HasDefaultPort do
|
8
|
+
it "should define a default_port property" do
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should initialize the default_port property if DEFAULT_PORT is defined" do
|
12
|
+
model = DefaultPortModel.new
|
13
|
+
|
14
|
+
model.default_port.should == DefaultPortModel::DEFAULT_PORT
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not initialize the default_port property if DEFAULT_PORT is undefined" do
|
18
|
+
model = NonDefaultPortModel.new
|
19
|
+
model.default_port.should be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should allow default_port to be overridden" do
|
23
|
+
model = DefaultPortModel.new(:default_port => 70)
|
24
|
+
|
25
|
+
model.default_port.should == 70
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ronin/model/targets_arch'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'model/models/targets_arch_model'
|
5
|
+
|
6
|
+
describe Model::TargetsArch do
|
7
|
+
it "should define an arch relation" do
|
8
|
+
TargetsArchModel.relationships.has_key?('arch')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should provide access to the targeted arch" do
|
12
|
+
model = TargetsArchModel.new(:arch => Arch.i386)
|
13
|
+
model.arch.name.should == 'i386'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should allow the arch to be set via the getter method" do
|
17
|
+
model = TargetsArchModel.new
|
18
|
+
model.arch :i386
|
19
|
+
|
20
|
+
model.arch.name.should == 'i386'
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'ronin/model/targets_os'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'model/models/targets_os_model'
|
5
|
+
|
6
|
+
describe Model::TargetsOS do
|
7
|
+
it "should define an os relation" do
|
8
|
+
TargetsOSModel.relationships.has_key?('os')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should provide access to the targeted os" do
|
12
|
+
model = TargetsOSModel.new(:os => OS.linux('2.6.29'))
|
13
|
+
model.os.should == OS.linux('2.6.29')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should allow the os to be set via the getter method" do
|
17
|
+
model = TargetsOSModel.new
|
18
|
+
model.os :name => 'Linux', :version => '2.6.29'
|
19
|
+
|
20
|
+
model.os.name.should == 'Linux'
|
21
|
+
model.os.version.should == '2.6.29'
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
ronin_exploit do
|
2
|
+
parameter :path,
|
3
|
+
:default => 'data',
|
4
|
+
:description => 'Parameter to be shared with the exploit'
|
5
|
+
|
6
|
+
cache do
|
7
|
+
self.name = 'example'
|
8
|
+
|
9
|
+
author :name => 'Anonymous', :email => 'anonymous@example.com'
|
10
|
+
|
11
|
+
targeting do |target|
|
12
|
+
target.arch :i686
|
13
|
+
target.os :name => 'Linux', :version => '2.6.23'
|
14
|
+
target.product :name => 'ExampleWare', :version => '1.5'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def buffer
|
19
|
+
@buffer
|
20
|
+
end
|
21
|
+
|
22
|
+
def build
|
23
|
+
@buffer = "GET /#{@path}/#{@encoded_payload}"
|
24
|
+
end
|
25
|
+
end
|
@@ -1,4 +1,8 @@
|
|
1
1
|
ronin_payload do
|
2
|
+
parameter :custom,
|
3
|
+
:default => 'func',
|
4
|
+
:description => 'Custom value to use in building the payload'
|
5
|
+
|
2
6
|
cache do
|
3
7
|
self.name = 'test'
|
4
8
|
|
@@ -6,6 +10,6 @@ ronin_payload do
|
|
6
10
|
end
|
7
11
|
|
8
12
|
def build
|
9
|
-
@payload =
|
13
|
+
@payload = "code.#{@custom}"
|
10
14
|
end
|
11
15
|
end
|
@@ -4,7 +4,7 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Payloads::Encoder do
|
6
6
|
before(:all) do
|
7
|
-
@encoder = Payloads::Encoder.new
|
7
|
+
@encoder = Payloads::Encoder.new(:name => 'test')
|
8
8
|
@data = 'some data'
|
9
9
|
end
|
10
10
|
|
@@ -23,4 +23,8 @@ describe Payloads::Encoder do
|
|
23
23
|
it "should return the data to be encoded by default" do
|
24
24
|
@encoder.call(@data).should == @data
|
25
25
|
end
|
26
|
+
|
27
|
+
it "should have a custom inspect method" do
|
28
|
+
@encoder.inspect.should == '#<Ronin::Payloads::Encoder: test>'
|
29
|
+
end
|
26
30
|
end
|
@@ -6,6 +6,7 @@ require 'helpers/objects'
|
|
6
6
|
describe Payloads::Payload do
|
7
7
|
before(:each) do
|
8
8
|
@payload = load_payload('test')
|
9
|
+
@exploit = load_exploit('example')
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should require a name attribute" do
|
@@ -36,24 +37,21 @@ describe Payloads::Payload do
|
|
36
37
|
third_payload.should be_valid
|
37
38
|
end
|
38
39
|
|
40
|
+
it "should initialize all parameters by default" do
|
41
|
+
@payload.params.should_not be_empty
|
42
|
+
end
|
43
|
+
|
39
44
|
it "should not have any controls by default" do
|
40
45
|
@payload.controls.should be_empty
|
41
46
|
end
|
42
47
|
|
43
48
|
it "should specify what behaviors the payload controls" do
|
44
|
-
@payload.controlling :memory_read
|
49
|
+
@payload.controlling :memory_read, :memory_write
|
45
50
|
|
46
|
-
@payload.behaviors.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@payload.instance_eval { helper :shell }.should == true
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should raise an UnknownHelper when extending an unknown helper" do
|
54
|
-
lambda {
|
55
|
-
@payload.instance_eval { helper :obvious_not_there }
|
56
|
-
}.should raise_error(Payloads::UnknownHelper)
|
51
|
+
@payload.behaviors.should == [
|
52
|
+
Vuln::Behavior[:memory_read],
|
53
|
+
Vuln::Behavior[:memory_write]
|
54
|
+
]
|
57
55
|
end
|
58
56
|
|
59
57
|
it "should not have an Arch by default" do
|
@@ -77,14 +75,45 @@ describe Payloads::Payload do
|
|
77
75
|
@payload.os.version.should == '7.1'
|
78
76
|
end
|
79
77
|
|
78
|
+
it "should allow for the extending of Helper modules" do
|
79
|
+
@payload.instance_eval { helper :shell }.should == true
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should raise an UnknownHelper when extending an unknown helper" do
|
83
|
+
lambda {
|
84
|
+
@payload.instance_eval { helper :obvious_not_there }
|
85
|
+
}.should raise_error(Payloads::UnknownHelper)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not have an exploit by default" do
|
89
|
+
@payload.exploit.should be_nil
|
90
|
+
end
|
91
|
+
|
80
92
|
it "should have 'built' and 'unbiult' states" do
|
81
93
|
@payload.should_not be_built
|
82
94
|
@payload.build!
|
83
95
|
@payload.should be_built
|
84
96
|
end
|
85
97
|
|
86
|
-
it "should
|
87
|
-
@payload.build
|
98
|
+
it "should store the built payload in the @payload instance variable" do
|
99
|
+
@payload.build!
|
100
|
+
@payload.payload.should == "code.func"
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should return the built payload when calling build!" do
|
104
|
+
@payload.build!.should == "code.func"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should use parameters in the building of the payload" do
|
108
|
+
@payload.custom = 'hello'
|
109
|
+
@payload.build!.should == "code.hello"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should have 'deployed' and 'undeployed' states" do
|
113
|
+
@payload.should_not be_deployed
|
114
|
+
@payload.build!
|
115
|
+
@payload.deploy!
|
116
|
+
@payload.should be_deployed
|
88
117
|
end
|
89
118
|
|
90
119
|
it "should have a default deployer method" do
|
@@ -92,4 +121,38 @@ describe Payloads::Payload do
|
|
92
121
|
payload.should == @payload
|
93
122
|
end
|
94
123
|
end
|
124
|
+
|
125
|
+
it "should pass the built payload to the exploit when deploying" do
|
126
|
+
@payload.exploit = @exploit
|
127
|
+
|
128
|
+
@payload.build!
|
129
|
+
@payload.deploy! do |payload|
|
130
|
+
payload.exploit.payload.should == "code.func"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should call the exploit when deployed" do
|
135
|
+
@payload.exploit = @exploit
|
136
|
+
|
137
|
+
@payload.build!
|
138
|
+
@payload.deploy! do |payload|
|
139
|
+
payload.exploit.should be_built
|
140
|
+
payload.exploit.should be_deployed
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should build and deploy the payload when called" do
|
145
|
+
@payload.call
|
146
|
+
|
147
|
+
@payload.should be_built
|
148
|
+
@payload.should be_deployed
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should return the name and the version when calling to_s" do
|
152
|
+
@payload.to_s.should == 'test 0.1'
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should have a custom inspect method" do
|
156
|
+
@payload.inspect.should == '#<Ronin::Payloads::Payload: test 0.1 {:custom=>"func"}>'
|
157
|
+
end
|
95
158
|
end
|