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.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/.yardopts +1 -1
  4. data/README.md +4 -3
  5. data/bin/ronin-payloads +1 -1
  6. data/gemspec.yml +8 -7
  7. data/lib/ronin/payloads/asm_payload.rb +1 -1
  8. data/lib/ronin/payloads/binary_payload.rb +1 -1
  9. data/lib/ronin/payloads/builtin/cmd/awk/reverse_shell.rb +1 -1
  10. data/lib/ronin/payloads/builtin/cmd/bash/reverse_shell.rb +1 -1
  11. data/lib/ronin/payloads/builtin/cmd/lua/reverse_shell.rb +1 -1
  12. data/lib/ronin/payloads/builtin/cmd/node/reverse_shell.rb +1 -1
  13. data/lib/ronin/payloads/builtin/cmd/openssl/reverse_shell.rb +1 -1
  14. data/lib/ronin/payloads/builtin/cmd/perl/reverse_shell.rb +1 -1
  15. data/lib/ronin/payloads/builtin/cmd/php/reverse_shell.rb +1 -1
  16. data/lib/ronin/payloads/builtin/cmd/powershell/reverse_shell.rb +1 -1
  17. data/lib/ronin/payloads/builtin/cmd/python/reverse_shell.rb +1 -1
  18. data/lib/ronin/payloads/builtin/cmd/ruby/reverse_shell.rb +1 -1
  19. data/lib/ronin/payloads/builtin/java/reverse_shell.rb +1 -1
  20. data/lib/ronin/payloads/builtin/php/cmd_exec.rb +1 -1
  21. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/bind_shell.rb +1 -1
  22. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/exec_shell.rb +1 -1
  23. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/reverse_shell.rb +1 -1
  24. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86_64/exec_shell.rb +1 -1
  25. data/lib/ronin/payloads/builtin/shellcode/linux/arm/bind_shell.rb +1 -1
  26. data/lib/ronin/payloads/builtin/shellcode/linux/arm/exec_shell.rb +1 -1
  27. data/lib/ronin/payloads/builtin/shellcode/linux/arm/reverse_shell.rb +1 -1
  28. data/lib/ronin/payloads/builtin/shellcode/linux/mips/bind_shell.rb +1 -1
  29. data/lib/ronin/payloads/builtin/shellcode/linux/mips/exec_shell.rb +1 -1
  30. data/lib/ronin/payloads/builtin/shellcode/linux/mips/reverse_shell.rb +1 -1
  31. data/lib/ronin/payloads/builtin/shellcode/linux/ppc/exec_shell.rb +1 -1
  32. data/lib/ronin/payloads/builtin/shellcode/linux/ppc/reverse_shell.rb +1 -1
  33. data/lib/ronin/payloads/builtin/shellcode/linux/x86/bind_shell.rb +2 -2
  34. data/lib/ronin/payloads/builtin/shellcode/linux/x86/exec_shell.rb +1 -1
  35. data/lib/ronin/payloads/builtin/shellcode/linux/x86/reverse_shell.rb +1 -1
  36. data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/bind_shell.rb +2 -2
  37. data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/exec_shell.rb +1 -1
  38. data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/reverse_shell.rb +1 -1
  39. data/lib/ronin/payloads/builtin/shellcode/macos/x86_64/exec_shell.rb +1 -1
  40. data/lib/ronin/payloads/builtin/shellcode/macos/x86_64/reverse_shell.rb +1 -1
  41. data/lib/ronin/payloads/builtin/shellcode/netbsd/x86/exec_shell.rb +1 -1
  42. data/lib/ronin/payloads/builtin/shellcode/netbsd/x86/reverse_shell.rb +1 -1
  43. data/lib/ronin/payloads/builtin/shellcode/openbsd/x86/bind_shell.rb +1 -1
  44. data/lib/ronin/payloads/builtin/shellcode/openbsd/x86/exec_shell.rb +1 -1
  45. data/lib/ronin/payloads/builtin/shellcode/windows/x86_64/cmd.rb +1 -1
  46. data/lib/ronin/payloads/builtin/test/open_redirect.rb +1 -1
  47. data/lib/ronin/payloads/builtin/test/xss.rb +1 -1
  48. data/lib/ronin/payloads/c_payload.rb +1 -1
  49. data/lib/ronin/payloads/cli/command.rb +1 -1
  50. data/lib/ronin/payloads/cli/commands/build.rb +1 -1
  51. data/lib/ronin/payloads/cli/commands/encode.rb +1 -1
  52. data/lib/ronin/payloads/cli/commands/encoder.rb +1 -1
  53. data/lib/ronin/payloads/cli/commands/encoders.rb +2 -2
  54. data/lib/ronin/payloads/cli/commands/irb.rb +1 -1
  55. data/lib/ronin/payloads/cli/commands/launch.rb +1 -1
  56. data/lib/ronin/payloads/cli/commands/list.rb +1 -1
  57. data/lib/ronin/payloads/cli/commands/new.rb +3 -3
  58. data/lib/ronin/payloads/cli/commands/show.rb +2 -2
  59. data/lib/ronin/payloads/cli/encoder_methods.rb +1 -1
  60. data/lib/ronin/payloads/cli/format_option.rb +1 -1
  61. data/lib/ronin/payloads/cli/generator/payload_types.rb +3 -3
  62. data/lib/ronin/payloads/cli/payload_command.rb +1 -1
  63. data/lib/ronin/payloads/cli/payload_methods.rb +1 -1
  64. data/lib/ronin/payloads/cli/printing.rb +1 -1
  65. data/lib/ronin/payloads/cli/ruby_shell.rb +1 -1
  66. data/lib/ronin/payloads/cli.rb +6 -1
  67. data/lib/ronin/payloads/coldfusion_payload.rb +1 -1
  68. data/lib/ronin/payloads/command_payload.rb +1 -1
  69. data/lib/ronin/payloads/encoders/builtin/html/encode.rb +1 -1
  70. data/lib/ronin/payloads/encoders/builtin/js/encode.rb +1 -1
  71. data/lib/ronin/payloads/encoders/builtin/powershell/encode.rb +1 -1
  72. data/lib/ronin/payloads/encoders/builtin/shell/encode.rb +1 -1
  73. data/lib/ronin/payloads/encoders/builtin/sql/encode.rb +1 -1
  74. data/lib/ronin/payloads/encoders/builtin/xml/encode.rb +1 -1
  75. data/lib/ronin/payloads/encoders/encoder.rb +1 -1
  76. data/lib/ronin/payloads/encoders/exceptions.rb +1 -1
  77. data/lib/ronin/payloads/encoders/html_encoder.rb +1 -1
  78. data/lib/ronin/payloads/encoders/javascript_encoder.rb +1 -1
  79. data/lib/ronin/payloads/encoders/pipeline.rb +2 -2
  80. data/lib/ronin/payloads/encoders/powershell_encoder.rb +1 -1
  81. data/lib/ronin/payloads/encoders/registry.rb +1 -1
  82. data/lib/ronin/payloads/encoders/shell_encoder.rb +1 -1
  83. data/lib/ronin/payloads/encoders/sql_encoder.rb +1 -1
  84. data/lib/ronin/payloads/encoders/xml_encoder.rb +1 -1
  85. data/lib/ronin/payloads/encoders.rb +1 -1
  86. data/lib/ronin/payloads/exceptions.rb +1 -1
  87. data/lib/ronin/payloads/go_payload.rb +1 -1
  88. data/lib/ronin/payloads/html_payload.rb +1 -1
  89. data/lib/ronin/payloads/java_payload.rb +1 -1
  90. data/lib/ronin/payloads/javascript_payload.rb +1 -1
  91. data/lib/ronin/payloads/jsp_payload.rb +1 -1
  92. data/lib/ronin/payloads/metadata/arch.rb +1 -1
  93. data/lib/ronin/payloads/metadata/os.rb +1 -1
  94. data/lib/ronin/payloads/mixins/binary.rb +1 -1
  95. data/lib/ronin/payloads/mixins/bind_shell.rb +1 -1
  96. data/lib/ronin/payloads/mixins/build_dir.rb +1 -1
  97. data/lib/ronin/payloads/mixins/erb.rb +1 -1
  98. data/lib/ronin/payloads/mixins/network.rb +1 -1
  99. data/lib/ronin/payloads/mixins/post_ex.rb +1 -1
  100. data/lib/ronin/payloads/mixins/resolve_host.rb +1 -1
  101. data/lib/ronin/payloads/mixins/reverse_shell.rb +1 -1
  102. data/lib/ronin/payloads/mixins/tempfile.rb +1 -1
  103. data/lib/ronin/payloads/mixins/typescript.rb +1 -1
  104. data/lib/ronin/payloads/node_js_payload.rb +1 -1
  105. data/lib/ronin/payloads/payload.rb +1 -1
  106. data/lib/ronin/payloads/php_payload.rb +1 -1
  107. data/lib/ronin/payloads/powershell_payload.rb +1 -1
  108. data/lib/ronin/payloads/python_payload.rb +1 -1
  109. data/lib/ronin/payloads/registry.rb +1 -1
  110. data/lib/ronin/payloads/root.rb +1 -1
  111. data/lib/ronin/payloads/ruby_payload.rb +1 -1
  112. data/lib/ronin/payloads/rust_payload.rb +1 -1
  113. data/lib/ronin/payloads/shell_payload.rb +1 -1
  114. data/lib/ronin/payloads/shellcode/bind_shell_payload.rb +1 -1
  115. data/lib/ronin/payloads/shellcode/exec_shell_payload.rb +1 -1
  116. data/lib/ronin/payloads/shellcode/reverse_shell_payload.rb +1 -1
  117. data/lib/ronin/payloads/shellcode_payload.rb +1 -1
  118. data/lib/ronin/payloads/sql_payload.rb +1 -1
  119. data/lib/ronin/payloads/url_payload.rb +2 -2
  120. data/lib/ronin/payloads/version.rb +2 -2
  121. data/lib/ronin/payloads/xml_payload.rb +1 -1
  122. data/lib/ronin/payloads.rb +1 -1
  123. data/ronin-payloads.gemspec +2 -1
  124. metadata +16 -215
  125. data/spec/asm_payload_spec.rb +0 -114
  126. data/spec/binary_payload_spec.rb +0 -8
  127. data/spec/builtin/cmd/awk/reverse_shell_spec.rb +0 -38
  128. data/spec/builtin/cmd/bash/reverse_shell_spec.rb +0 -36
  129. data/spec/builtin/cmd/lua/reverse_shell_spec.rb +0 -38
  130. data/spec/builtin/cmd/node/reverse_shell_spec.rb +0 -36
  131. data/spec/builtin/cmd/openssl/reverse_shell_spec.rb +0 -38
  132. data/spec/builtin/cmd/perl/reverse_shell_spec.rb +0 -38
  133. data/spec/builtin/cmd/php/reverse_shell_spec.rb +0 -38
  134. data/spec/builtin/cmd/powershell/reverse_shell_spec.rb +0 -38
  135. data/spec/builtin/cmd/python/reverse_shell_spec.rb +0 -38
  136. data/spec/builtin/cmd/ruby/reverse_shell_spec.rb +0 -38
  137. data/spec/builtin/java/reverse_shell_spec.rb +0 -103
  138. data/spec/builtin/php/cmd_exec.rb +0 -52
  139. data/spec/builtin/shellcode/freebsd/x86/bind_shell_spec.rb +0 -58
  140. data/spec/builtin/shellcode/freebsd/x86/exec_shell_spec.rb +0 -46
  141. data/spec/builtin/shellcode/freebsd/x86/reverse_shell_spec.rb +0 -63
  142. data/spec/builtin/shellcode/freebsd/x86_64/exec_shell_spec.rb +0 -46
  143. data/spec/builtin/shellcode/linux/arm/bind_shell_spec.rb +0 -62
  144. data/spec/builtin/shellcode/linux/arm/exec_shell_spec.rb +0 -46
  145. data/spec/builtin/shellcode/linux/arm/reverse_shell_spec.rb +0 -58
  146. data/spec/builtin/shellcode/linux/mips/bind_shell_spec.rb +0 -60
  147. data/spec/builtin/shellcode/linux/mips/exec_shell_spec.rb +0 -46
  148. data/spec/builtin/shellcode/linux/mips/reverse_shell_spec.rb +0 -58
  149. data/spec/builtin/shellcode/linux/ppc/exec_shell_spec.rb +0 -46
  150. data/spec/builtin/shellcode/linux/ppc/reverse_shell_spec.rb +0 -87
  151. data/spec/builtin/shellcode/linux/x86/bind_shell_spec.rb +0 -60
  152. data/spec/builtin/shellcode/linux/x86/exec_shell_spec.rb +0 -46
  153. data/spec/builtin/shellcode/linux/x86/reverse_shell_spec.rb +0 -58
  154. data/spec/builtin/shellcode/linux/x86_64/bind_shell_spec.rb +0 -60
  155. data/spec/builtin/shellcode/linux/x86_64/exec_shell_spec.rb +0 -46
  156. data/spec/builtin/shellcode/linux/x86_64/reverse_shell_spec.rb +0 -58
  157. data/spec/builtin/shellcode/macos/x86_64/exec_shell_spec.rb +0 -46
  158. data/spec/builtin/shellcode/macos/x86_64/reverse_shell_spec.rb +0 -58
  159. data/spec/builtin/shellcode/netbsd/x86/exec_shell_spec.rb +0 -46
  160. data/spec/builtin/shellcode/netbsd/x86/reverse_shell_spec.rb +0 -63
  161. data/spec/builtin/shellcode/openbsd/x86/bind_shell_spec.rb +0 -58
  162. data/spec/builtin/shellcode/openbsd/x86/exec_shell_spec.rb +0 -46
  163. data/spec/builtin/shellcode/windows/x86_64/cmd_spec.rb +0 -54
  164. data/spec/builtin/test/open_redirect_spec.rb +0 -24
  165. data/spec/builtin/test/xss_spec.rb +0 -24
  166. data/spec/c_payload_spec.rb +0 -139
  167. data/spec/cli/commands/show_spec.rb +0 -21
  168. data/spec/cli/encoder_methods_spec.rb +0 -275
  169. data/spec/cli/format_option_spec.rb +0 -187
  170. data/spec/cli/payload_command_spec.rb +0 -68
  171. data/spec/cli/payload_methods_spec.rb +0 -208
  172. data/spec/cli/printing_spec.rb +0 -65
  173. data/spec/cli/ruby_shell_spec.rb +0 -14
  174. data/spec/coldfusion_payload_spec.rb +0 -8
  175. data/spec/command_payload_spec.rb +0 -8
  176. data/spec/encoders/builtin/html/encode_spec.rb +0 -17
  177. data/spec/encoders/builtin/js/encode_spec.rb +0 -17
  178. data/spec/encoders/builtin/powershell/encode_spec.rb +0 -17
  179. data/spec/encoders/builtin/shell/encode_spec.rb +0 -17
  180. data/spec/encoders/builtin/sql/encode_spec.rb +0 -17
  181. data/spec/encoders/builtin/xml/encode_spec.rb +0 -17
  182. data/spec/encoders/encoder_spec.rb +0 -62
  183. data/spec/encoders/html_encoder_spec.rb +0 -8
  184. data/spec/encoders/javascript_encoder_spec.rb +0 -8
  185. data/spec/encoders/pipeline_spec.rb +0 -153
  186. data/spec/encoders/powershell_encoder_spec.rb +0 -8
  187. data/spec/encoders/shell_encoder_spec.rb +0 -8
  188. data/spec/encoders/sql_encoder_spec.rb +0 -8
  189. data/spec/encoders/xml_encoder_spec.rb +0 -8
  190. data/spec/encoders_spec.rb +0 -25
  191. data/spec/go_payload_spec.rb +0 -56
  192. data/spec/helpers/encoders.rb +0 -9
  193. data/spec/helpers/payloads.rb +0 -9
  194. data/spec/helpers/scripts/payloads/simple.rb +0 -22
  195. data/spec/html_payload_spec.rb +0 -12
  196. data/spec/java_payload_spec.rb +0 -97
  197. data/spec/javascript_payload_spec.rb +0 -12
  198. data/spec/jsp_payload_spec.rb +0 -8
  199. data/spec/metadata/arch_spec.rb +0 -82
  200. data/spec/metadata/os_spec.rb +0 -164
  201. data/spec/mixins/binary_spec.rb +0 -129
  202. data/spec/mixins/bind_shell_spec.rb +0 -73
  203. data/spec/mixins/build_dir.rb +0 -64
  204. data/spec/mixins/erb_spec.rb +0 -19
  205. data/spec/mixins/network_spec.rb +0 -75
  206. data/spec/mixins/post_ex_spec.rb +0 -40
  207. data/spec/mixins/resolve_host_spec.rb +0 -322
  208. data/spec/mixins/reverse_shell_spec.rb +0 -103
  209. data/spec/mixins/tempfile_spec.rb +0 -97
  210. data/spec/mixins/typescript_spec.rb +0 -92
  211. data/spec/node_js_payload_spec.rb +0 -8
  212. data/spec/payload_spec.rb +0 -288
  213. data/spec/payloads_spec.rb +0 -29
  214. data/spec/php_payload_spec.rb +0 -8
  215. data/spec/powershell_payload_spec.rb +0 -16
  216. data/spec/python_payload_spec.rb +0 -8
  217. data/spec/ruby_payload_spec.rb +0 -8
  218. data/spec/rust_payload_spec.rb +0 -116
  219. data/spec/shell_payload_spec.rb +0 -16
  220. data/spec/shellcode/bind_shell_payload_spec.rb +0 -42
  221. data/spec/shellcode/exec_shell_payload_spec.rb +0 -8
  222. data/spec/shellcode/reverse_shell_payload_spec.rb +0 -136
  223. data/spec/shellcode_payload_spec.rb +0 -38
  224. data/spec/spec_helper.rb +0 -7
  225. data/spec/sql_payload_spec.rb +0 -12
  226. data/spec/url_payload_spec.rb +0 -72
  227. data/spec/xml_payload_spec.rb +0 -12
@@ -1,208 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/cli/payload_methods'
3
- require 'ronin/payloads/cli/command'
4
-
5
- describe Ronin::Payloads::CLI::PayloadMethods do
6
- module TestPayloadMethods
7
- class TestCommand < Ronin::Payloads::CLI::Command
8
- include Ronin::Payloads::CLI::PayloadMethods
9
- end
10
- end
11
-
12
- let(:command_class) { TestPayloadMethods::TestCommand }
13
- subject { command_class.new }
14
-
15
- describe "#load_payload" do
16
- let(:payload_id) { 'html/encode' }
17
-
18
- it "must call Payloads.load_class with the given ID" do
19
- expect(Ronin::Payloads).to receive(:load_class).with(payload_id)
20
- expect(subject).to_not receive(:exit)
21
-
22
- subject.load_payload(payload_id)
23
- end
24
-
25
- context "when Ronin::Payloads::ClassNotfound is raised" do
26
- let(:message) { "class not found" }
27
- let(:exception) do
28
- Ronin::Payloads::ClassNotFound.new(message)
29
- end
30
-
31
- it "must print an error message and exit with an error code" do
32
- expect(Ronin::Payloads).to receive(:load_class).with(payload_id).and_raise(exception)
33
- expect(subject).to receive(:exit).with(1)
34
-
35
- expect {
36
- subject.load_payload(payload_id)
37
- }.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
38
- end
39
- end
40
-
41
- context "when another type of exception is raised" do
42
- let(:message) { "unexpected error" }
43
- let(:exception) { RuntimeError.new(message) }
44
-
45
- it "must print the exception, an error message, and exit with -1" do
46
- expect(Ronin::Payloads).to receive(:load_class).with(payload_id).and_raise(exception)
47
- expect(subject).to receive(:print_exception).with(exception)
48
- expect(subject).to receive(:exit).with(-1)
49
-
50
- expect {
51
- subject.load_payload(payload_id)
52
- }.to output("#{subject.command_name}: an unhandled exception occurred while loading payload #{payload_id}#{$/}").to_stderr
53
- end
54
- end
55
- end
56
-
57
- describe "#load_payload_from" do
58
- let(:file) { '/path/to/html/encode.rb' }
59
-
60
- it "must call Payloads.load_class with the given ID and file" do
61
- expect(Ronin::Payloads).to receive(:load_class_from_file).with(file)
62
- expect(subject).to_not receive(:exit)
63
-
64
- subject.load_payload_from(file)
65
- end
66
-
67
- context "when Ronin::Payloads::ClassNotfound is raised" do
68
- let(:message) { "class not found" }
69
- let(:exception) do
70
- Ronin::Payloads::ClassNotFound.new(message)
71
- end
72
-
73
- it "must print an error message and exit with an error code" do
74
- expect(Ronin::Payloads).to receive(:load_class_from_file).with(file).and_raise(exception)
75
- expect(subject).to receive(:exit).with(1)
76
-
77
- expect {
78
- subject.load_payload_from(file)
79
- }.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
80
- end
81
- end
82
-
83
- context "when another type of exception is raised" do
84
- let(:message) { "unexpected error" }
85
- let(:exception) { RuntimeError.new(message) }
86
-
87
- it "must print the exception, an error message, and exit with -1" do
88
- expect(Ronin::Payloads).to receive(:load_class_from_file).with(file).and_raise(exception)
89
- expect(subject).to receive(:print_exception).with(exception)
90
- expect(subject).to receive(:exit).with(-1)
91
-
92
- expect {
93
- subject.load_payload_from(file)
94
- }.to output(
95
- "#{subject.command_name}: an unhandled exception occurred while loading payload from file #{file}#{$/}"
96
- ).to_stderr
97
- end
98
- end
99
- end
100
-
101
- describe "#initialie_payload" do
102
- let(:payload_id) { 'test' }
103
- let(:payload_class) { double('Encoder class', id: payload_id) }
104
-
105
- it "must return a new instance of the given payload class" do
106
- expect(payload_class).to receive(:new)
107
-
108
- subject.initialize_payload(payload_class)
109
- end
110
-
111
- context "when additional keyword arguments are given" do
112
- let(:kwargs) do
113
- {foo: 1, bar: 2}
114
- end
115
-
116
- it "must pass them to new()" do
117
- expect(payload_class).to receive(:new).with(**kwargs)
118
-
119
- subject.initialize_payload(payload_class,**kwargs)
120
- end
121
- end
122
-
123
- context "when a Core::Params::ParamError is raised" do
124
- let(:message) { "param foo was not set" }
125
- let(:exception) { Ronin::Core::Params::RequiredParam.new(message) }
126
-
127
- it "must print an error message and exit with 1" do
128
- expect(payload_class).to receive(:new).and_raise(exception)
129
- expect(subject).to receive(:exit).with(1)
130
-
131
- expect {
132
- subject.initialize_payload(payload_class)
133
- }.to output("#{subject.command_name}: #{message}#{$/}").to_stderr
134
- end
135
- end
136
-
137
- context "when another type of exception is raised" do
138
- let(:message) { "unexpected error" }
139
- let(:exception) { RuntimeError.new(message) }
140
-
141
- it "must print the exception, an error message, and exit with -1" do
142
- expect(payload_class).to receive(:new).and_raise(exception)
143
- expect(subject).to receive(:print_exception).with(exception)
144
- expect(subject).to receive(:exit).with(-1)
145
-
146
- expect {
147
- subject.initialize_payload(payload_class)
148
- }.to output("#{subject.command_name}: an unhandled exception occurred while initializing payload #{payload_id}#{$/}").to_stderr
149
- end
150
- end
151
- end
152
-
153
- describe "#validate_payload" do
154
- let(:payload_id) { 'test' }
155
- let(:payload) { double('Encoder instance', class_id: payload_id) }
156
-
157
- it "must call #perform_validate on #payload" do
158
- expect(payload).to receive(:perform_validate)
159
-
160
- subject.validate_payload(payload)
161
- end
162
-
163
- context "when a Core::Params::ParamError is raised" do
164
- let(:message) { "param foo was not set" }
165
- let(:exception) { Ronin::Core::Params::RequiredParam.new(message) }
166
-
167
- it "must print an error message and exit with 1" do
168
- expect(payload).to receive(:perform_validate).and_raise(exception)
169
- expect(subject).to receive(:exit).with(1)
170
-
171
- expect {
172
- subject.validate_payload(payload)
173
- }.to output("#{subject.command_name}: failed to validate the payload #{payload_id}: #{message}#{$/}").to_stderr
174
- end
175
- end
176
-
177
- context "when a Ronin::Payloads::ValidationError is raised" do
178
- let(:message) { "param foo was not set" }
179
- let(:exception) do
180
- Ronin::Payloads::ValidationError.new(message)
181
- end
182
-
183
- it "must print an error message and exit with 1" do
184
- expect(payload).to receive(:perform_validate).and_raise(exception)
185
- expect(subject).to receive(:exit).with(1)
186
-
187
- expect {
188
- subject.validate_payload(payload)
189
- }.to output("#{subject.command_name}: failed to validate the payload #{payload_id}: #{message}#{$/}").to_stderr
190
- end
191
- end
192
-
193
- context "when another type of exception is raised" do
194
- let(:message) { "unexpected error" }
195
- let(:exception) { RuntimeError.new(message) }
196
-
197
- it "must print the exception, an error message, and exit with -1" do
198
- expect(payload).to receive(:perform_validate).and_raise(exception)
199
- expect(subject).to receive(:print_exception).with(exception)
200
- expect(subject).to receive(:exit).with(-1)
201
-
202
- expect {
203
- subject.validate_payload(payload)
204
- }.to output("#{subject.command_name}: an unhandled exception occurred while validating the payload #{payload_id}#{$/}").to_stderr
205
- end
206
- end
207
- end
208
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/cli/printing'
3
- require 'ronin/payloads/cli/command'
4
-
5
- require 'ronin/payloads/binary_payload'
6
- require 'ronin/payloads/asm_payload'
7
- require 'ronin/payloads/shellcode_payload'
8
- require 'ronin/payloads/c_payload'
9
- require 'ronin/payloads/go_payload'
10
- require 'ronin/payloads/rust_payload'
11
- require 'ronin/payloads/java_payload'
12
- require 'ronin/payloads/javascript_payload'
13
- require 'ronin/payloads/node_js_payload'
14
- require 'ronin/payloads/command_payload'
15
- require 'ronin/payloads/shell_payload'
16
- require 'ronin/payloads/powershell_payload'
17
- require 'ronin/payloads/coldfusion_payload'
18
- require 'ronin/payloads/php_payload'
19
- require 'ronin/payloads/sql_payload'
20
- require 'ronin/payloads/html_payload'
21
- require 'ronin/payloads/xml_payload'
22
- require 'ronin/payloads/mixins/typescript'
23
-
24
- describe Ronin::Payloads::CLI::Printing do
25
- module TestCLIPrinting
26
- class TestCommand < Ronin::Payloads::CLI::Command
27
- include Ronin::Payloads::CLI::Printing
28
- end
29
- end
30
-
31
- let(:command_class) { TestCLIPrinting::TestCommand }
32
- subject { command_class.new }
33
-
34
- describe "#payload_type" do
35
- {
36
- Ronin::Payloads::HTMLPayload => 'HTML',
37
- Ronin::Payloads::XMLPayload => 'XML',
38
- Ronin::Payloads::JavaScriptPayload => 'JavaScript',
39
- Ronin::Payloads::NodeJSPayload => 'Node.js',
40
- Ronin::Payloads::SQLPayload => 'SQL',
41
- Ronin::Payloads::CommandPayload => 'Command',
42
- Ronin::Payloads::ShellPayload => 'Shell',
43
- Ronin::Payloads::PowerShellPayload => 'PowerShell',
44
- Ronin::Payloads::CPayload => 'C',
45
- Ronin::Payloads::GoPayload => 'Go',
46
- Ronin::Payloads::RustPayload => 'Rust',
47
- Ronin::Payloads::JavaPayload => 'Java',
48
- Ronin::Payloads::ColdFusionPayload => 'ColdFusion',
49
- Ronin::Payloads::PHPPayload => 'PHP',
50
- Ronin::Payloads::ASMPayload => 'ASM',
51
- Ronin::Payloads::ShellcodePayload => 'Shellcode',
52
- Ronin::Payloads::BinaryPayload => 'Binary',
53
- Ronin::Payloads::Payload => 'Custom'
54
- }.each do |payload_class,type|
55
- context "when the class inherits from #{payload_class}" do
56
- let(:klass) { Class.new(payload_class) }
57
- let(:type) { type }
58
-
59
- it "must return '#{type}'" do
60
- expect(subject.payload_type(klass)).to eq(type)
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/cli/ruby_shell'
3
-
4
- describe Ronin::Payloads::CLI::RubyShell do
5
- describe "#initialize" do
6
- it "must default #name to 'ronin-payloads'" do
7
- expect(subject.name).to eq('ronin-payloads')
8
- end
9
-
10
- it "must default #context to Ronin::Payloads" do
11
- expect(subject.context).to be(Ronin::Payloads)
12
- end
13
- end
14
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/coldfusion_payload'
3
-
4
- describe Ronin::Payloads::ColdFusionPayload do
5
- it "must inherit from Ronin::Payloads::Payload" do
6
- expect(described_class).to be < Ronin::Payloads::Payload
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/command_payload'
3
-
4
- describe Ronin::Payloads::CommandPayload do
5
- it "must inherit from Ronin::Payloads::Payload" do
6
- expect(described_class.superclass).to be(Ronin::Payloads::Payload)
7
- end
8
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/builtin/html/encode'
3
-
4
- describe Ronin::Payloads::Encoders::HTML::Encode do
5
- it "must inherit from Ronin::Payloads::Encoders::HTMLEncoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::HTMLEncoder
7
- end
8
-
9
- describe "#encode" do
10
- let(:data) { "hello world" }
11
- let(:encoded) { "&#104;&#101;&#108;&#108;&#111;&#32;&#119;&#111;&#114;&#108;&#100;" }
12
-
13
- it "must HTML encode each character" do
14
- expect(subject.encode(data)).to eq(encoded)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/builtin/js/encode'
3
-
4
- describe Ronin::Payloads::Encoders::JS::Encode do
5
- it "must inherit from Ronin::Payloads::Encoders::JavaScriptEncoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::JavaScriptEncoder
7
- end
8
-
9
- describe "#encode" do
10
- let(:data) { "hello world" }
11
- let(:encoded) { "\\x68\\x65\\x6C\\x6C\\x6F\\x20\\x77\\x6F\\x72\\x6C\\x64" }
12
-
13
- it "must JavaScript encode each character" do
14
- expect(subject.encode(data)).to eq(encoded)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/builtin/powershell/encode'
3
-
4
- describe Ronin::Payloads::Encoders::PowerShell::Encode do
5
- it "must inherit from Ronin::Payloads::Encoders::PowerShellEncoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::PowerShellEncoder
7
- end
8
-
9
- describe "#encode" do
10
- let(:data) { "hello world" }
11
- let(:encoded) { "$([char]0x68)$([char]0x65)$([char]0x6c)$([char]0x6c)$([char]0x6f)$([char]0x20)$([char]0x77)$([char]0x6f)$([char]0x72)$([char]0x6c)$([char]0x64)" }
12
-
13
- it "must PowerShell encode each character" do
14
- expect(subject.encode(data)).to eq(encoded)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/builtin/shell/encode'
3
-
4
- describe Ronin::Payloads::Encoders::Shell::Encode do
5
- it "must inherit from Ronin::Payloads::Encoders::ShellEncoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::ShellEncoder
7
- end
8
-
9
- describe "#encode" do
10
- let(:data) { "hello world" }
11
- let(:encoded) { "\\x68\\x65\\x6c\\x6c\\x6f\\x20\\x77\\x6f\\x72\\x6c\\x64" }
12
-
13
- it "must shell encode each character" do
14
- expect(subject.encode(data)).to eq(encoded)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/builtin/sql/encode'
3
-
4
- describe Ronin::Payloads::Encoders::SQL::Encode do
5
- it "must inherit from Ronin::Payloads::Encoders::SQLEncoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::SQLEncoder
7
- end
8
-
9
- describe "#encode" do
10
- let(:data) { "hello world" }
11
- let(:encoded) { "0x68656c6c6f20776f726c64" }
12
-
13
- it "must SQL encode the given String" do
14
- expect(subject.encode(data)).to eq(encoded)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/builtin/xml/encode'
3
-
4
- describe Ronin::Payloads::Encoders::XML::Encode do
5
- it "must inherit from Ronin::Payloads::Encoders::XMLEncoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::XMLEncoder
7
- end
8
-
9
- describe "#encode" do
10
- let(:data) { "hello world" }
11
- let(:encoded) { "&#104;&#101;&#108;&#108;&#111;&#32;&#119;&#111;&#114;&#108;&#100;" }
12
-
13
- it "must XML encode each character" do
14
- expect(subject.encode(data)).to eq(encoded)
15
- end
16
- end
17
- end
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/encoder'
3
-
4
- describe Ronin::Payloads::Encoders::Encoder do
5
- it "must include Ronin::Core::Metadata::ID" do
6
- expect(described_class).to include(Ronin::Core::Metadata::ID)
7
- end
8
-
9
- it "must include Ronin::Core::Metadata::Summary" do
10
- expect(described_class).to include(Ronin::Core::Metadata::Summary)
11
- end
12
-
13
- it "must include Ronin::Core::Metadata::Description" do
14
- expect(described_class).to include(Ronin::Core::Metadata::Description)
15
- end
16
-
17
- it "must include Ronin::Core::Metadata::References" do
18
- expect(described_class).to include(Ronin::Core::Metadata::References)
19
- end
20
-
21
- it "must include Ronin::Core::Params::Mixin" do
22
- expect(described_class).to include(Ronin::Core::Params::Mixin)
23
- end
24
-
25
- module TestEncoders
26
- class TestEncoder < Ronin::Payloads::Encoders::Encoder
27
-
28
- register 'test_encoder'
29
-
30
- end
31
- end
32
-
33
- describe ".register" do
34
- subject { TestEncoders::TestEncoder }
35
-
36
- it "must register the Encoder class with Encoders.module_registry" do
37
- expect(Ronin::Payloads::Encoders.registry['test_encoder']).to be(subject)
38
- end
39
-
40
- it "must also set .id" do
41
- expect(subject.id).to eq('test_encoder')
42
- end
43
- end
44
-
45
- describe "#validate" do
46
- it "must call #validate_params" do
47
- expect(subject).to receive(:validate_params)
48
-
49
- subject.validate
50
- end
51
- end
52
-
53
- describe "#encode" do
54
- let(:data) { "data" }
55
-
56
- it "must raise NotImplementedError by default" do
57
- expect {
58
- subject.encode(data)
59
- }.to raise_error(NotImplementedError,"#{described_class}#encode was not implemented")
60
- end
61
- end
62
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/html_encoder'
3
-
4
- describe Ronin::Payloads::Encoders::HTMLEncoder do
5
- it "must inherit from Ronin::Payloads::Encoders::Encoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::Encoder
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/javascript_encoder'
3
-
4
- describe Ronin::Payloads::Encoders::JavaScriptEncoder do
5
- it "must inherit from Ronin::Payloads::Encoders::Encoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::Encoder
7
- end
8
- end
@@ -1,153 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/pipeline'
3
- require 'ronin/payloads/encoders/encoder'
4
-
5
- describe Ronin::Payloads::Encoders::Pipeline do
6
- module TestEncoderPipeline
7
- class EncoderA < Ronin::Payloads::Encoders::Encoder
8
-
9
- id 'encoder_a'
10
-
11
- def encode(data)
12
- "AAA#{data}"
13
- end
14
-
15
- end
16
-
17
- class EncoderB < Ronin::Payloads::Encoders::Encoder
18
-
19
- id 'encoder_b'
20
-
21
- def encode(data)
22
- "#{data}BBB"
23
- end
24
-
25
- end
26
-
27
- class BadEncoder < Ronin::Payloads::Encoders::Encoder
28
-
29
- id 'bad_encoder'
30
-
31
- def encode(data)
32
- end
33
-
34
- end
35
- end
36
-
37
- describe "#initialize" do
38
- subject { described_class.new }
39
-
40
- it "must initialize #encoders to an empty Array" do
41
- expect(subject.encoders).to eq([])
42
- end
43
- end
44
-
45
- let(:encoder_a) { TestEncoderPipeline::EncoderA.new }
46
- let(:encoder_b) { TestEncoderPipeline::EncoderB.new }
47
- let(:encoders) { [encoder_a, encoder_b] }
48
-
49
- subject { described_class.new(encoders) }
50
-
51
- describe "#<<" do
52
- subject { described_class.new([encoder_a]) }
53
-
54
- it "must append the encoder to the end of #encoders" do
55
- subject << encoder_b
56
-
57
- expect(subject.encoders[0]).to eq(encoder_a)
58
- expect(subject.encoders[1]).to eq(encoder_b)
59
- end
60
-
61
- it "must return self" do
62
- expect(subject << encoder_b).to be(subject)
63
- end
64
- end
65
-
66
- describe "#empty?" do
67
- context "when #encoders is empty" do
68
- subject { described_class.new }
69
-
70
- it "must return true" do
71
- expect(subject.empty?).to be(true)
72
- end
73
- end
74
-
75
- context "when #encoders is not empty" do
76
- it "must return false" do
77
- expect(subject.empty?).to be(false)
78
- end
79
- end
80
- end
81
-
82
- describe "#each" do
83
- context "when given a block" do
84
- it "must yield each encoder in #encoders" do
85
- expect { |b|
86
- subject.each(&b)
87
- }.to yield_successive_args(*subject.encoders)
88
- end
89
- end
90
-
91
- context "when no block is given" do
92
- it "must return an Enumerator" do
93
- expect(subject.each.to_a).to eq(subject.encoders)
94
- end
95
- end
96
- end
97
-
98
- describe "#validate" do
99
- it "must also call #validate on each encoder in #encoders" do
100
- expect(encoder_a).to receive(:validate)
101
- expect(encoder_b).to receive(:validate)
102
-
103
- subject.validate
104
- end
105
- end
106
-
107
- describe "#[]" do
108
- context "when given an Integer" do
109
- it "must return the encoder at the given index" do
110
- expect(subject[0]).to eq(encoders[0])
111
- expect(subject[1]).to eq(encoders[1])
112
- end
113
- end
114
-
115
- context "when given a String" do
116
- it "must return the encoder with the matching id" do
117
- expect(subject['encoder_a'].class_id).to eq('encoder_a')
118
- expect(subject['encoder_b'].class_id).to eq('encoder_b')
119
- end
120
-
121
- context "but there is no encoder with the matching id" do
122
- it "must return nil" do
123
- expect(subject['foo']).to be(nil)
124
- end
125
- end
126
- end
127
- end
128
-
129
- describe "#encode" do
130
- let(:payload) { "foo" }
131
-
132
- it "must pass the given payload String through each encoder" do
133
- expect(subject.encode(payload)).to eq("AAA#{payload}BBB")
134
- end
135
-
136
- it "must not change the given payload String" do
137
- subject.encode(payload)
138
-
139
- expect(payload).to eq("foo")
140
- end
141
-
142
- context "when one of the encoders in #encoders does not return a String" do
143
- let(:bad_encoder) { TestEncoderPipeline::BadEncoder.new }
144
- before { subject << bad_encoder }
145
-
146
- it do
147
- expect {
148
- subject.encode(payload)
149
- }.to raise_error(Ronin::Payloads::Encoders::BadEncoder,"no result was returned by the encoder: #{bad_encoder.inspect}")
150
- end
151
- end
152
- end
153
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/powershell_encoder'
3
-
4
- describe Ronin::Payloads::Encoders::PowerShellEncoder do
5
- it "must inherit from Ronin::Payloads::Encoders::Encoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::Encoder
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/shell_encoder'
3
-
4
- describe Ronin::Payloads::Encoders::ShellEncoder do
5
- it "must inherit from Ronin::Payloads::Encoders::Encoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::Encoder
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/sql_encoder'
3
-
4
- describe Ronin::Payloads::Encoders::SQLEncoder do
5
- it "must inherit from Ronin::Payloads::Encoders::Encoder" do
6
- expect(described_class).to be < Ronin::Payloads::Encoders::Encoder
7
- end
8
- end