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
data/spec/c_payload_spec.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/c_payload'
|
3
|
-
|
4
|
-
describe Ronin::Payloads::CPayload do
|
5
|
-
it "must inherit from Ronin::Payloads::BinaryPayload" do
|
6
|
-
expect(described_class.superclass).to be(Ronin::Payloads::BinaryPayload)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".cc" do
|
10
|
-
subject { described_class }
|
11
|
-
|
12
|
-
before do
|
13
|
-
@cc = ENV['CC']
|
14
|
-
ENV.delete('CC')
|
15
|
-
end
|
16
|
-
|
17
|
-
context "when ENV['CC'] is set" do
|
18
|
-
let(:cc) { 'gcc' }
|
19
|
-
|
20
|
-
before { ENV['CC'] = cc }
|
21
|
-
|
22
|
-
it "must return ENV['CC']" do
|
23
|
-
expect(subject.cc).to eq(cc)
|
24
|
-
end
|
25
|
-
|
26
|
-
after { ENV.delete('CC') }
|
27
|
-
end
|
28
|
-
|
29
|
-
context "when ENV['CC'] is not set" do
|
30
|
-
it "must return 'cc'" do
|
31
|
-
expect(subject.cc).to eq('cc')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
after { ENV['CC'] = @cc if @cc }
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "params" do
|
39
|
-
subject { described_class }
|
40
|
-
|
41
|
-
it "must define a :cc param" do
|
42
|
-
expect(subject.params[:cc]).to_not be_nil
|
43
|
-
end
|
44
|
-
|
45
|
-
it "must default the :cc param to #{described_class}.cc" do
|
46
|
-
expect(subject.params[:cc].default_value).to eq(subject.cc)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#compile" do
|
51
|
-
let(:source_files) { %w[foo.c bar.c baz.c] }
|
52
|
-
let(:output) { 'output' }
|
53
|
-
|
54
|
-
it "must call system with params[:cc], the output and source files" do
|
55
|
-
expect(subject).to receive(:system).with(
|
56
|
-
subject.params[:cc],'-o',output,*source_files
|
57
|
-
).and_return(true)
|
58
|
-
|
59
|
-
subject.compile(*source_files, output: output)
|
60
|
-
end
|
61
|
-
|
62
|
-
context "when the defs: keyword argument is given" do
|
63
|
-
context "and it's an Array" do
|
64
|
-
let(:def1) { 'foo' }
|
65
|
-
let(:def2) { 'bar=baz' }
|
66
|
-
let(:defs) { [def1, def2] }
|
67
|
-
|
68
|
-
it "must append the values with '-D' flags" do
|
69
|
-
expect(subject).to receive(:system).with(
|
70
|
-
subject.params[:cc],
|
71
|
-
'-o', output,
|
72
|
-
"-D#{def1}",
|
73
|
-
"-D#{def2}",
|
74
|
-
*source_files
|
75
|
-
).and_return(true)
|
76
|
-
|
77
|
-
subject.compile(*source_files, output: output, defs: defs)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "and it's a Hash" do
|
82
|
-
let(:name1) { "foo" }
|
83
|
-
let(:value1) { "1" }
|
84
|
-
let(:name2) { "bar" }
|
85
|
-
let(:value2) { "2" }
|
86
|
-
|
87
|
-
let(:def1) { "#{name1}=#{value1}" }
|
88
|
-
let(:def2) { "#{name2}=#{value2}" }
|
89
|
-
let(:defs) { {name1 => value1, name2 => value2} }
|
90
|
-
|
91
|
-
it "must append the values with '-D' flags" do
|
92
|
-
expect(subject).to receive(:system).with(
|
93
|
-
subject.params[:cc],
|
94
|
-
'-o', output,
|
95
|
-
"-D#{def1}",
|
96
|
-
"-D#{def2}",
|
97
|
-
*source_files
|
98
|
-
).and_return(true)
|
99
|
-
|
100
|
-
subject.compile(*source_files, output: output, defs: defs)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "but it's not an Array or a Hash" do
|
105
|
-
let(:defs) { Object.new }
|
106
|
-
|
107
|
-
it do
|
108
|
-
expect {
|
109
|
-
subject.compile(*source_files, output: output, defs: defs)
|
110
|
-
}.to raise_error(ArgumentError,"defs must be either an Array or a Hash: #{defs.inspect}")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "when system() returns false" do
|
116
|
-
let(:source_file) { 'foo.go' }
|
117
|
-
|
118
|
-
it do
|
119
|
-
allow(subject).to receive(:system).and_return(false)
|
120
|
-
|
121
|
-
expect {
|
122
|
-
subject.compile(source_file, output: output)
|
123
|
-
}.to raise_error(Ronin::Payloads::BuildFailed,"cc command failed: #{subject.params[:cc]} -o #{output} #{source_file}")
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context "when system() returns nil" do
|
128
|
-
let(:source_file) { 'foo.go' }
|
129
|
-
|
130
|
-
it do
|
131
|
-
allow(subject).to receive(:system).and_return(nil)
|
132
|
-
|
133
|
-
expect {
|
134
|
-
subject.compile(source_file, output: output)
|
135
|
-
}.to raise_error(Ronin::Payloads::BuildFailed,"cc command not installed")
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/cli/commands/show'
|
3
|
-
|
4
|
-
require 'ronin/payloads/binary_payload'
|
5
|
-
require 'ronin/payloads/asm_payload'
|
6
|
-
require 'ronin/payloads/shellcode_payload'
|
7
|
-
require 'ronin/payloads/c_payload'
|
8
|
-
require 'ronin/payloads/java_payload'
|
9
|
-
require 'ronin/payloads/javascript_payload'
|
10
|
-
require 'ronin/payloads/node_js_payload'
|
11
|
-
require 'ronin/payloads/shell_payload'
|
12
|
-
require 'ronin/payloads/powershell_payload'
|
13
|
-
require 'ronin/payloads/coldfusion_payload'
|
14
|
-
require 'ronin/payloads/php_payload'
|
15
|
-
require 'ronin/payloads/sql_payload'
|
16
|
-
require 'ronin/payloads/html_payload'
|
17
|
-
require 'ronin/payloads/xml_payload'
|
18
|
-
require 'ronin/payloads/mixins/typescript'
|
19
|
-
|
20
|
-
describe Ronin::Payloads::CLI::Commands::Show do
|
21
|
-
end
|
@@ -1,275 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/cli/encoder_methods'
|
3
|
-
require 'ronin/payloads/cli/command'
|
4
|
-
|
5
|
-
describe Ronin::Payloads::CLI::EncoderMethods do
|
6
|
-
module TestEncoderMethods
|
7
|
-
class TestCommand < Ronin::Payloads::CLI::Command
|
8
|
-
include Ronin::Payloads::CLI::EncoderMethods
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:command_class) { TestEncoderMethods::TestCommand }
|
13
|
-
subject { command_class.new }
|
14
|
-
|
15
|
-
describe "#encoder_type" do
|
16
|
-
context "when given a HTMLEncoder class" do
|
17
|
-
module TestEncoderMethods
|
18
|
-
class TestHTMLEncoder < Ronin::Payloads::Encoders::HTMLEncoder
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:klass) { TestEncoderMethods::TestHTMLEncoder }
|
23
|
-
|
24
|
-
it "must return 'html'" do
|
25
|
-
expect(subject.encoder_type(klass)).to eq('html')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "when given a JavaScriptEncoder class" do
|
30
|
-
module TestEncoderMethods
|
31
|
-
class TestJavaScriptEncoder < Ronin::Payloads::Encoders::JavaScriptEncoder
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
let(:klass) { TestEncoderMethods::TestJavaScriptEncoder }
|
36
|
-
|
37
|
-
it "must return 'javascript'" do
|
38
|
-
expect(subject.encoder_type(klass)).to eq('javascript')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when given a ShellEncoder class" do
|
43
|
-
module TestEncoderMethods
|
44
|
-
class TestShellEncoder < Ronin::Payloads::Encoders::ShellEncoder
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
let(:klass) { TestEncoderMethods::TestShellEncoder }
|
49
|
-
|
50
|
-
it "must return 'shell'" do
|
51
|
-
expect(subject.encoder_type(klass)).to eq('shell')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when given a PowerShellEncoder class" do
|
56
|
-
module TestEncoderMethods
|
57
|
-
class TestPowerShellEncoder < Ronin::Payloads::Encoders::PowerShellEncoder
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
let(:klass) { TestEncoderMethods::TestPowerShellEncoder }
|
62
|
-
|
63
|
-
it "must return 'powershell'" do
|
64
|
-
expect(subject.encoder_type(klass)).to eq('powershell')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "when given a SQLgEncoder class" do
|
69
|
-
module TestEncoderMethods
|
70
|
-
class TestSQLgEncoder < Ronin::Payloads::Encoders::SQLEncoder
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
let(:klass) { TestEncoderMethods::TestSQLgEncoder }
|
75
|
-
|
76
|
-
it "must return 'sql'" do
|
77
|
-
expect(subject.encoder_type(klass)).to eq('sql')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "#load_encoder" do
|
83
|
-
let(:encoder_id) { 'html/encode' }
|
84
|
-
|
85
|
-
it "must call Encoders.load_class with the given ID" do
|
86
|
-
expect(Ronin::Payloads::Encoders).to receive(:load_class).with(encoder_id)
|
87
|
-
expect(subject).to_not receive(:exit)
|
88
|
-
|
89
|
-
subject.load_encoder(encoder_id)
|
90
|
-
end
|
91
|
-
|
92
|
-
context "when Ronin::Payloads::Encoders::ClassNotfound is raised" do
|
93
|
-
let(:message) { "class not found" }
|
94
|
-
let(:exception) do
|
95
|
-
Ronin::Payloads::Encoders::ClassNotFound.new(message)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "must print an error message and exit with an error code" do
|
99
|
-
expect(Ronin::Payloads::Encoders).to receive(:load_class).with(encoder_id).and_raise(exception)
|
100
|
-
expect(subject).to receive(:exit).with(1)
|
101
|
-
|
102
|
-
expect {
|
103
|
-
subject.load_encoder(encoder_id)
|
104
|
-
}.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "when another type of exception is raised" do
|
109
|
-
let(:message) { "unexpected error" }
|
110
|
-
let(:exception) { RuntimeError.new(message) }
|
111
|
-
|
112
|
-
it "must print the exception, an error message, and exit with -1" do
|
113
|
-
expect(Ronin::Payloads::Encoders).to receive(:load_class).with(encoder_id).and_raise(exception)
|
114
|
-
expect(subject).to receive(:print_exception).with(exception)
|
115
|
-
expect(subject).to receive(:exit).with(-1)
|
116
|
-
|
117
|
-
expect {
|
118
|
-
subject.load_encoder(encoder_id)
|
119
|
-
}.to output("#{subject.command_name}: an unhandled exception occurred while loading encoder #{encoder_id}#{$/}").to_stderr
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "#load_encoder_from" do
|
125
|
-
let(:file) { '/path/to/html/encode.rb' }
|
126
|
-
|
127
|
-
it "must call Payloads.load_class with the given ID and file" do
|
128
|
-
expect(Ronin::Payloads::Encoders).to receive(:load_class_from_file).with(file)
|
129
|
-
expect(subject).to_not receive(:exit)
|
130
|
-
|
131
|
-
subject.load_encoder_from(file)
|
132
|
-
end
|
133
|
-
|
134
|
-
context "when Ronin::Payloads::ClassNotfound is raised" do
|
135
|
-
let(:message) { "class not found" }
|
136
|
-
let(:exception) do
|
137
|
-
Ronin::Payloads::ClassNotFound.new(message)
|
138
|
-
end
|
139
|
-
|
140
|
-
it "must print an error message and exit with an error code" do
|
141
|
-
expect(Ronin::Payloads::Encoders).to receive(:load_class_from_file).with(file).and_raise(exception)
|
142
|
-
expect(subject).to receive(:exit).with(1)
|
143
|
-
|
144
|
-
expect {
|
145
|
-
subject.load_encoder_from(file)
|
146
|
-
}.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "when another type of exception is raised" do
|
151
|
-
let(:message) { "unexpected error" }
|
152
|
-
let(:exception) { RuntimeError.new(message) }
|
153
|
-
|
154
|
-
it "must print the exception, an error message, and exit with -1" do
|
155
|
-
expect(Ronin::Payloads::Encoders).to receive(:load_class_from_file).with(file).and_raise(exception)
|
156
|
-
expect(subject).to receive(:print_exception).with(exception)
|
157
|
-
expect(subject).to receive(:exit).with(-1)
|
158
|
-
|
159
|
-
expect {
|
160
|
-
subject.load_encoder_from(file)
|
161
|
-
}.to output(
|
162
|
-
"#{subject.command_name}: an unhandled exception occurred while loading encoder from file #{file}#{$/}"
|
163
|
-
).to_stderr
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#initialie_encoder" do
|
169
|
-
let(:encoder_id) { 'test' }
|
170
|
-
let(:encoder_class) { double('Encoder class', id: encoder_id) }
|
171
|
-
|
172
|
-
it "must return a new instance of the given encoder class" do
|
173
|
-
expect(encoder_class).to receive(:new)
|
174
|
-
|
175
|
-
subject.initialize_encoder(encoder_class)
|
176
|
-
end
|
177
|
-
|
178
|
-
context "when additional keyword arguments are given" do
|
179
|
-
let(:kwargs) do
|
180
|
-
{foo: 1, bar: 2}
|
181
|
-
end
|
182
|
-
|
183
|
-
it "must pass them to new()" do
|
184
|
-
expect(encoder_class).to receive(:new).with(**kwargs)
|
185
|
-
|
186
|
-
subject.initialize_encoder(encoder_class,**kwargs)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
context "when a Core::Params::ParamError is raised" do
|
191
|
-
let(:message) { "param foo was not set" }
|
192
|
-
let(:exception) { Ronin::Core::Params::RequiredParam.new(message) }
|
193
|
-
|
194
|
-
it "must print an error message and exit with 1" do
|
195
|
-
expect(encoder_class).to receive(:new).and_raise(exception)
|
196
|
-
expect(subject).to receive(:exit).with(1)
|
197
|
-
|
198
|
-
expect {
|
199
|
-
subject.initialize_encoder(encoder_class)
|
200
|
-
}.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
context "when another type of exception is raised" do
|
205
|
-
let(:message) { "unexpected error" }
|
206
|
-
let(:exception) { RuntimeError.new(message) }
|
207
|
-
|
208
|
-
it "must print the exception, an error message, and exit with -1" do
|
209
|
-
expect(encoder_class).to receive(:new).and_raise(exception)
|
210
|
-
expect(subject).to receive(:print_exception).with(exception)
|
211
|
-
expect(subject).to receive(:exit).with(-1)
|
212
|
-
|
213
|
-
expect {
|
214
|
-
subject.initialize_encoder(encoder_class)
|
215
|
-
}.to output("#{subject.command_name}: an unhandled exception occurred while initializing encoder #{encoder_id}#{$/}").to_stderr
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe "#validate_encoder" do
|
221
|
-
let(:encoder_id) { 'test' }
|
222
|
-
let(:encoder) { double('Encoder instance', class_id: encoder_id) }
|
223
|
-
|
224
|
-
it "must return a new instance of the given encoder class" do
|
225
|
-
expect(encoder).to receive(:validate)
|
226
|
-
|
227
|
-
subject.validate_encoder(encoder)
|
228
|
-
end
|
229
|
-
|
230
|
-
context "when a Core::Params::ParamError is raised" do
|
231
|
-
let(:message) { "param foo was not set" }
|
232
|
-
let(:exception) { Ronin::Core::Params::RequiredParam.new(message) }
|
233
|
-
|
234
|
-
it "must print an error message and exit with 1" do
|
235
|
-
expect(encoder).to receive(:validate).and_raise(exception)
|
236
|
-
expect(subject).to receive(:exit).with(1)
|
237
|
-
|
238
|
-
expect {
|
239
|
-
subject.validate_encoder(encoder)
|
240
|
-
}.to output("#{subject.command_name}: failed to validate the encoder #{encoder_id}: #{message}#{$/}").to_stderr
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
context "when a Ronin::Payloads::Encoders::ValidationError is raised" do
|
245
|
-
let(:message) { "param foo was not set" }
|
246
|
-
let(:exception) do
|
247
|
-
Ronin::Payloads::Encoders::ValidationError.new(message)
|
248
|
-
end
|
249
|
-
|
250
|
-
it "must print an error message and exit with 1" do
|
251
|
-
expect(encoder).to receive(:validate).and_raise(exception)
|
252
|
-
expect(subject).to receive(:exit).with(1)
|
253
|
-
|
254
|
-
expect {
|
255
|
-
subject.validate_encoder(encoder)
|
256
|
-
}.to output("#{subject.command_name}: failed to validate the encoder #{encoder_id}: #{message}#{$/}").to_stderr
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
context "when another type of exception is raised" do
|
261
|
-
let(:message) { "unexpected error" }
|
262
|
-
let(:exception) { RuntimeError.new(message) }
|
263
|
-
|
264
|
-
it "must print the exception, an error message, and exit with -1" do
|
265
|
-
expect(encoder).to receive(:validate).and_raise(exception)
|
266
|
-
expect(subject).to receive(:print_exception).with(exception)
|
267
|
-
expect(subject).to receive(:exit).with(-1)
|
268
|
-
|
269
|
-
expect {
|
270
|
-
subject.validate_encoder(encoder)
|
271
|
-
}.to output("#{subject.command_name}: an unhandled exception occurred while validating the encoder #{encoder_id}#{$/}").to_stderr
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
@@ -1,187 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/cli/format_option'
|
3
|
-
require 'ronin/payloads/cli/command'
|
4
|
-
|
5
|
-
require 'stringio'
|
6
|
-
|
7
|
-
describe Ronin::Payloads::CLI::FormatOption do
|
8
|
-
module TestFormatOption
|
9
|
-
class TestCommand < Ronin::Payloads::CLI::Command
|
10
|
-
include Ronin::Payloads::CLI::FormatOption
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:command_class) { TestFormatOption::TestCommand }
|
15
|
-
subject { command_class.new }
|
16
|
-
|
17
|
-
describe ".included" do
|
18
|
-
subject { command_class }
|
19
|
-
|
20
|
-
it "must add a -F,--format c|shell|js|ruby option" do
|
21
|
-
expect(subject.options[:format]).to_not be(nil)
|
22
|
-
expect(subject.options[:format].short).to eq('-F')
|
23
|
-
expect(subject.options[:format].value).to_not be(nil)
|
24
|
-
expect(subject.options[:format].value.type).to eq(
|
25
|
-
[:hex, :c, :shell, :powershell, :xml, :html, :js, :ruby]
|
26
|
-
)
|
27
|
-
expect(subject.options[:format].desc).to eq('Formats the outputed data')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "parse_options" do
|
32
|
-
context "when given '--format hex'" do
|
33
|
-
before { subject.parse_options(%w[--format hex]) }
|
34
|
-
|
35
|
-
it "must set #format to Ronin::Support::Encoding::Hex.escape" do
|
36
|
-
expect(subject.format).to eq(
|
37
|
-
Ronin::Support::Encoding::Hex.method(:escape)
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when given '--format c'" do
|
43
|
-
before { subject.parse_options(%w[--format c]) }
|
44
|
-
|
45
|
-
it "must set #format to Ronin::Support::Encoding::C.quote" do
|
46
|
-
expect(subject.format).to eq(
|
47
|
-
Ronin::Support::Encoding::C.method(:quote)
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when given '--format shell'" do
|
53
|
-
before { subject.parse_options(%w[--format shell]) }
|
54
|
-
|
55
|
-
it "must set #format to Ronin::Support::Encoding::Shell.quote" do
|
56
|
-
expect(subject.format).to eq(
|
57
|
-
Ronin::Support::Encoding::Shell.method(:quote)
|
58
|
-
)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "when given '--format powershell'" do
|
63
|
-
before { subject.parse_options(%w[--format powershell]) }
|
64
|
-
|
65
|
-
it "must set #format to Ronin::Support::Encoding::PowerShell.quote" do
|
66
|
-
expect(subject.format).to eq(
|
67
|
-
Ronin::Support::Encoding::PowerShell.method(:quote)
|
68
|
-
)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "when given '--format xml'" do
|
73
|
-
before { subject.parse_options(%w[--format xml]) }
|
74
|
-
|
75
|
-
it "must set #format to Ronin::Support::Encoding::XML.escape" do
|
76
|
-
expect(subject.format).to eq(
|
77
|
-
Ronin::Support::Encoding::XML.method(:escape)
|
78
|
-
)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "when given '--format html'" do
|
83
|
-
before { subject.parse_options(%w[--format html]) }
|
84
|
-
|
85
|
-
it "must set #format to Ronin::Support::Encoding::HTML.escape" do
|
86
|
-
expect(subject.format).to eq(
|
87
|
-
Ronin::Support::Encoding::HTML.method(:escape)
|
88
|
-
)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "when given '--format js'" do
|
93
|
-
before { subject.parse_options(%w[--format js]) }
|
94
|
-
|
95
|
-
it "must set #format to Ronin::Support::Encoding::JS.quote" do
|
96
|
-
expect(subject.format).to eq(
|
97
|
-
Ronin::Support::Encoding::JS.method(:quote)
|
98
|
-
)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "when given '--format ruby'" do
|
103
|
-
before { subject.parse_options(%w[--format ruby]) }
|
104
|
-
|
105
|
-
it "must set #format to Ronin::Support::Encoding::Ruby.quote" do
|
106
|
-
expect(subject.format).to eq(
|
107
|
-
Ronin::Support::Encoding::Ruby.method(:quote)
|
108
|
-
)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe "#format_data" do
|
114
|
-
let(:data) { "hello world" }
|
115
|
-
|
116
|
-
context "when #format is set" do
|
117
|
-
before { subject.parse_options(%w[--format html]) }
|
118
|
-
|
119
|
-
it "must call #encode on the #format" do
|
120
|
-
expect(subject.format_data(data)).to eq(
|
121
|
-
Ronin::Support::Encoding::HTML.escape(data)
|
122
|
-
)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context "when #format is not set" do
|
127
|
-
it "must return the data" do
|
128
|
-
expect(subject.format_data(data)).to eq(data)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe "#print_data" do
|
134
|
-
let(:data) { "hello world" }
|
135
|
-
|
136
|
-
let(:stdout) { StringIO.new }
|
137
|
-
subject { command_class.new(stdout: stdout) }
|
138
|
-
|
139
|
-
context "when stdout is a TTY" do
|
140
|
-
before { expect(stdout).to receive(:tty?).and_return(true) }
|
141
|
-
|
142
|
-
context "when #format is set" do
|
143
|
-
before { subject.parse_options(%w[--format html]) }
|
144
|
-
|
145
|
-
it "must print the formatted data" do
|
146
|
-
subject.print_data(data)
|
147
|
-
|
148
|
-
expect(stdout.string).to eq(
|
149
|
-
"#{Ronin::Support::Encoding::HTML.escape(data)}#{$/}"
|
150
|
-
)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context "when #format is not set" do
|
155
|
-
it "must print the unformatted data" do
|
156
|
-
subject.print_data(data)
|
157
|
-
|
158
|
-
expect(stdout.string).to eq("#{data}#{$/}")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context "when stdout not is a TTY" do
|
164
|
-
before { expect(stdout).to receive(:tty?).and_return(false) }
|
165
|
-
|
166
|
-
context "when #format is set" do
|
167
|
-
before { subject.parse_options(%w[--format html]) }
|
168
|
-
|
169
|
-
it "must print the formatted data without a newline" do
|
170
|
-
subject.print_data(data)
|
171
|
-
|
172
|
-
expect(stdout.string).to eq(
|
173
|
-
"#{Ronin::Support::Encoding::HTML.escape(data)}"
|
174
|
-
)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context "when #format is not set" do
|
179
|
-
it "must print the unformatted data without a newline" do
|
180
|
-
subject.print_data(data)
|
181
|
-
|
182
|
-
expect(stdout.string).to eq(data)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/payloads/cli/payload_command'
|
3
|
-
require 'ronin/payloads/payload'
|
4
|
-
|
5
|
-
describe Ronin::Payloads::CLI::PayloadCommand do
|
6
|
-
module TestPayloadCommand
|
7
|
-
class TestPayload < Ronin::Payloads::Payload
|
8
|
-
register 'test_payload_command'
|
9
|
-
end
|
10
|
-
|
11
|
-
class TestCommand < Ronin::Payloads::CLI::PayloadCommand
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:payload_class) { TestPayloadCommand::TestPayload }
|
16
|
-
let(:command_class) { TestPayloadCommand::TestCommand }
|
17
|
-
subject { command_class.new }
|
18
|
-
|
19
|
-
describe "#load_payload" do
|
20
|
-
let(:id) { payload_class.id }
|
21
|
-
|
22
|
-
before do
|
23
|
-
expect(Ronin::Payloads).to receive(:load_class).with(id).and_return(payload_class)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "must load the payload class and return the payload class" do
|
27
|
-
expect(subject.load_payload(id)).to be(payload_class)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "must also set #payload_class" do
|
31
|
-
subject.load_payload(id)
|
32
|
-
|
33
|
-
expect(subject.payload_class).to be(payload_class)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#load_payload_from" do
|
38
|
-
let(:file) { "path/to/payload/file.rb" }
|
39
|
-
|
40
|
-
before do
|
41
|
-
expect(Ronin::Payloads).to receive(:load_class_from_file).with(file).and_return(payload_class)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "must load the payload class and return the payload class" do
|
45
|
-
expect(subject.load_payload_from(file)).to be(payload_class)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "must also set #payload_class" do
|
49
|
-
subject.load_payload_from(file)
|
50
|
-
|
51
|
-
expect(subject.payload_class).to be(payload_class)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "#initialize_payload" do
|
56
|
-
before { subject.load_payload(payload_class.id) }
|
57
|
-
|
58
|
-
it "must initialize a new payload object using #payload_class" do
|
59
|
-
expect(subject.initialize_payload).to be_kind_of(payload_class)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "must also set #payload" do
|
63
|
-
subject.initialize_payload
|
64
|
-
|
65
|
-
expect(subject.payload).to be_kind_of(payload_class)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|