ronin-payloads 0.1.0.beta1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.yardopts +1 -1
- data/README.md +4 -3
- data/bin/ronin-payloads +1 -1
- data/gemspec.yml +8 -7
- data/lib/ronin/payloads/asm_payload.rb +1 -1
- data/lib/ronin/payloads/binary_payload.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/awk/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/bash/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/lua/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/node/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/openssl/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/perl/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/php/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/powershell/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/python/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/cmd/ruby/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/java/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/php/cmd_exec.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/bind_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/freebsd/x86_64/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/arm/bind_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/arm/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/arm/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/mips/bind_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/mips/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/mips/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/ppc/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/ppc/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/x86/bind_shell.rb +2 -2
- data/lib/ronin/payloads/builtin/shellcode/linux/x86/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/x86/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/bind_shell.rb +2 -2
- data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/macos/x86_64/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/macos/x86_64/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/netbsd/x86/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/netbsd/x86/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/openbsd/x86/bind_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/openbsd/x86/exec_shell.rb +1 -1
- data/lib/ronin/payloads/builtin/shellcode/windows/x86_64/cmd.rb +1 -1
- data/lib/ronin/payloads/builtin/test/open_redirect.rb +1 -1
- data/lib/ronin/payloads/builtin/test/xss.rb +1 -1
- data/lib/ronin/payloads/c_payload.rb +1 -1
- data/lib/ronin/payloads/cli/command.rb +1 -1
- data/lib/ronin/payloads/cli/commands/build.rb +1 -1
- data/lib/ronin/payloads/cli/commands/encode.rb +1 -1
- data/lib/ronin/payloads/cli/commands/encoder.rb +1 -1
- data/lib/ronin/payloads/cli/commands/encoders.rb +2 -2
- data/lib/ronin/payloads/cli/commands/irb.rb +1 -1
- data/lib/ronin/payloads/cli/commands/launch.rb +1 -1
- data/lib/ronin/payloads/cli/commands/list.rb +1 -1
- data/lib/ronin/payloads/cli/commands/new.rb +3 -3
- data/lib/ronin/payloads/cli/commands/show.rb +2 -2
- data/lib/ronin/payloads/cli/encoder_methods.rb +1 -1
- data/lib/ronin/payloads/cli/format_option.rb +1 -1
- data/lib/ronin/payloads/cli/generator/payload_types.rb +3 -3
- data/lib/ronin/payloads/cli/payload_command.rb +1 -1
- data/lib/ronin/payloads/cli/payload_methods.rb +1 -1
- data/lib/ronin/payloads/cli/printing.rb +1 -1
- data/lib/ronin/payloads/cli/ruby_shell.rb +1 -1
- data/lib/ronin/payloads/cli.rb +6 -1
- data/lib/ronin/payloads/coldfusion_payload.rb +1 -1
- data/lib/ronin/payloads/command_payload.rb +1 -1
- data/lib/ronin/payloads/encoders/builtin/html/encode.rb +1 -1
- data/lib/ronin/payloads/encoders/builtin/js/encode.rb +1 -1
- data/lib/ronin/payloads/encoders/builtin/powershell/encode.rb +1 -1
- data/lib/ronin/payloads/encoders/builtin/shell/encode.rb +1 -1
- data/lib/ronin/payloads/encoders/builtin/sql/encode.rb +1 -1
- data/lib/ronin/payloads/encoders/builtin/xml/encode.rb +1 -1
- data/lib/ronin/payloads/encoders/encoder.rb +1 -1
- data/lib/ronin/payloads/encoders/exceptions.rb +1 -1
- data/lib/ronin/payloads/encoders/html_encoder.rb +1 -1
- data/lib/ronin/payloads/encoders/javascript_encoder.rb +1 -1
- data/lib/ronin/payloads/encoders/pipeline.rb +2 -2
- data/lib/ronin/payloads/encoders/powershell_encoder.rb +1 -1
- data/lib/ronin/payloads/encoders/registry.rb +1 -1
- data/lib/ronin/payloads/encoders/shell_encoder.rb +1 -1
- data/lib/ronin/payloads/encoders/sql_encoder.rb +1 -1
- data/lib/ronin/payloads/encoders/xml_encoder.rb +1 -1
- data/lib/ronin/payloads/encoders.rb +1 -1
- data/lib/ronin/payloads/exceptions.rb +1 -1
- data/lib/ronin/payloads/go_payload.rb +1 -1
- data/lib/ronin/payloads/html_payload.rb +1 -1
- data/lib/ronin/payloads/java_payload.rb +1 -1
- data/lib/ronin/payloads/javascript_payload.rb +1 -1
- data/lib/ronin/payloads/jsp_payload.rb +1 -1
- data/lib/ronin/payloads/metadata/arch.rb +1 -1
- data/lib/ronin/payloads/metadata/os.rb +1 -1
- data/lib/ronin/payloads/mixins/binary.rb +1 -1
- data/lib/ronin/payloads/mixins/bind_shell.rb +1 -1
- data/lib/ronin/payloads/mixins/build_dir.rb +1 -1
- data/lib/ronin/payloads/mixins/erb.rb +1 -1
- data/lib/ronin/payloads/mixins/network.rb +1 -1
- data/lib/ronin/payloads/mixins/post_ex.rb +1 -1
- data/lib/ronin/payloads/mixins/resolve_host.rb +1 -1
- data/lib/ronin/payloads/mixins/reverse_shell.rb +1 -1
- data/lib/ronin/payloads/mixins/tempfile.rb +1 -1
- data/lib/ronin/payloads/mixins/typescript.rb +1 -1
- data/lib/ronin/payloads/node_js_payload.rb +1 -1
- data/lib/ronin/payloads/payload.rb +1 -1
- data/lib/ronin/payloads/php_payload.rb +1 -1
- data/lib/ronin/payloads/powershell_payload.rb +1 -1
- data/lib/ronin/payloads/python_payload.rb +1 -1
- data/lib/ronin/payloads/registry.rb +1 -1
- data/lib/ronin/payloads/root.rb +1 -1
- data/lib/ronin/payloads/ruby_payload.rb +1 -1
- data/lib/ronin/payloads/rust_payload.rb +1 -1
- data/lib/ronin/payloads/shell_payload.rb +1 -1
- data/lib/ronin/payloads/shellcode/bind_shell_payload.rb +1 -1
- data/lib/ronin/payloads/shellcode/exec_shell_payload.rb +1 -1
- data/lib/ronin/payloads/shellcode/reverse_shell_payload.rb +1 -1
- data/lib/ronin/payloads/shellcode_payload.rb +1 -1
- data/lib/ronin/payloads/sql_payload.rb +1 -1
- data/lib/ronin/payloads/url_payload.rb +2 -2
- data/lib/ronin/payloads/version.rb +2 -2
- data/lib/ronin/payloads/xml_payload.rb +1 -1
- data/lib/ronin/payloads.rb +1 -1
- data/ronin-payloads.gemspec +2 -1
- metadata +16 -215
- data/spec/asm_payload_spec.rb +0 -114
- data/spec/binary_payload_spec.rb +0 -8
- data/spec/builtin/cmd/awk/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/bash/reverse_shell_spec.rb +0 -36
- data/spec/builtin/cmd/lua/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/node/reverse_shell_spec.rb +0 -36
- data/spec/builtin/cmd/openssl/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/perl/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/php/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/powershell/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/python/reverse_shell_spec.rb +0 -38
- data/spec/builtin/cmd/ruby/reverse_shell_spec.rb +0 -38
- data/spec/builtin/java/reverse_shell_spec.rb +0 -103
- data/spec/builtin/php/cmd_exec.rb +0 -52
- data/spec/builtin/shellcode/freebsd/x86/bind_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/freebsd/x86/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/freebsd/x86/reverse_shell_spec.rb +0 -63
- data/spec/builtin/shellcode/freebsd/x86_64/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/linux/arm/bind_shell_spec.rb +0 -62
- data/spec/builtin/shellcode/linux/arm/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/linux/arm/reverse_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/linux/mips/bind_shell_spec.rb +0 -60
- data/spec/builtin/shellcode/linux/mips/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/linux/mips/reverse_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/linux/ppc/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/linux/ppc/reverse_shell_spec.rb +0 -87
- data/spec/builtin/shellcode/linux/x86/bind_shell_spec.rb +0 -60
- data/spec/builtin/shellcode/linux/x86/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/linux/x86/reverse_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/linux/x86_64/bind_shell_spec.rb +0 -60
- data/spec/builtin/shellcode/linux/x86_64/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/linux/x86_64/reverse_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/macos/x86_64/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/macos/x86_64/reverse_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/netbsd/x86/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/netbsd/x86/reverse_shell_spec.rb +0 -63
- data/spec/builtin/shellcode/openbsd/x86/bind_shell_spec.rb +0 -58
- data/spec/builtin/shellcode/openbsd/x86/exec_shell_spec.rb +0 -46
- data/spec/builtin/shellcode/windows/x86_64/cmd_spec.rb +0 -54
- data/spec/builtin/test/open_redirect_spec.rb +0 -24
- data/spec/builtin/test/xss_spec.rb +0 -24
- data/spec/c_payload_spec.rb +0 -139
- data/spec/cli/commands/show_spec.rb +0 -21
- data/spec/cli/encoder_methods_spec.rb +0 -275
- data/spec/cli/format_option_spec.rb +0 -187
- data/spec/cli/payload_command_spec.rb +0 -68
- data/spec/cli/payload_methods_spec.rb +0 -208
- data/spec/cli/printing_spec.rb +0 -65
- data/spec/cli/ruby_shell_spec.rb +0 -14
- data/spec/coldfusion_payload_spec.rb +0 -8
- data/spec/command_payload_spec.rb +0 -8
- data/spec/encoders/builtin/html/encode_spec.rb +0 -17
- data/spec/encoders/builtin/js/encode_spec.rb +0 -17
- data/spec/encoders/builtin/powershell/encode_spec.rb +0 -17
- data/spec/encoders/builtin/shell/encode_spec.rb +0 -17
- data/spec/encoders/builtin/sql/encode_spec.rb +0 -17
- data/spec/encoders/builtin/xml/encode_spec.rb +0 -17
- data/spec/encoders/encoder_spec.rb +0 -62
- data/spec/encoders/html_encoder_spec.rb +0 -8
- data/spec/encoders/javascript_encoder_spec.rb +0 -8
- data/spec/encoders/pipeline_spec.rb +0 -153
- data/spec/encoders/powershell_encoder_spec.rb +0 -8
- data/spec/encoders/shell_encoder_spec.rb +0 -8
- data/spec/encoders/sql_encoder_spec.rb +0 -8
- data/spec/encoders/xml_encoder_spec.rb +0 -8
- data/spec/encoders_spec.rb +0 -25
- data/spec/go_payload_spec.rb +0 -56
- data/spec/helpers/encoders.rb +0 -9
- data/spec/helpers/payloads.rb +0 -9
- data/spec/helpers/scripts/payloads/simple.rb +0 -22
- data/spec/html_payload_spec.rb +0 -12
- data/spec/java_payload_spec.rb +0 -97
- data/spec/javascript_payload_spec.rb +0 -12
- data/spec/jsp_payload_spec.rb +0 -8
- data/spec/metadata/arch_spec.rb +0 -82
- data/spec/metadata/os_spec.rb +0 -164
- data/spec/mixins/binary_spec.rb +0 -129
- data/spec/mixins/bind_shell_spec.rb +0 -73
- data/spec/mixins/build_dir.rb +0 -64
- data/spec/mixins/erb_spec.rb +0 -19
- data/spec/mixins/network_spec.rb +0 -75
- data/spec/mixins/post_ex_spec.rb +0 -40
- data/spec/mixins/resolve_host_spec.rb +0 -322
- data/spec/mixins/reverse_shell_spec.rb +0 -103
- data/spec/mixins/tempfile_spec.rb +0 -97
- data/spec/mixins/typescript_spec.rb +0 -92
- data/spec/node_js_payload_spec.rb +0 -8
- data/spec/payload_spec.rb +0 -288
- data/spec/payloads_spec.rb +0 -29
- data/spec/php_payload_spec.rb +0 -8
- data/spec/powershell_payload_spec.rb +0 -16
- data/spec/python_payload_spec.rb +0 -8
- data/spec/ruby_payload_spec.rb +0 -8
- data/spec/rust_payload_spec.rb +0 -116
- data/spec/shell_payload_spec.rb +0 -16
- data/spec/shellcode/bind_shell_payload_spec.rb +0 -42
- data/spec/shellcode/exec_shell_payload_spec.rb +0 -8
- data/spec/shellcode/reverse_shell_payload_spec.rb +0 -136
- data/spec/shellcode_payload_spec.rb +0 -38
- data/spec/spec_helper.rb +0 -7
- data/spec/sql_payload_spec.rb +0 -12
- data/spec/url_payload_spec.rb +0 -72
- data/spec/xml_payload_spec.rb +0 -12
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/bind_shell'
|
3
|
-
require 'ronin/payloads/payload'
|
4
|
-
|
5
|
-
describe Ronin::Payloads::Mixins::BindShell do
|
6
|
-
module TestBindShellMixin
|
7
|
-
class TestPayload < Ronin::Payloads::Payload
|
8
|
-
include Ronin::Payloads::Mixins::BindShell
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:payload_class) { TestBindShellMixin::TestPayload }
|
13
|
-
|
14
|
-
it "must also include Ronin::Payloads::Mixins::PostEx" do
|
15
|
-
expect(payload_class).to include(Ronin::Payloads::Mixins::PostEx)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ".included" do
|
19
|
-
subject { payload_class }
|
20
|
-
|
21
|
-
it "must add a required 'host' param" do
|
22
|
-
expect(subject.params[:host]).to_not be_nil
|
23
|
-
expect(subject.params[:host].type).to be_kind_of(Ronin::Core::Params::Types::String)
|
24
|
-
expect(subject.params[:host].required?).to be(true)
|
25
|
-
expect(subject.params[:host].desc).to eq('The host to connect to')
|
26
|
-
end
|
27
|
-
|
28
|
-
it "must add a required 'port' param" do
|
29
|
-
expect(subject.params[:port]).to_not be_nil
|
30
|
-
expect(subject.params[:port].type).to be_kind_of(Ronin::Core::Params::Types::Integer)
|
31
|
-
expect(subject.params[:port].required?).to be(true)
|
32
|
-
expect(subject.params[:port].desc).to eq('The port to listen on')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:host) { 'example.com' }
|
37
|
-
let(:port) { 1337 }
|
38
|
-
|
39
|
-
subject do
|
40
|
-
payload_class.new(params: {host: host, port: port})
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#host" do
|
44
|
-
it "must return the 'host' param value" do
|
45
|
-
expect(subject.host).to eq(host)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "#port" do
|
50
|
-
it "must return the 'port' param value" do
|
51
|
-
expect(subject.port).to eq(port)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#perform_postlaunch" do
|
56
|
-
let(:addrinfo) { Addrinfo.tcp(host,port) }
|
57
|
-
let(:socket) { double('TCPSocket') }
|
58
|
-
|
59
|
-
before { allow(socket).to receive(:remote_address).and_return(addrinfo) }
|
60
|
-
|
61
|
-
let(:session) { Ronin::PostEx::Sessions::BindShell.new(socket) }
|
62
|
-
|
63
|
-
it "must print a message about connecting to host:port, create a new Ronin::PostEx::Sesssions::BindShell session, set #session, then print a message about being connected to host:port" do
|
64
|
-
expect(subject).to receive(:print_info).with("Connecting to #{host}:#{port} ...")
|
65
|
-
expect(Ronin::PostEx::Sessions::BindShell).to receive(:connect).with(host,port).and_return(session)
|
66
|
-
expect(subject).to receive(:print_info).with("Connected to #{host}:#{port}!")
|
67
|
-
|
68
|
-
subject.perform_postlaunch
|
69
|
-
|
70
|
-
expect(subject.session).to be(session)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
data/spec/mixins/build_dir.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/build_dir'
|
3
|
-
|
4
|
-
require 'ronin/payloads/payload'
|
5
|
-
|
6
|
-
describe Ronin::Payloads::Mixins::BuildDir do
|
7
|
-
module TestBuildDirMixin
|
8
|
-
class TestPayload < Ronin::Payloads::Payload
|
9
|
-
include Ronin::Payloads::Mixins::BuildDir
|
10
|
-
|
11
|
-
id 'test-payload'
|
12
|
-
|
13
|
-
def build
|
14
|
-
@payload = 'built payload'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:payload_class) { TestBuildDirMixin::TestPayload }
|
20
|
-
subject { payload_class.new }
|
21
|
-
|
22
|
-
describe "#perform_build" do
|
23
|
-
before { subject.perform_build }
|
24
|
-
|
25
|
-
it "must set #build_dir to a temporary directory using the payload ID then build the payload" do
|
26
|
-
expect(subject.build_dir).to match(%r{\A/tmp/ronin-payloads-#{payload_class.id}-\d+-\d+-[a-z0-9]+\z})
|
27
|
-
expect(File.directory?(subject.build_dir)).to be(true)
|
28
|
-
|
29
|
-
expect(subject.payload).to eq('built payload')
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when the payload ID contains a '/'" do
|
33
|
-
module TestBuildDirmixin
|
34
|
-
class TestPayloadWithDirSeparatorInID < Ronin::Payloads::Payload
|
35
|
-
include Ronin::Payloads::Mixins::BuildDir
|
36
|
-
|
37
|
-
id 'test/payload'
|
38
|
-
|
39
|
-
def build
|
40
|
-
@payload = 'built payload'
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
let(:payload_class) { TestBuildDirmixin::TestPayloadWithDirSeparatorInID }
|
46
|
-
|
47
|
-
it "must replace any '/' characters with a '-'" do
|
48
|
-
expect(subject.build_dir).to match(%r{\A/tmp/ronin-payloads-test-payload-\d+-\d+-[a-z0-9]+\z})
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#perform_cleanup" do
|
54
|
-
it "must delete #build_dir" do
|
55
|
-
subject.perform_build
|
56
|
-
|
57
|
-
build_dir = subject.build_dir
|
58
|
-
|
59
|
-
subject.perform_cleanup
|
60
|
-
|
61
|
-
expect(File.exist?(build_dir)).to be(false)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/spec/mixins/erb_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/erb'
|
3
|
-
|
4
|
-
require 'ronin/payloads/payload'
|
5
|
-
|
6
|
-
describe Ronin::Payloads::Mixins::ERB do
|
7
|
-
module TestErbMixin
|
8
|
-
class TestPayload < Ronin::Payloads::Payload
|
9
|
-
include Ronin::Payloads::Mixins::ERB
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:payload_class) { TestErbMixin::TestPayload }
|
14
|
-
subject { payload_class.new }
|
15
|
-
|
16
|
-
it "must include Ronin::Support::Text::ERB::Mixin" do
|
17
|
-
expect(payload_class).to include(Ronin::Support::Text::ERB::Mixin)
|
18
|
-
end
|
19
|
-
end
|
data/spec/mixins/network_spec.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/network'
|
3
|
-
|
4
|
-
require 'ronin/payloads/payload'
|
5
|
-
|
6
|
-
describe Ronin::Payloads::Mixins::Network do
|
7
|
-
module TestNetworkMixin
|
8
|
-
class TestPayload < Ronin::Payloads::Payload
|
9
|
-
include Ronin::Payloads::Mixins::Network
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:payload_class) { TestNetworkMixin::TestPayload }
|
14
|
-
subject { payload_class.new }
|
15
|
-
|
16
|
-
describe "#pack_ipv4" do
|
17
|
-
context "when given an IPv4 address" do
|
18
|
-
let(:ip) { '1.2.3.4' }
|
19
|
-
|
20
|
-
it "must pack the IPv4 address as a 32bit integer in network byte-order" do
|
21
|
-
expect(subject.pack_ipv4(ip)).to eq("\x01\x02\x03\x04".b)
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when given the `negate: true` keyword argument" do
|
25
|
-
it "must invert the bits of the packed IPv4 address" do
|
26
|
-
expect(subject.pack_ipv4(ip, negate: true)).to eq("\xfe\xfd\xfc\xfb".b)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when given an IPv6 address" do
|
32
|
-
let(:ip) { '::1' }
|
33
|
-
|
34
|
-
it do
|
35
|
-
expect {
|
36
|
-
subject.pack_ipv4(ip)
|
37
|
-
}.to raise_error(ArgumentError,"IP must be an IPv4 address: #{ip.inspect}")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#pack_ipv6" do
|
43
|
-
context "when given an IPv6 address" do
|
44
|
-
let(:ip) { '1111:2222:3333:4444:5555:6666:7777:8888' }
|
45
|
-
|
46
|
-
it "must pack the IPv6 address as a 128bit integer in network byte-order" do
|
47
|
-
expect(subject.pack_ipv6(ip)).to eq("\x11\x11\x22\x22\x33\x33\x44\x44\x55\x55\x66\x66\x77\x77\x88\x88".b)
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when given the `negate: true` keyword argument" do
|
51
|
-
it "must invert the bits of the packed IPv4 address" do
|
52
|
-
expect(subject.pack_ipv6(ip, negate: true)).to eq("\xee\xee\xdd\xdd\xcc\xcc\xbb\xbb\xaa\xaa\x99\x99\x88\x88\x77\x77".b)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "when given an IPv4 address" do
|
58
|
-
let(:ip) { '1.2.3.4' }
|
59
|
-
|
60
|
-
it do
|
61
|
-
expect {
|
62
|
-
subject.pack_ipv6(ip)
|
63
|
-
}.to raise_error(ArgumentError,"IP must be an IPv6 address: #{ip.inspect}")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#pack_port" do
|
69
|
-
let(:port) { 0xff00 }
|
70
|
-
|
71
|
-
it "must pack the port number as a 16bit integer in network byte-ordeR" do
|
72
|
-
expect(subject.pack_port(port)).to eq("\xff\x00".b)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
data/spec/mixins/post_ex_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/post_ex'
|
3
|
-
|
4
|
-
require 'ronin/payloads/payload'
|
5
|
-
require 'ronin/post_ex/sessions/session'
|
6
|
-
|
7
|
-
describe Ronin::Payloads::Mixins::PostEx do
|
8
|
-
module TestPostExMixin
|
9
|
-
class TestPayload < Ronin::Payloads::Payload
|
10
|
-
include Ronin::Payloads::Mixins::PostEx
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:payload_class) { TestPostExMixin::TestPayload }
|
15
|
-
subject { payload_class.new }
|
16
|
-
|
17
|
-
let(:session) { Ronin::PostEx::Sessions::Session.new }
|
18
|
-
|
19
|
-
describe "#session=" do
|
20
|
-
before { subject.session = session }
|
21
|
-
|
22
|
-
it "must set #session" do
|
23
|
-
expect(subject.session).to be(session)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#perform_cleanup" do
|
28
|
-
context "when #session is set" do
|
29
|
-
before { subject.session = session }
|
30
|
-
|
31
|
-
it "must call #session.close and set #session to nil" do
|
32
|
-
expect(session).to receive(:close)
|
33
|
-
|
34
|
-
subject.perform_cleanup
|
35
|
-
|
36
|
-
expect(subject.session).to be(nil)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,322 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/resolve_host'
|
3
|
-
|
4
|
-
require 'ronin/payloads/payload'
|
5
|
-
require 'resolv'
|
6
|
-
|
7
|
-
describe Ronin::Payloads::Mixins::ResolveHost do
|
8
|
-
module TestResolveHostMixin
|
9
|
-
class TestPayload < Ronin::Payloads::Payload
|
10
|
-
include Ronin::Payloads::Mixins::ResolveHost
|
11
|
-
|
12
|
-
param :host, String, desc: 'The host name'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:host) { 'example.com' }
|
17
|
-
let(:ipv4_addresses) { %w[93.184.216.34] }
|
18
|
-
let(:ipv6_addresses) { %w[2606:2800:220:1:248:1893:25c8:1946] }
|
19
|
-
let(:ip_addresses) { ipv4_addresses + ipv6_addresses }
|
20
|
-
let(:addresses) { Resolv.getaddresses(host) }
|
21
|
-
|
22
|
-
let(:payload_class) { TestResolveHostMixin::TestPayload }
|
23
|
-
subject do
|
24
|
-
payload_class.new(
|
25
|
-
params: {
|
26
|
-
host: host
|
27
|
-
}
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#host_addresses" do
|
32
|
-
context "when the host has addresses" do
|
33
|
-
it "must return the IPv4 and IPv6 addresses for the host" do
|
34
|
-
expect(subject.host_addresses).to eq(addresses)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context "when the host is an IPv4 address" do
|
39
|
-
let(:host) { '127.0.0.1' }
|
40
|
-
|
41
|
-
it "must return an Array containing the host" do
|
42
|
-
expect(subject.host_addresses).to eq([host])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "when the host is an IPv6 address" do
|
47
|
-
let(:host) { '::1' }
|
48
|
-
|
49
|
-
it "must return an Array containing the host" do
|
50
|
-
expect(subject.host_addresses).to eq([host])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when the host has no addresses" do
|
55
|
-
let(:host) { 'does.not.exist' }
|
56
|
-
|
57
|
-
it "must return an empty Array" do
|
58
|
-
expect(subject.host_addresses).to eq([])
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#host_address" do
|
64
|
-
context "when the host has addresses" do
|
65
|
-
it "must return the first IP addresses for the host" do
|
66
|
-
expect(addresses).to include(subject.host_address)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when the host is an IPv4 address" do
|
71
|
-
let(:host) { '127.0.0.1' }
|
72
|
-
|
73
|
-
it "must return the host" do
|
74
|
-
expect(subject.host_address).to eq(host)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "when the host is an IPv6 address" do
|
79
|
-
let(:host) { '::1' }
|
80
|
-
|
81
|
-
it "must return the host" do
|
82
|
-
expect(subject.host_address).to eq(host)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "when the host has no addresses" do
|
87
|
-
let(:host) { 'does.not.exist' }
|
88
|
-
|
89
|
-
it "must return nil "do
|
90
|
-
expect(subject.host_address).to be(nil)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "#host_ip_addresses" do
|
96
|
-
context "when the host has addresses" do
|
97
|
-
it "must return the IPv4 and IPv6 addresses for the host" do
|
98
|
-
expect(subject.host_ip_addresses).to eq(ip_addresses)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "when the host is an IPv4 address" do
|
103
|
-
let(:host) { '127.0.0.1' }
|
104
|
-
|
105
|
-
it "must return an Array containing the host" do
|
106
|
-
expect(subject.host_ip_addresses).to eq([host])
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "when the host is an IPv6 address" do
|
111
|
-
let(:host) { '::1' }
|
112
|
-
|
113
|
-
it "must return an Array containing the host" do
|
114
|
-
expect(subject.host_ip_addresses).to eq([host])
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context "when the host has no addresses" do
|
119
|
-
let(:host) { 'does.not.exist' }
|
120
|
-
|
121
|
-
it "must return an empty Array" do
|
122
|
-
expect(subject.host_ip_addresses).to eq([])
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "#host_ip_address" do
|
128
|
-
context "when the host has addresses" do
|
129
|
-
it "must return the first IP addresses for the host" do
|
130
|
-
expect(ip_addresses).to include(subject.host_ip_address)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
context "when the host is an IPv4 address" do
|
135
|
-
let(:host) { '127.0.0.1' }
|
136
|
-
|
137
|
-
it "must return the host" do
|
138
|
-
expect(subject.host_ip_address).to eq(host)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context "when the host is an IPv6 address" do
|
143
|
-
let(:host) { '::1' }
|
144
|
-
|
145
|
-
it "must return the host" do
|
146
|
-
expect(subject.host_ip_address).to eq(host)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "when the host has no addresses" do
|
151
|
-
let(:host) { 'does.not.exist' }
|
152
|
-
|
153
|
-
it "must return nil "do
|
154
|
-
expect(subject.host_ip_address).to be(nil)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe "#host_ipv4_addresses" do
|
160
|
-
context "when the host has addresses" do
|
161
|
-
it "must return the IPv4 addresses for the host" do
|
162
|
-
expect(subject.host_ipv4_addresses).to eq(ipv4_addresses)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "when the host is an IPv4 address" do
|
167
|
-
let(:host) { '127.0.0.1' }
|
168
|
-
|
169
|
-
it "must return an Array containing the host" do
|
170
|
-
expect(subject.host_ipv4_addresses).to eq([host])
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
context "when the host is an IPv6 address" do
|
175
|
-
let(:host) { '::1' }
|
176
|
-
|
177
|
-
it do
|
178
|
-
expect {
|
179
|
-
subject.host_ipv4_addresses
|
180
|
-
}.to raise_error(Ronin::Payloads::ValidationError,"host must be a hostname or an IPv4 address, was an IPv6 address: #{host.inspect}")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
context "when the host only has IPv6 addresses" do
|
185
|
-
let(:host) { 'ipv6.wtfismyip.com' }
|
186
|
-
|
187
|
-
it "must return an empty Array" do
|
188
|
-
expect(subject.host_ipv4_addresses).to eq([])
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context "when the host has no addresses" do
|
193
|
-
let(:host) { 'does.not.exist' }
|
194
|
-
|
195
|
-
it "must return an empty Array" do
|
196
|
-
expect(subject.host_ipv4_addresses).to eq([])
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "#host_ipv4_address" do
|
202
|
-
context "when the host has addresses" do
|
203
|
-
it "must return the first IP addresses for the host" do
|
204
|
-
expect(ipv4_addresses).to include(subject.host_ipv4_address)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
context "when the host is an IPv4 address" do
|
209
|
-
let(:host) { '127.0.0.1' }
|
210
|
-
|
211
|
-
it "must return the host" do
|
212
|
-
expect(subject.host_ipv4_address).to eq(host)
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context "when the host is an IPv6 address" do
|
217
|
-
let(:host) { '::1' }
|
218
|
-
|
219
|
-
it do
|
220
|
-
expect {
|
221
|
-
subject.host_ipv4_address
|
222
|
-
}.to raise_error(Ronin::Payloads::ValidationError,"host must be a hostname or an IPv4 address, was an IPv6 address: #{host.inspect}")
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
context "when the host only has IPv6 addresses" do
|
227
|
-
let(:host) { 'ipv6.wtfismyip.com' }
|
228
|
-
|
229
|
-
it "must return nil" do
|
230
|
-
expect(subject.host_ipv4_address).to be(nil)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
context "when the host has no addresses" do
|
235
|
-
let(:host) { 'does.not.exist' }
|
236
|
-
|
237
|
-
it "must return nil "do
|
238
|
-
expect(subject.host_ipv4_address).to be(nil)
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
describe "#host_ipv6_addresses" do
|
244
|
-
context "when the host has addresses" do
|
245
|
-
it "must return the IPv4 and IPv6 addresses for the host" do
|
246
|
-
expect(subject.host_ipv6_addresses).to eq(ipv6_addresses)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
context "when the host is an IPv4 address" do
|
251
|
-
let(:host) { '127.0.0.1' }
|
252
|
-
|
253
|
-
it "must return an IPv6-to-IPv4 mapped address" do
|
254
|
-
expect(subject.host_ipv6_addresses).to eq(["::ffff:#{host}"])
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context "when the host is an IPv6 address" do
|
259
|
-
let(:host) { '::1' }
|
260
|
-
|
261
|
-
it "must return an Array containing the host" do
|
262
|
-
expect(subject.host_ipv6_addresses).to eq([host])
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
context "when the host only has IPv4 addresses" do
|
267
|
-
let(:host) { 'a.resolvers.level3.net' }
|
268
|
-
|
269
|
-
it "must return an empty Array" do
|
270
|
-
expect(subject.host_ipv6_addresses).to eq([])
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
context "when the host has no addresses" do
|
275
|
-
let(:host) { 'does.not.exist' }
|
276
|
-
|
277
|
-
it "must return an empty Array" do
|
278
|
-
expect(subject.host_ipv6_addresses).to eq([])
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
describe "#host_ipv6_address" do
|
284
|
-
context "when the host has addresses" do
|
285
|
-
it "must return the first IP addresses for the host" do
|
286
|
-
expect(ipv6_addresses).to include(subject.host_ipv6_address)
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context "when the host is an IPv4 address" do
|
291
|
-
let(:host) { '127.0.0.1' }
|
292
|
-
|
293
|
-
it "must return an IPv6-to-IPv4 mapped address" do
|
294
|
-
expect(subject.host_ipv6_address).to eq("::ffff:#{host}")
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
context "when the host is an IPv6 address" do
|
299
|
-
let(:host) { '::1' }
|
300
|
-
|
301
|
-
it "must return an Array containing the host" do
|
302
|
-
expect(subject.host_ipv6_address).to eq(host)
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
context "when the host only has IPv4 addresses" do
|
307
|
-
let(:host) { 'a.resolvers.level3.net' }
|
308
|
-
|
309
|
-
it "must return nil" do
|
310
|
-
expect(subject.host_ipv6_address).to be(nil)
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
context "when the host has no addresses" do
|
315
|
-
let(:host) { 'does.not.exist' }
|
316
|
-
|
317
|
-
it "must return nil "do
|
318
|
-
expect(subject.host_ipv6_address).to be(nil)
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/mixins/reverse_shell'
|
3
|
-
require 'ronin/payloads/payload'
|
4
|
-
|
5
|
-
describe Ronin::Payloads::Mixins::ReverseShell do
|
6
|
-
module TestReverseShellMixin
|
7
|
-
class TestPayload < Ronin::Payloads::Payload
|
8
|
-
include Ronin::Payloads::Mixins::ReverseShell
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:payload_class) { TestReverseShellMixin::TestPayload }
|
13
|
-
|
14
|
-
describe ".included" do
|
15
|
-
subject { payload_class }
|
16
|
-
|
17
|
-
it "must add a required 'host' param" do
|
18
|
-
expect(subject.params[:host]).to_not be_nil
|
19
|
-
expect(subject.params[:host].type).to be_kind_of(Ronin::Core::Params::Types::String)
|
20
|
-
expect(subject.params[:host].required?).to be(true)
|
21
|
-
expect(subject.params[:host].desc).to eq('The host to connect back to')
|
22
|
-
end
|
23
|
-
|
24
|
-
it "must add a required 'port' param" do
|
25
|
-
expect(subject.params[:port]).to_not be_nil
|
26
|
-
expect(subject.params[:port].type).to be_kind_of(Ronin::Core::Params::Types::Integer)
|
27
|
-
expect(subject.params[:port].required?).to be(true)
|
28
|
-
expect(subject.params[:port].desc).to eq('The port to connect back to')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
let(:host) { '127.0.0.1' }
|
33
|
-
let(:port) { 1337 }
|
34
|
-
|
35
|
-
subject do
|
36
|
-
payload_class.new(params: {host: host, port: port})
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#host" do
|
40
|
-
it "must return the 'host' param value" do
|
41
|
-
expect(subject.host).to eq(host)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "#port" do
|
46
|
-
it "must return the 'port' param value" do
|
47
|
-
expect(subject.port).to eq(port)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#perform_prelaunch" do
|
52
|
-
let(:server_socket) { double('TCPServer') }
|
53
|
-
|
54
|
-
it "must create a new TCPServer that listens on #host and #port and set @server" do
|
55
|
-
expect(TCPServer).to receive(:new).with(port,host).and_return(server_socket)
|
56
|
-
expect(server_socket).to receive(:listen).with(1)
|
57
|
-
|
58
|
-
subject.perform_prelaunch
|
59
|
-
|
60
|
-
expect(subject.instance_variable_get(:@server)).to be(server_socket)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#perform_postlaunch" do
|
65
|
-
let(:server_socket) { double('TCPServer') }
|
66
|
-
let(:client_socket) { double('TCPSocket') }
|
67
|
-
|
68
|
-
let(:client_ip) { '1.2.3.4' }
|
69
|
-
let(:client_port) { 8888 }
|
70
|
-
let(:client_addrinfo) { Addrinfo.tcp(client_ip,client_port) }
|
71
|
-
|
72
|
-
before do
|
73
|
-
allow(client_socket).to receive(:remote_address).and_return(client_addrinfo)
|
74
|
-
end
|
75
|
-
|
76
|
-
before { subject.instance_variable_set(:@server,server_socket) }
|
77
|
-
|
78
|
-
it "must print a message about waiting for a connection on host:port, accept a connection, create a new Ronin::PostEx::Sessions::ReverseShell with the new connection, set @session, and print a message about a new connection on host:port" do
|
79
|
-
expect(subject).to receive(:print_info).with("Waiting for connection on #{host}:#{port} ...")
|
80
|
-
expect(server_socket).to receive(:accept).and_return(client_socket)
|
81
|
-
expect(subject).to receive(:print_info).with("Accepted connection from #{client_ip}:#{client_port}!")
|
82
|
-
|
83
|
-
subject.perform_postlaunch
|
84
|
-
|
85
|
-
expect(subject.session).to be_kind_of(Ronin::PostEx::Sessions::ReverseShell)
|
86
|
-
expect(subject.session.io).to be(client_socket)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "#perform_cleanup" do
|
91
|
-
let(:server_socket) { double('TCPServer') }
|
92
|
-
|
93
|
-
before { subject.instance_variable_set(:@server,server_socket) }
|
94
|
-
|
95
|
-
it "must call @server.close and set @server to nil" do
|
96
|
-
expect(server_socket).to receive(:close)
|
97
|
-
|
98
|
-
subject.perform_cleanup
|
99
|
-
|
100
|
-
expect(subject.instance_variable_get(:@server)).to be(nil)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|