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.
- data/History.txt +80 -2
- data/Manifest.txt +63 -16
- data/README.txt +89 -2
- data/Rakefile +1 -1
- data/TODO.txt +1 -1
- data/bin/ronin-exploits +12 -0
- data/bin/ronin-payload +12 -0
- data/bin/ronin-payloads +12 -0
- data/lib/ronin/exploits.rb +13 -10
- data/lib/ronin/exploits/{impact.rb → allow.rb} +9 -4
- data/lib/ronin/exploits/exceptions.rb +3 -0
- data/lib/ronin/exploits/exceptions/target_data_missing.rb +29 -0
- data/lib/ronin/exploits/exceptions/target_unspecified.rb +29 -0
- data/lib/ronin/exploits/exceptions/unknown_helper.rb +29 -0
- data/lib/ronin/exploits/exploit.rb +330 -77
- data/lib/ronin/exploits/{format_string_target.rb → ftp.rb} +5 -11
- data/lib/ronin/exploits/helpers.rb +27 -0
- data/lib/ronin/exploits/helpers/binary.rb +44 -0
- data/lib/ronin/exploits/helpers/buffer_overflow.rb +102 -0
- data/lib/ronin/exploits/helpers/format_string.rb +107 -0
- data/lib/ronin/exploits/helpers/padding.rb +84 -0
- data/lib/ronin/exploits/http.rb +37 -0
- data/lib/ronin/exploits/{requirement.rb → local.rb} +2 -14
- data/lib/ronin/exploits/remote.rb +34 -0
- data/lib/ronin/exploits/remote_tcp.rb +70 -0
- data/lib/ronin/exploits/remote_udp.rb +70 -0
- data/lib/ronin/exploits/target.rb +134 -0
- data/lib/ronin/exploits/targets.rb +29 -0
- data/lib/ronin/exploits/{buffer_overflow_target.rb → targets/buffer_overflow.rb} +13 -11
- data/lib/ronin/exploits/{exploit_target.rb → targets/format_string.rb} +11 -14
- data/lib/ronin/exploits/version.rb +1 -1
- data/lib/ronin/exploits/{web_exploit.rb → web.rb} +3 -3
- data/lib/ronin/model/targets_arch.rb +59 -0
- data/lib/ronin/model/targets_os.rb +59 -0
- data/lib/ronin/payloads.rb +7 -3
- data/lib/ronin/payloads/binary_payload.rb +3 -7
- data/lib/ronin/payloads/{ability.rb → control.rb} +7 -2
- data/lib/ronin/payloads/encoder.rb +78 -0
- data/lib/ronin/payloads/encoders.rb +33 -0
- data/lib/ronin/payloads/encoders/xor.rb +81 -0
- data/lib/ronin/payloads/exceptions.rb +24 -0
- data/lib/ronin/payloads/exceptions/unknown_helper.rb +29 -0
- data/lib/ronin/payloads/helpers.rb +26 -0
- data/lib/ronin/payloads/helpers/exceptions.rb +24 -0
- data/lib/ronin/payloads/helpers/exceptions/program_not_found.rb +31 -0
- data/lib/ronin/payloads/helpers/exceptions/unimplemented.rb +31 -0
- data/lib/ronin/payloads/helpers/file_system.rb +187 -0
- data/lib/ronin/payloads/helpers/rpc.rb +83 -0
- data/lib/ronin/payloads/helpers/shell.rb +91 -0
- data/lib/ronin/payloads/nops.rb +32 -0
- data/lib/ronin/payloads/payload.rb +90 -53
- data/lib/ronin/payloads/shellcode.rb +1 -1
- data/lib/ronin/payloads/web_payload.rb +2 -1
- data/lib/ronin/targeted_arch.rb +38 -0
- data/lib/ronin/targeted_os.rb +38 -0
- data/lib/ronin/targeted_product.rb +34 -0
- data/lib/ronin/ui/command_line/commands/exploits.rb +77 -0
- data/lib/ronin/ui/command_line/commands/payload.rb +106 -0
- data/lib/ronin/ui/command_line/commands/payloads.rb +73 -0
- data/spec/exploits/binary_exploit_spec.rb +44 -0
- data/spec/exploits/buffer_overflow_exploit_spec.rb +70 -0
- data/spec/exploits/exploit_spec.rb +122 -25
- data/spec/exploits/format_string_exploit_spec.rb +32 -0
- data/spec/exploits/ftp_spec.rb +17 -0
- data/spec/exploits/http_spec.rb +17 -0
- data/spec/exploits/padding_exploit_spec.rb +44 -0
- data/spec/exploits/remote_tcp_spec.rb +24 -0
- data/spec/exploits/remote_udp_spec.rb +24 -0
- data/spec/exploits/target_spec.rb +91 -0
- data/spec/exploits/targets/buffer_overflow_spec.rb +18 -0
- data/spec/exploits/{web_exploit_spec.rb → web_spec.rb} +5 -5
- data/spec/helpers/database.rb +5 -0
- data/spec/helpers/objects.rb +22 -0
- data/spec/objects/exploits/test.rb +28 -0
- data/spec/objects/payloads/example.rb +19 -0
- data/spec/objects/payloads/test.rb +11 -0
- data/spec/payloads/encoder_spec.rb +26 -0
- data/spec/payloads/encoders/xor_spec.rb +20 -0
- data/spec/payloads/payload_spec.rb +48 -13
- data/spec/spec_helper.rb +3 -5
- metadata +71 -22
- data/lib/ronin/exploits/binary_exploit.rb +0 -139
- data/lib/ronin/exploits/buffer_overflow.rb +0 -80
- data/lib/ronin/exploits/exploitable.rb +0 -77
- data/lib/ronin/exploits/format_string.rb +0 -88
- data/lib/ronin/models.rb +0 -38
- data/lib/ronin/translators/xor.rb +0 -96
- data/spec/exploits/exploitable_spec.rb +0 -21
- data/spec/translators/xor_spec.rb +0 -26
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ronin/exploits/local'
|
2
|
+
require 'ronin/exploits/helpers/format_string'
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Exploits::Helpers::FormatString do
|
7
|
+
before(:all) do
|
8
|
+
@exploit = Exploits::Local.new do
|
9
|
+
helper :format_string
|
10
|
+
|
11
|
+
self.name = 'example_fmtstring'
|
12
|
+
|
13
|
+
targeting do |target|
|
14
|
+
target.arch = Arch.i686
|
15
|
+
target.pop_length = 256
|
16
|
+
target.overwrite = 0xffffaaaa
|
17
|
+
target.address = 0xffffbbbb
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should use Targets::FormatString for targets" do
|
23
|
+
@exploit.targets.all? { |target|
|
24
|
+
target.class == Exploits::Targets::FormatString
|
25
|
+
}.should == true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should build a format string" do
|
29
|
+
@exploit.target = @exploit.targets[0]
|
30
|
+
@exploit.build!
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ronin/exploits/ftp'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exploits::FTP do
|
6
|
+
before(:all) do
|
7
|
+
@exploit = Exploits::FTP.new do
|
8
|
+
self.name = 'example_ftp'
|
9
|
+
end
|
10
|
+
|
11
|
+
@exploit.save!
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a default port of 21" do
|
15
|
+
@exploit.default_port.should == 21
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ronin/exploits/http'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exploits::HTTP do
|
6
|
+
before(:all) do
|
7
|
+
@exploit = Exploits::HTTP.new do
|
8
|
+
self.name = 'example_httpd'
|
9
|
+
end
|
10
|
+
|
11
|
+
@exploit.save!
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a default port of 80" do
|
15
|
+
@exploit.default_port.should == 80
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ronin/exploits/local'
|
2
|
+
require 'ronin/exploits/helpers/padding'
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Exploits::Helpers::Padding do
|
7
|
+
before(:all) do
|
8
|
+
@exploit = Exploits::Local.new do
|
9
|
+
helper :padding
|
10
|
+
|
11
|
+
def pad_buffer
|
12
|
+
pad(1024)
|
13
|
+
end
|
14
|
+
|
15
|
+
def pad_data_left
|
16
|
+
pad_left('hello',1024)
|
17
|
+
end
|
18
|
+
|
19
|
+
def pad_data_right
|
20
|
+
pad_right('hello',1024)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should pad a buffer" do
|
26
|
+
buffer = @exploit.pad_buffer
|
27
|
+
|
28
|
+
buffer.length.should == 1024
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should pad a buffer with data to the left" do
|
32
|
+
buffer = @exploit.pad_data_left
|
33
|
+
|
34
|
+
buffer.length.should == 1024
|
35
|
+
(buffer =~ /hello$/).should_not be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should pad a buffer with data to the right" do
|
39
|
+
buffer = @exploit.pad_data_right
|
40
|
+
|
41
|
+
buffer.length.should == 1024
|
42
|
+
(buffer =~ /^hello/).should_not be_nil
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ronin/exploits/remote_tcp'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exploits::RemoteTCP do
|
6
|
+
before(:all) do
|
7
|
+
@exp = Exploits::RemoteTCP.new(
|
8
|
+
:default_port => 22,
|
9
|
+
:host => '127.0.0.1'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should include the TCP Session module" do
|
14
|
+
Exploits::RemoteTCP.include?(Sessions::TCP).should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should default the port to the default_port before deploying" do
|
18
|
+
@exp.build!
|
19
|
+
|
20
|
+
@exp.deploy! do |exp|
|
21
|
+
exp.port.should == 22
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ronin/exploits/remote_udp'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exploits::RemoteUDP do
|
6
|
+
before(:all) do
|
7
|
+
@exp = Exploits::RemoteUDP.new(
|
8
|
+
:default_port => 22,
|
9
|
+
:host => '127.0.0.1'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should include the UDP Session module" do
|
14
|
+
Exploits::RemoteUDP.include?(Sessions::UDP).should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should default the port to the default_port before deploying" do
|
18
|
+
@exp.build!
|
19
|
+
|
20
|
+
@exp.deploy! do |exp|
|
21
|
+
exp.port.should == 22
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'ronin/exploits/target'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exploits::Target do
|
6
|
+
before(:each) do
|
7
|
+
@target = Exploits::Target.new(
|
8
|
+
:data => {:var => 1, :test => 'hello'}
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not have an Arch by default" do
|
13
|
+
@target.arch.should be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set the Arch when called with a name" do
|
17
|
+
@target.arch :i686
|
18
|
+
@target.arch.name.should == 'i686'
|
19
|
+
@target.arch.endian == 'little'
|
20
|
+
@target.arch.address_length == 4
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not have an OS by default" do
|
24
|
+
@target.os.should be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should set the OS when called with arguments" do
|
28
|
+
@target.os(:name => 'FreeBSD', :version => '7.1')
|
29
|
+
@target.os.name.should == 'FreeBSD'
|
30
|
+
@target.os.version.should == '7.1'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not have a product by default" do
|
34
|
+
@target.product.should be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set the product when called with arguments" do
|
38
|
+
@target.product(:name => 'Apache', :version => '1.3.3.7')
|
39
|
+
@target.product.name.should == 'Apache'
|
40
|
+
@target.product.version.should == '1.3.3.7'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should contain target data" do
|
44
|
+
@target.data[:var].should == 1
|
45
|
+
@target.data[:test].should == 'hello'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should provide Hash like access to target data" do
|
49
|
+
@target[:var].should == 1
|
50
|
+
@target[:test].should == 'hello'
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to set data like a Hash" do
|
54
|
+
@target[:var] = 2
|
55
|
+
|
56
|
+
@target[:var].should == 2
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should provide OStruct like access to target data" do
|
60
|
+
@target.var.should == 1
|
61
|
+
@target.test.should == 'hello'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should be able to set data like an OStruct" do
|
65
|
+
@target.var = 2
|
66
|
+
|
67
|
+
@target.var.should == 2
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be able to serialize and deserialize it's target data" do
|
71
|
+
@target.save!
|
72
|
+
|
73
|
+
target = Exploits::Target.get(@target.id)
|
74
|
+
target.data[:var].should == 1
|
75
|
+
target.data[:test].should == 'hello'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should not raise TargetDataMissing when setting new data" do
|
79
|
+
lambda {
|
80
|
+
@target.bla = 'yes'
|
81
|
+
}.should_not raise_error(Exploits::TargetDataMissing)
|
82
|
+
|
83
|
+
@target.bla.should == 'yes'
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should raise TargetDataMissing when accessing non-existant data" do
|
87
|
+
lambda {
|
88
|
+
@target.bla
|
89
|
+
}.should raise_error(Exploits::TargetDataMissing)
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ronin/exploits/targets/buffer_overflow'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Exploits::Targets::BufferOverflow do
|
6
|
+
it "should require an ip to overwrite with" do
|
7
|
+
target = Exploits::Targets::BufferOverflow.new
|
8
|
+
target.should_not be_valid
|
9
|
+
|
10
|
+
target.ip = 0xffffeeee
|
11
|
+
target.should be_valid
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a default frame_repeat of 1" do
|
15
|
+
target = Exploits::Targets::BufferOverflow.new
|
16
|
+
target.frame_repeat.should == 1
|
17
|
+
end
|
18
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require 'ronin/exploits/
|
1
|
+
require 'ronin/exploits/web'
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Exploits::
|
5
|
+
describe Exploits::Web do
|
6
6
|
describe "targeted_url" do
|
7
7
|
it "should create a targeted URL using the host param" do
|
8
8
|
host = 'www.example.com'
|
9
|
-
exploit = Exploits::
|
9
|
+
exploit = Exploits::Web.new(:host => host)
|
10
10
|
|
11
11
|
exploit.targeted_url.host.should == host
|
12
12
|
end
|
@@ -14,14 +14,14 @@ describe Exploits::WebExploit do
|
|
14
14
|
it "should create a targeted URL using the host param and the url_path property" do
|
15
15
|
host = 'www.example.com'
|
16
16
|
path = '/'
|
17
|
-
exploit = Exploits::
|
17
|
+
exploit = Exploits::Web.new(:host => host, :url_path => path)
|
18
18
|
|
19
19
|
exploit.targeted_url.host.should == host
|
20
20
|
exploit.targeted_url.path.should == path
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should raise a MissingParam exception if host params is missing" do
|
24
|
-
exploit = Exploits::
|
24
|
+
exploit = Exploits::Web.new(:url_path => '/')
|
25
25
|
|
26
26
|
lambda { exploit.targeted_url }.should raise_error(Parameters::MissingParam)
|
27
27
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ronin/exploits/exploit'
|
2
|
+
require 'ronin/payloads/payload'
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
EXPLOITS_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','objects','exploits'))
|
7
|
+
|
8
|
+
PAYLOADS_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','objects','payloads'))
|
9
|
+
|
10
|
+
PAYLOAD_ENCODERS_DIR = File.join(PAYLOADS_DIR,'encoders')
|
11
|
+
|
12
|
+
def load_exploit(name,base=Exploits::Exploit)
|
13
|
+
base.load_from(File.join(EXPLOITS_DIR,"#{name}.rb"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_payload(name,base=Payloads::Payload)
|
17
|
+
base.load_from(File.join(PAYLOADS_DIR,"#{name}.rb"))
|
18
|
+
end
|
19
|
+
|
20
|
+
def load_payload_encoder(name,base=Payloads::Encoder)
|
21
|
+
base.load_from(File.join(PAYLOAD_ENCODERS_DIR,"#{name}.rb"))
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
ronin_exploit do
|
2
|
+
parameter :var,
|
3
|
+
:default => 'value1',
|
4
|
+
:description => 'Parameter to be shared with the payload'
|
5
|
+
|
6
|
+
cache do
|
7
|
+
self.name = 'test'
|
8
|
+
self.version = '0.2'
|
9
|
+
|
10
|
+
author :name => 'Anonymous', :email => 'anonymous@example.com'
|
11
|
+
|
12
|
+
targeting do |target|
|
13
|
+
target.arch :i686
|
14
|
+
target.os :name => 'Linux', :version => '2.6.23'
|
15
|
+
target.product :name => 'ExampleWare', :version => '1.5'
|
16
|
+
end
|
17
|
+
|
18
|
+
targeting do |target|
|
19
|
+
target.arch :i386
|
20
|
+
target.os :name => 'Windows', :version => '7.1'
|
21
|
+
target.product :name => 'ExampleWare', :version => '1.5'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def build
|
26
|
+
'result'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
ronin_payload do
|
2
|
+
parameter :var,
|
3
|
+
:value => 'usual',
|
4
|
+
:description => 'Parameter set by an exploit'
|
5
|
+
|
6
|
+
cache do
|
7
|
+
self.name = 'example'
|
8
|
+
self.version = '0.2'
|
9
|
+
|
10
|
+
arch :i686
|
11
|
+
os :name => 'Linux'
|
12
|
+
|
13
|
+
author :name => 'Anonymous', :email => 'anonymous@example.com'
|
14
|
+
end
|
15
|
+
|
16
|
+
def build
|
17
|
+
@payload = "data/#{@var}"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'ronin/payloads/encoder'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Payloads::Encoder do
|
6
|
+
before(:all) do
|
7
|
+
@encoder = Payloads::Encoder.new
|
8
|
+
@data = 'some data'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should require a name" do
|
12
|
+
encoder = Payloads::Encoder.new
|
13
|
+
encoder.should_not be_valid
|
14
|
+
|
15
|
+
encoder = Payloads::Encoder.new(:name => 'encoder')
|
16
|
+
encoder.should be_valid
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should provide a #call method" do
|
20
|
+
@encoder.respond_to?(:call).should == true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return the data to be encoded by default" do
|
24
|
+
@encoder.call(@data).should == @data
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'ronin/payloads/encoders/xor'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Ronin do
|
6
|
+
describe Payloads::Encoders::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 = Payloads::Encoders::XOR.new(:disallow => disallow)
|
14
|
+
|
15
|
+
xor.call(@data).each_byte do |b|
|
16
|
+
disallow.include?(b).should_not == true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|