ronin-payloads 0.1.0.beta1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +16 -1
  3. data/.rubocop.yml +37 -0
  4. data/.yardopts +1 -1
  5. data/ChangeLog.md +13 -1
  6. data/Gemfile +5 -2
  7. data/README.md +4 -3
  8. data/Rakefile +3 -1
  9. data/bin/ronin-payloads +7 -8
  10. data/examples/bin_sh.rb +4 -0
  11. data/gemspec.yml +8 -7
  12. data/lib/ronin/payloads/asm_payload.rb +2 -2
  13. data/lib/ronin/payloads/binary_payload.rb +1 -1
  14. data/lib/ronin/payloads/builtin/cmd/awk/reverse_shell.rb +1 -1
  15. data/lib/ronin/payloads/builtin/cmd/bash/reverse_shell.rb +1 -1
  16. data/lib/ronin/payloads/builtin/cmd/lua/reverse_shell.rb +1 -1
  17. data/lib/ronin/payloads/builtin/cmd/node/reverse_shell.rb +1 -1
  18. data/lib/ronin/payloads/builtin/cmd/openssl/reverse_shell.rb +1 -1
  19. data/lib/ronin/payloads/builtin/cmd/perl/reverse_shell.rb +1 -1
  20. data/lib/ronin/payloads/builtin/cmd/php/reverse_shell.rb +1 -1
  21. data/lib/ronin/payloads/builtin/cmd/powershell/reverse_shell.rb +1 -1
  22. data/lib/ronin/payloads/builtin/cmd/python/reverse_shell.rb +1 -1
  23. data/lib/ronin/payloads/builtin/cmd/ruby/reverse_shell.rb +1 -1
  24. data/lib/ronin/payloads/builtin/java/reverse_shell.rb +1 -1
  25. data/lib/ronin/payloads/builtin/php/cmd_exec.rb +5 -4
  26. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/bind_shell.rb +2 -2
  27. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/exec_shell.rb +2 -2
  28. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86/reverse_shell.rb +2 -2
  29. data/lib/ronin/payloads/builtin/shellcode/freebsd/x86_64/exec_shell.rb +2 -2
  30. data/lib/ronin/payloads/builtin/shellcode/linux/arm/bind_shell.rb +2 -2
  31. data/lib/ronin/payloads/builtin/shellcode/linux/arm/exec_shell.rb +2 -2
  32. data/lib/ronin/payloads/builtin/shellcode/linux/arm/reverse_shell.rb +2 -2
  33. data/lib/ronin/payloads/builtin/shellcode/linux/mips/bind_shell.rb +2 -2
  34. data/lib/ronin/payloads/builtin/shellcode/linux/mips/exec_shell.rb +2 -2
  35. data/lib/ronin/payloads/builtin/shellcode/linux/mips/reverse_shell.rb +2 -2
  36. data/lib/ronin/payloads/builtin/shellcode/linux/ppc/exec_shell.rb +2 -2
  37. data/lib/ronin/payloads/builtin/shellcode/linux/ppc/reverse_shell.rb +3 -3
  38. data/lib/ronin/payloads/builtin/shellcode/linux/x86/bind_shell.rb +3 -3
  39. data/lib/ronin/payloads/builtin/shellcode/linux/x86/exec_shell.rb +2 -2
  40. data/lib/ronin/payloads/builtin/shellcode/linux/x86/reverse_shell.rb +2 -2
  41. data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/bind_shell.rb +3 -3
  42. data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/exec_shell.rb +2 -2
  43. data/lib/ronin/payloads/builtin/shellcode/linux/x86_64/reverse_shell.rb +2 -2
  44. data/lib/ronin/payloads/builtin/shellcode/macos/x86_64/exec_shell.rb +2 -2
  45. data/lib/ronin/payloads/builtin/shellcode/macos/x86_64/reverse_shell.rb +2 -2
  46. data/lib/ronin/payloads/builtin/shellcode/netbsd/x86/exec_shell.rb +2 -2
  47. data/lib/ronin/payloads/builtin/shellcode/netbsd/x86/reverse_shell.rb +2 -2
  48. data/lib/ronin/payloads/builtin/shellcode/openbsd/x86/bind_shell.rb +2 -2
  49. data/lib/ronin/payloads/builtin/shellcode/openbsd/x86/exec_shell.rb +2 -2
  50. data/lib/ronin/payloads/builtin/shellcode/windows/x86_64/cmd.rb +3 -3
  51. data/lib/ronin/payloads/builtin/test/open_redirect.rb +4 -4
  52. data/lib/ronin/payloads/builtin/test/xss.rb +4 -4
  53. data/lib/ronin/payloads/c_payload.rb +2 -2
  54. data/lib/ronin/payloads/cli/command.rb +1 -1
  55. data/lib/ronin/payloads/cli/commands/build.rb +11 -13
  56. data/lib/ronin/payloads/cli/commands/encode.rb +17 -21
  57. data/lib/ronin/payloads/cli/commands/encoder.rb +1 -1
  58. data/lib/ronin/payloads/cli/commands/encoders.rb +2 -2
  59. data/lib/ronin/payloads/cli/commands/irb.rb +1 -1
  60. data/lib/ronin/payloads/cli/commands/launch.rb +3 -3
  61. data/lib/ronin/payloads/cli/commands/list.rb +1 -1
  62. data/lib/ronin/payloads/cli/commands/new.rb +4 -4
  63. data/lib/ronin/payloads/cli/commands/show.rb +3 -2
  64. data/lib/ronin/payloads/cli/encoder_methods.rb +2 -1
  65. data/lib/ronin/payloads/cli/format_option.rb +1 -1
  66. data/lib/ronin/payloads/cli/generator/payload_types.rb +4 -3
  67. data/lib/ronin/payloads/cli/payload_command.rb +1 -1
  68. data/lib/ronin/payloads/cli/payload_methods.rb +1 -1
  69. data/lib/ronin/payloads/cli/printing.rb +1 -1
  70. data/lib/ronin/payloads/cli/ruby_shell.rb +1 -1
  71. data/lib/ronin/payloads/cli.rb +6 -1
  72. data/lib/ronin/payloads/coldfusion_payload.rb +1 -1
  73. data/lib/ronin/payloads/command_payload.rb +1 -1
  74. data/lib/ronin/payloads/encoders/builtin/html/encode.rb +2 -1
  75. data/lib/ronin/payloads/encoders/builtin/js/encode.rb +2 -1
  76. data/lib/ronin/payloads/encoders/builtin/powershell/encode.rb +2 -1
  77. data/lib/ronin/payloads/encoders/builtin/shell/encode.rb +2 -1
  78. data/lib/ronin/payloads/encoders/builtin/sql/encode.rb +2 -1
  79. data/lib/ronin/payloads/encoders/builtin/xml/encode.rb +2 -1
  80. data/lib/ronin/payloads/encoders/encoder.rb +3 -2
  81. data/lib/ronin/payloads/encoders/exceptions.rb +2 -1
  82. data/lib/ronin/payloads/encoders/html_encoder.rb +2 -1
  83. data/lib/ronin/payloads/encoders/javascript_encoder.rb +2 -1
  84. data/lib/ronin/payloads/encoders/pipeline.rb +3 -2
  85. data/lib/ronin/payloads/encoders/powershell_encoder.rb +2 -1
  86. data/lib/ronin/payloads/encoders/registry.rb +5 -1
  87. data/lib/ronin/payloads/encoders/shell_encoder.rb +2 -1
  88. data/lib/ronin/payloads/encoders/sql_encoder.rb +2 -1
  89. data/lib/ronin/payloads/encoders/xml_encoder.rb +2 -1
  90. data/lib/ronin/payloads/encoders.rb +1 -1
  91. data/lib/ronin/payloads/exceptions.rb +2 -1
  92. data/lib/ronin/payloads/go_payload.rb +2 -2
  93. data/lib/ronin/payloads/html_payload.rb +1 -1
  94. data/lib/ronin/payloads/java_payload.rb +2 -2
  95. data/lib/ronin/payloads/javascript_payload.rb +1 -1
  96. data/lib/ronin/payloads/jsp_payload.rb +1 -1
  97. data/lib/ronin/payloads/metadata/arch.rb +2 -1
  98. data/lib/ronin/payloads/metadata/os.rb +2 -1
  99. data/lib/ronin/payloads/mixins/binary.rb +1 -1
  100. data/lib/ronin/payloads/mixins/bind_shell.rb +3 -3
  101. data/lib/ronin/payloads/mixins/build_dir.rb +1 -1
  102. data/lib/ronin/payloads/mixins/erb.rb +1 -1
  103. data/lib/ronin/payloads/mixins/network.rb +1 -1
  104. data/lib/ronin/payloads/mixins/post_ex.rb +1 -2
  105. data/lib/ronin/payloads/mixins/resolve_host.rb +1 -1
  106. data/lib/ronin/payloads/mixins/reverse_shell.rb +1 -2
  107. data/lib/ronin/payloads/mixins/tempfile.rb +1 -1
  108. data/lib/ronin/payloads/mixins/typescript.rb +2 -3
  109. data/lib/ronin/payloads/node_js_payload.rb +1 -1
  110. data/lib/ronin/payloads/payload.rb +8 -8
  111. data/lib/ronin/payloads/php_payload.rb +1 -1
  112. data/lib/ronin/payloads/powershell_payload.rb +1 -1
  113. data/lib/ronin/payloads/python_payload.rb +1 -1
  114. data/lib/ronin/payloads/registry.rb +4 -1
  115. data/lib/ronin/payloads/root.rb +1 -1
  116. data/lib/ronin/payloads/ruby_payload.rb +1 -1
  117. data/lib/ronin/payloads/rust_payload.rb +2 -2
  118. data/lib/ronin/payloads/shell_payload.rb +1 -1
  119. data/lib/ronin/payloads/shellcode/bind_shell_payload.rb +1 -1
  120. data/lib/ronin/payloads/shellcode/exec_shell_payload.rb +1 -1
  121. data/lib/ronin/payloads/shellcode/reverse_shell_payload.rb +1 -1
  122. data/lib/ronin/payloads/shellcode_payload.rb +9 -9
  123. data/lib/ronin/payloads/sql_payload.rb +1 -1
  124. data/lib/ronin/payloads/url_payload.rb +3 -3
  125. data/lib/ronin/payloads/version.rb +2 -2
  126. data/lib/ronin/payloads/xml_payload.rb +1 -1
  127. data/lib/ronin/payloads.rb +2 -1
  128. data/man/ronin-payloads-build.1 +1 -1
  129. data/man/ronin-payloads-build.1.md +1 -1
  130. data/man/ronin-payloads-encode.1 +1 -1
  131. data/man/ronin-payloads-encode.1.md +1 -1
  132. data/man/ronin-payloads-encoder.1 +1 -1
  133. data/man/ronin-payloads-encoder.1.md +1 -1
  134. data/man/ronin-payloads-encoders.1 +1 -1
  135. data/man/ronin-payloads-encoders.1.md +1 -1
  136. data/man/ronin-payloads-irb.1 +1 -1
  137. data/man/ronin-payloads-irb.1.md +1 -1
  138. data/man/ronin-payloads-launch.1 +1 -1
  139. data/man/ronin-payloads-launch.1.md +1 -1
  140. data/man/ronin-payloads-list.1 +1 -1
  141. data/man/ronin-payloads-list.1.md +1 -1
  142. data/man/ronin-payloads.1 +1 -1
  143. data/man/ronin-payloads.1.md +1 -1
  144. data/ronin-payloads.gemspec +5 -5
  145. metadata +17 -215
  146. data/spec/asm_payload_spec.rb +0 -114
  147. data/spec/binary_payload_spec.rb +0 -8
  148. data/spec/builtin/cmd/awk/reverse_shell_spec.rb +0 -38
  149. data/spec/builtin/cmd/bash/reverse_shell_spec.rb +0 -36
  150. data/spec/builtin/cmd/lua/reverse_shell_spec.rb +0 -38
  151. data/spec/builtin/cmd/node/reverse_shell_spec.rb +0 -36
  152. data/spec/builtin/cmd/openssl/reverse_shell_spec.rb +0 -38
  153. data/spec/builtin/cmd/perl/reverse_shell_spec.rb +0 -38
  154. data/spec/builtin/cmd/php/reverse_shell_spec.rb +0 -38
  155. data/spec/builtin/cmd/powershell/reverse_shell_spec.rb +0 -38
  156. data/spec/builtin/cmd/python/reverse_shell_spec.rb +0 -38
  157. data/spec/builtin/cmd/ruby/reverse_shell_spec.rb +0 -38
  158. data/spec/builtin/java/reverse_shell_spec.rb +0 -103
  159. data/spec/builtin/php/cmd_exec.rb +0 -52
  160. data/spec/builtin/shellcode/freebsd/x86/bind_shell_spec.rb +0 -58
  161. data/spec/builtin/shellcode/freebsd/x86/exec_shell_spec.rb +0 -46
  162. data/spec/builtin/shellcode/freebsd/x86/reverse_shell_spec.rb +0 -63
  163. data/spec/builtin/shellcode/freebsd/x86_64/exec_shell_spec.rb +0 -46
  164. data/spec/builtin/shellcode/linux/arm/bind_shell_spec.rb +0 -62
  165. data/spec/builtin/shellcode/linux/arm/exec_shell_spec.rb +0 -46
  166. data/spec/builtin/shellcode/linux/arm/reverse_shell_spec.rb +0 -58
  167. data/spec/builtin/shellcode/linux/mips/bind_shell_spec.rb +0 -60
  168. data/spec/builtin/shellcode/linux/mips/exec_shell_spec.rb +0 -46
  169. data/spec/builtin/shellcode/linux/mips/reverse_shell_spec.rb +0 -58
  170. data/spec/builtin/shellcode/linux/ppc/exec_shell_spec.rb +0 -46
  171. data/spec/builtin/shellcode/linux/ppc/reverse_shell_spec.rb +0 -87
  172. data/spec/builtin/shellcode/linux/x86/bind_shell_spec.rb +0 -60
  173. data/spec/builtin/shellcode/linux/x86/exec_shell_spec.rb +0 -46
  174. data/spec/builtin/shellcode/linux/x86/reverse_shell_spec.rb +0 -58
  175. data/spec/builtin/shellcode/linux/x86_64/bind_shell_spec.rb +0 -60
  176. data/spec/builtin/shellcode/linux/x86_64/exec_shell_spec.rb +0 -46
  177. data/spec/builtin/shellcode/linux/x86_64/reverse_shell_spec.rb +0 -58
  178. data/spec/builtin/shellcode/macos/x86_64/exec_shell_spec.rb +0 -46
  179. data/spec/builtin/shellcode/macos/x86_64/reverse_shell_spec.rb +0 -58
  180. data/spec/builtin/shellcode/netbsd/x86/exec_shell_spec.rb +0 -46
  181. data/spec/builtin/shellcode/netbsd/x86/reverse_shell_spec.rb +0 -63
  182. data/spec/builtin/shellcode/openbsd/x86/bind_shell_spec.rb +0 -58
  183. data/spec/builtin/shellcode/openbsd/x86/exec_shell_spec.rb +0 -46
  184. data/spec/builtin/shellcode/windows/x86_64/cmd_spec.rb +0 -54
  185. data/spec/builtin/test/open_redirect_spec.rb +0 -24
  186. data/spec/builtin/test/xss_spec.rb +0 -24
  187. data/spec/c_payload_spec.rb +0 -139
  188. data/spec/cli/commands/show_spec.rb +0 -21
  189. data/spec/cli/encoder_methods_spec.rb +0 -275
  190. data/spec/cli/format_option_spec.rb +0 -187
  191. data/spec/cli/payload_command_spec.rb +0 -68
  192. data/spec/cli/payload_methods_spec.rb +0 -208
  193. data/spec/cli/printing_spec.rb +0 -65
  194. data/spec/cli/ruby_shell_spec.rb +0 -14
  195. data/spec/coldfusion_payload_spec.rb +0 -8
  196. data/spec/command_payload_spec.rb +0 -8
  197. data/spec/encoders/builtin/html/encode_spec.rb +0 -17
  198. data/spec/encoders/builtin/js/encode_spec.rb +0 -17
  199. data/spec/encoders/builtin/powershell/encode_spec.rb +0 -17
  200. data/spec/encoders/builtin/shell/encode_spec.rb +0 -17
  201. data/spec/encoders/builtin/sql/encode_spec.rb +0 -17
  202. data/spec/encoders/builtin/xml/encode_spec.rb +0 -17
  203. data/spec/encoders/encoder_spec.rb +0 -62
  204. data/spec/encoders/html_encoder_spec.rb +0 -8
  205. data/spec/encoders/javascript_encoder_spec.rb +0 -8
  206. data/spec/encoders/pipeline_spec.rb +0 -153
  207. data/spec/encoders/powershell_encoder_spec.rb +0 -8
  208. data/spec/encoders/shell_encoder_spec.rb +0 -8
  209. data/spec/encoders/sql_encoder_spec.rb +0 -8
  210. data/spec/encoders/xml_encoder_spec.rb +0 -8
  211. data/spec/encoders_spec.rb +0 -25
  212. data/spec/go_payload_spec.rb +0 -56
  213. data/spec/helpers/encoders.rb +0 -9
  214. data/spec/helpers/payloads.rb +0 -9
  215. data/spec/helpers/scripts/payloads/simple.rb +0 -22
  216. data/spec/html_payload_spec.rb +0 -12
  217. data/spec/java_payload_spec.rb +0 -97
  218. data/spec/javascript_payload_spec.rb +0 -12
  219. data/spec/jsp_payload_spec.rb +0 -8
  220. data/spec/metadata/arch_spec.rb +0 -82
  221. data/spec/metadata/os_spec.rb +0 -164
  222. data/spec/mixins/binary_spec.rb +0 -129
  223. data/spec/mixins/bind_shell_spec.rb +0 -73
  224. data/spec/mixins/build_dir.rb +0 -64
  225. data/spec/mixins/erb_spec.rb +0 -19
  226. data/spec/mixins/network_spec.rb +0 -75
  227. data/spec/mixins/post_ex_spec.rb +0 -40
  228. data/spec/mixins/resolve_host_spec.rb +0 -322
  229. data/spec/mixins/reverse_shell_spec.rb +0 -103
  230. data/spec/mixins/tempfile_spec.rb +0 -97
  231. data/spec/mixins/typescript_spec.rb +0 -92
  232. data/spec/node_js_payload_spec.rb +0 -8
  233. data/spec/payload_spec.rb +0 -288
  234. data/spec/payloads_spec.rb +0 -29
  235. data/spec/php_payload_spec.rb +0 -8
  236. data/spec/powershell_payload_spec.rb +0 -16
  237. data/spec/python_payload_spec.rb +0 -8
  238. data/spec/ruby_payload_spec.rb +0 -8
  239. data/spec/rust_payload_spec.rb +0 -116
  240. data/spec/shell_payload_spec.rb +0 -16
  241. data/spec/shellcode/bind_shell_payload_spec.rb +0 -42
  242. data/spec/shellcode/exec_shell_payload_spec.rb +0 -8
  243. data/spec/shellcode/reverse_shell_payload_spec.rb +0 -136
  244. data/spec/shellcode_payload_spec.rb +0 -38
  245. data/spec/spec_helper.rb +0 -7
  246. data/spec/sql_payload_spec.rb +0 -12
  247. data/spec/url_payload_spec.rb +0 -72
  248. data/spec/xml_payload_spec.rb +0 -12
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/mixins/tempfile'
3
-
4
- require 'ronin/payloads/payload'
5
-
6
- describe Ronin::Payloads::Mixins::Tempfile do
7
- module TestFileBuilderMixin
8
- class TestPayload < Ronin::Payloads::Payload
9
- include Ronin::Payloads::Mixins::Tempfile
10
- end
11
- end
12
-
13
- let(:payload_class) { TestFileBuilderMixin::TestPayload }
14
- subject { payload_class.new }
15
-
16
- describe "#tempfile" do
17
- context "when given a block" do
18
- it "must yield a new Tempfile object" do
19
- expect { |b|
20
- subject.tempfile(&b)
21
- }.to yield_with_args(Tempfile)
22
- end
23
-
24
- it "must create the tempfile" do
25
- subject.tempfile do |tempfile|
26
- expect(File.file?(tempfile.path)).to be(true)
27
- end
28
- end
29
-
30
- context "when given a file name" do
31
- let(:name) { 'foo' }
32
-
33
- it "must add the file name to the tempfile name" do
34
- subject.tempfile(name) do |tempfile|
35
- expect(tempfile.path).to match(%r{\A/tmp/ronin-payloads-#{name}-\d+-\d+-[a-z0-9]+\z})
36
- end
37
- end
38
-
39
- context "when given the ext: keyword argument" do
40
- let(:ext) { '.txt' }
41
-
42
- it "must also append the file extension to the tempfile name" do
43
- subject.tempfile(name, ext: ext) do |tempfile|
44
- expect(tempfile.path).to match(%r{\A/tmp/ronin-payloads-#{name}-\d+-\d+-[a-z0-9]+#{Regexp.escape(ext)}\z})
45
- end
46
- end
47
- end
48
- end
49
-
50
- context "when given the ext: keyword argument" do
51
- let(:ext) { '.txt' }
52
-
53
- it "must append the file extension to the tempfile name" do
54
- subject.tempfile(ext: ext) do |tempfile|
55
- expect(tempfile.path).to match(%r{\A/tmp/ronin-payloads-\d+-\d+-[a-z0-9]+#{Regexp.escape(ext)}\z})
56
- end
57
- end
58
- end
59
- end
60
-
61
- context "when no block is given" do
62
- it "must return a Tempfile object" do
63
- expect(subject.tempfile).to be_kind_of(Tempfile)
64
- end
65
-
66
- context "when given a file name" do
67
- let(:name) { 'foo' }
68
-
69
- it "must add the file name to the tempfile name" do
70
- tempfile = subject.tempfile(name)
71
-
72
- expect(tempfile.path).to match(%r{\A/tmp/ronin-payloads-#{name}-\d+-\d+-[a-z0-9]+\z})
73
- end
74
-
75
- context "when given the ext: keyword argument" do
76
- let(:ext) { '.txt' }
77
-
78
- it "must also append the file extension to the tempfile name" do
79
- tempfile = subject.tempfile(name, ext: ext)
80
-
81
- expect(tempfile.path).to match(%r{\A/tmp/ronin-payloads-#{name}-\d+-\d+-[a-z0-9]+#{Regexp.escape(ext)}\z})
82
- end
83
- end
84
- end
85
-
86
- context "when given the ext: keyword argument" do
87
- let(:ext) { '.txt' }
88
-
89
- it "must append the file extension to the tempfile name" do
90
- tempfile = subject.tempfile(ext: ext)
91
-
92
- expect(tempfile.path).to match(%r{\A/tmp/ronin-payloads-\d+-\d+-[a-z0-9]+#{Regexp.escape(ext)}\z})
93
- end
94
- end
95
- end
96
- end
97
- end
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/mixins/typescript'
3
- require 'ronin/payloads/javascript_payload'
4
-
5
- describe Ronin::Payloads::Mixins::TypeScript do
6
- module TestTypeScriptMixin
7
- class TestPayload < Ronin::Payloads::JavaScriptPayload
8
- include Ronin::Payloads::Mixins::TypeScript
9
- end
10
- end
11
-
12
- let(:payload_class) { TestTypeScriptMixin::TestPayload }
13
-
14
- describe ".tsc" do
15
- subject { described_class }
16
-
17
- context "when ENV['TSC'] is set" do
18
- let(:tsc) { 'tsc' }
19
-
20
- before { ENV['TSC'] = tsc }
21
-
22
- it "must return ENV['TSC']" do
23
- expect(subject.tsc).to eq(tsc)
24
- end
25
- end
26
-
27
- context "when ENV['TSC'] is not set" do
28
- before(:all) do
29
- @tsc = ENV['TSC']
30
- ENV.delete('TSC')
31
- end
32
-
33
- it "must return 'tsc'" do
34
- expect(subject.tsc).to eq('tsc')
35
- end
36
-
37
- after(:all) do
38
- ENV['TSC'] = @tsc if @tsc
39
- end
40
- end
41
- end
42
-
43
- describe "params" do
44
- subject { payload_class }
45
-
46
- it "must define a :tsc param" do
47
- expect(subject.params[:tsc]).to_not be_nil
48
- end
49
-
50
- it "must default the :tsc param to #{described_class}.tsc" do
51
- expect(subject.params[:tsc].default_value).to eq(described_class.tsc)
52
- end
53
- end
54
-
55
- subject { payload_class.new }
56
-
57
- describe "#compile" do
58
- let(:source_files) { %w[foo.ts bar.ts baz.ts] }
59
-
60
- it "must call system with params[:tsc] and additional source files" do
61
- expect(subject).to receive(:system).with(
62
- subject.params[:tsc], *source_files
63
- ).and_return(true)
64
-
65
- subject.compile(*source_files)
66
- end
67
-
68
- context "when system() returns false" do
69
- let(:source_file) { 'foo.ts' }
70
-
71
- it do
72
- allow(subject).to receive(:system).and_return(false)
73
-
74
- expect {
75
- subject.compile(source_file)
76
- }.to raise_error(Ronin::Payloads::BuildFailed,"tsc command failed: #{subject.params[:tsc]} #{source_file}")
77
- end
78
- end
79
-
80
- context "when system() returns nil" do
81
- let(:source_file) { 'foo.rs' }
82
-
83
- it do
84
- allow(subject).to receive(:system).and_return(nil)
85
-
86
- expect {
87
- subject.compile(source_file)
88
- }.to raise_error(Ronin::Payloads::BuildFailed,"tsc command not installed")
89
- end
90
- end
91
- end
92
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/node_js_payload'
3
-
4
- describe Ronin::Payloads::NodeJSPayload do
5
- it "must inherit from Ronin::Payloads::Payload" do
6
- expect(described_class.superclass).to be(Ronin::Payloads::Payload)
7
- end
8
- end
data/spec/payload_spec.rb DELETED
@@ -1,288 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/payload'
3
- require 'ronin/payloads/encoders/encoder'
4
-
5
- describe Ronin::Payloads::Payload do
6
- it "must include Ronin::Core::Metadata::ID" do
7
- expect(described_class).to include(Ronin::Core::Metadata::ID)
8
- end
9
-
10
- it "must include Ronin::Core::Metadata::Authors" do
11
- expect(described_class).to include(Ronin::Core::Metadata::Authors)
12
- end
13
-
14
- it "must include Ronin::Core::Metadata::Summary" do
15
- expect(described_class).to include(Ronin::Core::Metadata::Summary)
16
- end
17
-
18
- it "must include Ronin::Core::Metadata::Description" do
19
- expect(described_class).to include(Ronin::Core::Metadata::Description)
20
- end
21
-
22
- it "must include Ronin::Core::Metadata::References" do
23
- expect(described_class).to include(Ronin::Core::Metadata::References)
24
- end
25
-
26
- it "must include Ronin::Core::Params::Mixin" do
27
- expect(described_class).to include(Ronin::Core::Params::Mixin)
28
- end
29
-
30
- it "must include Ronin::Support::CLI::Printing" do
31
- expect(described_class).to include(Ronin::Support::CLI::Printing)
32
- end
33
-
34
- describe "#build" do
35
- subject { described_class.new }
36
-
37
- it "must return nil by default" do
38
- expect(subject.build).to be(nil)
39
- end
40
-
41
- it "must not set @payload by default" do
42
- subject.build
43
-
44
- expect(subject.instance_variable_get('@payload')).to be(nil)
45
- end
46
- end
47
-
48
- describe "#cleanup" do
49
- subject { described_class.new }
50
-
51
- it "must return nil by default" do
52
- expect(subject.cleanup).to be(nil)
53
- end
54
- end
55
-
56
- module TestPayload
57
- class TestEncoder < Ronin::Payloads::Encoders::Encoder
58
-
59
- def encode(payload)
60
- payload.upcase
61
- end
62
-
63
- end
64
-
65
- class TestPayload < Ronin::Payloads::Payload
66
-
67
- register 'test_payload'
68
-
69
- def build
70
- @payload = "the payload"
71
- end
72
-
73
- end
74
- end
75
-
76
- let(:test_encoder_class) { TestPayload::TestEncoder }
77
- let(:test_encoder) { test_encoder_class.new }
78
-
79
- let(:test_class) { TestPayload::TestPayload }
80
- subject { test_class.new }
81
-
82
- describe ".register" do
83
- subject { test_class }
84
-
85
- it "must register the payload class into Payloads.registry" do
86
- expect(Ronin::Payloads.registry['test_payload']).to eq(subject)
87
- end
88
-
89
- it "must also set .id" do
90
- expect(subject.id).to eq('test_payload')
91
- end
92
- end
93
-
94
- describe "#perform_validate" do
95
- it "must call #validate_params" do
96
- expect(subject).to receive(:validate_params)
97
-
98
- subject.perform_validate
99
- end
100
-
101
- it "must also call #validate" do
102
- expect(subject).to receive(:validate)
103
-
104
- subject.perform_validate
105
- end
106
-
107
- context "when #encoders is populated" do
108
- let(:encoder1) { test_encoder_class.new }
109
- let(:encoder2) { test_encoder_class.new }
110
-
111
- subject { test_class.new(encoders: [encoder1, encoder2]) }
112
-
113
- it "must also call #validate on each #encoder" do
114
- expect(encoder1).to receive(:validate)
115
- expect(encoder2).to receive(:validate)
116
- expect(subject).to receive(:validate_params)
117
-
118
- subject.perform_validate
119
- end
120
- end
121
- end
122
-
123
- describe "#built?" do
124
- context "when @payload is set by #build" do
125
- before { subject.build }
126
-
127
- it "must return true" do
128
- expect(subject.built?).to be(true)
129
- end
130
- end
131
-
132
- context "when @payload is not set" do
133
- it "must return false" do
134
- expect(subject.built?).to be(false)
135
- end
136
- end
137
- end
138
-
139
- describe "#perform_build" do
140
- subject { described_class.new }
141
-
142
- it "must call #build and then check #built?" do
143
- expect(subject).to receive(:build)
144
- expect(subject).to receive(:built?).and_return(true)
145
-
146
- subject.perform_build
147
- end
148
-
149
- context "when the #build method did not set @payload" do
150
- it do
151
- expect {
152
- subject.perform_build
153
- }.to raise_error(Ronin::Payloads::PayloadNotBuilt,/^the payload was not built for some reason: /)
154
- end
155
- end
156
- end
157
-
158
- describe "#built_payload" do
159
- it "must return the built payload" do
160
- expect(subject.built_payload).to eq("the payload")
161
- end
162
-
163
- it "must not re-build the payload when called multiple times" do
164
- expect(subject.built_payload).to be(subject.built_payload)
165
- end
166
- end
167
-
168
- describe "#rebuild_payload" do
169
- before { subject.build }
170
-
171
- it "must forcibly re-build the payload" do
172
- previously_built_payload = subject.payload
173
-
174
- subject.rebuild_payload
175
-
176
- expect(subject.payload).to eq(previously_built_payload)
177
- expect(subject.payload).to_not be(previously_built_payload)
178
- end
179
- end
180
-
181
- describe "#encode_payload" do
182
- subject { test_class.new(encoders: [test_encoder]) }
183
-
184
- it "must encode the built payload" do
185
- expect(subject.encode_payload).to eq(
186
- test_encoder.encode(subject.built_payload)
187
- )
188
- end
189
-
190
- it "must return a new String each time" do
191
- encoded_payload = subject.encoded_payload
192
-
193
- expect(subject.encode_payload).to eq(encoded_payload)
194
- expect(subject.encode_payload).to_not be(encoded_payload)
195
- end
196
- end
197
-
198
- describe "#encoded_payload" do
199
- subject { test_class.new(encoders: [test_encoder]) }
200
-
201
- it "must encode the built payload" do
202
- expect(subject.encoded_payload).to eq(
203
- test_encoder.encode(subject.built_payload)
204
- )
205
- end
206
-
207
- it "must not re-encode the payload when called multiple times" do
208
- expect(subject.encoded_payload).to be(subject.encoded_payload)
209
- end
210
- end
211
-
212
- describe "#reencode_payload" do
213
- subject { test_class.new(encoders: [test_encoder]) }
214
-
215
- before { subject.encoded_payload }
216
-
217
- it "must forcibly re-encoded the payload" do
218
- previously_encoded_payload = subject.encoded_payload
219
-
220
- subject.reencode_payload
221
-
222
- expect(subject.encoded_payload).to eq(previously_encoded_payload)
223
- expect(subject.encoded_payload).to_not be(previously_encoded_payload)
224
- end
225
- end
226
-
227
- describe "#perform_prelaunch" do
228
- subject { described_class.new }
229
-
230
- it "must call #prelaunch" do
231
- expect(subject).to receive(:prelaunch)
232
-
233
- subject.perform_prelaunch
234
- end
235
- end
236
-
237
- describe "#perform_postlaunch" do
238
- subject { described_class.new }
239
-
240
- it "must call #postlaunch" do
241
- expect(subject).to receive(:postlaunch)
242
-
243
- subject.perform_postlaunch
244
- end
245
- end
246
-
247
- describe "#perform_cleanup" do
248
- subject { described_class.new }
249
-
250
- it "must call #cleanup" do
251
- expect(subject).to receive(:cleanup)
252
-
253
- subject.perform_cleanup
254
- end
255
-
256
- it "must set @payload to nil" do
257
- subject.instance_variable_set('@payload',"foo")
258
-
259
- subject.perform_cleanup
260
-
261
- expect(subject.instance_variable_get('@payload')).to be(nil)
262
- end
263
- end
264
-
265
- describe "#length" do
266
- subject { test_class.new(encoders: [test_encoder]) }
267
-
268
- it "must return the size of the encoded payload in bytes" do
269
- expect(subject.length).to eq(subject.encoded_payload.length)
270
- end
271
- end
272
-
273
- describe "#bytesize" do
274
- subject { test_class.new(encoders: [test_encoder]) }
275
-
276
- it "must return the size of the encoded payload in bytes" do
277
- expect(subject.bytesize).to eq(subject.encoded_payload.bytesize)
278
- end
279
- end
280
-
281
- describe "#to_s" do
282
- subject { test_class.new(encoders: [test_encoder]) }
283
-
284
- it "must return the encoded payload" do
285
- expect(subject.to_s).to eq(subject.encoded_payload)
286
- end
287
- end
288
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads'
3
- require 'ronin/payloads/root'
4
-
5
- describe Ronin::Payloads do
6
- it "should have a version" do
7
- expect(subject.const_defined?('VERSION')).to eq(true)
8
- end
9
-
10
- it "must include Ronin::Core::ClassRegistry" do
11
- expect(subject).to include(Ronin::Core::ClassRegistry)
12
- end
13
-
14
- it "must include Ronin::Repos::ClassDir" do
15
- expect(subject).to include(Ronin::Repos::ClassDir)
16
- end
17
-
18
- it "must set .class_dir to 'ronin/payloads/builtin'" do
19
- expect(subject.class_dir).to eq(
20
- File.join(
21
- Ronin::Payloads::ROOT, 'lib', 'ronin', 'payloads', 'builtin'
22
- )
23
- )
24
- end
25
-
26
- it "must set .repo_class_dir to 'payloads'" do
27
- expect(subject.repo_class_dir).to eq('payloads')
28
- end
29
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/php_payload'
3
-
4
- describe Ronin::Payloads::PHPPayload 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,16 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/powershell_payload'
3
-
4
- describe Ronin::Payloads::PowerShellPayload do
5
- it "must inherit from Ronin::Payloads::Payload" do
6
- expect(described_class.superclass).to be(Ronin::Payloads::Payload)
7
- end
8
-
9
- describe ".encoder_class" do
10
- subject { described_class }
11
-
12
- it do
13
- expect(subject.encoder_class).to be(Ronin::Payloads::Encoders::PowerShellEncoder)
14
- end
15
- end
16
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/python_payload'
3
-
4
- describe Ronin::Payloads::PythonPayload 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,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/ruby_payload'
3
-
4
- describe Ronin::Payloads::RubyPayload 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,116 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/rust_payload'
3
-
4
- describe Ronin::Payloads::RustPayload 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 "#compile" do
10
- let(:source_files) { %w[foo.rs bar.rs baz.rs] }
11
-
12
- it "must call system with `rustc` and source files" do
13
- expect(subject).to receive(:system).with(
14
- 'rustc', *source_files
15
- ).and_return(true)
16
-
17
- subject.compile(*source_files)
18
- end
19
-
20
- context "when the output: keyword is given" do
21
- let(:output) { 'output' }
22
-
23
- it "must call system with 'rustc', the output, and source files" do
24
- expect(subject).to receive(:system).with(
25
- 'rustc','-o', output, *source_files
26
- ).and_return(true)
27
-
28
- subject.compile(*source_files, output: output)
29
- end
30
- end
31
-
32
- context "when the target: keyword is given" do
33
- let(:target) { 'aarch64-unknown-linux-gnu' }
34
-
35
- it "must call system with 'rustc', the target, and source files" do
36
- expect(subject).to receive(:system).with(
37
- 'rustc','--target', target, *source_files
38
- ).and_return(true)
39
-
40
- subject.compile(*source_files, target: target)
41
- end
42
- end
43
-
44
- context "when the cfg: keyword is given" do
45
- context "and it's a Hash" do
46
- let(:key1) { 'foo' }
47
- let(:value1) { 42 }
48
- let(:key2) { 'bar' }
49
- let(:value2) { "baz" }
50
- let(:cfg) do
51
- {key1 => value1, key2 => value2}
52
- end
53
-
54
- it "must call system with 'rustc', --cfg='key=value' arguments, and the source files" do
55
- expect(subject).to receive(:system).with(
56
- 'rustc', '--cfg', "#{key1}=\"#{value1}\"",
57
- '--cfg', "#{key2}=\"#{value2}\"",
58
- *source_files
59
- ).and_return(true)
60
-
61
- subject.compile(*source_files, cfg: cfg)
62
- end
63
- end
64
-
65
- context "and it's an Array" do
66
- let(:value1) { :foo }
67
- let(:value2) { "baz" }
68
- let(:cfg) { [value1, value2] }
69
-
70
- it "must call system with 'rustc', --cfg='key=value' arguments, and the source files" do
71
- expect(subject).to receive(:system).with(
72
- 'rustc', '--cfg', value1.to_s, '--cfg', value2.to_s, *source_files
73
- ).and_return(true)
74
-
75
- subject.compile(*source_files, cfg: cfg)
76
- end
77
- end
78
-
79
- context "but it's not a Hash or an Array" do
80
- let(:cfg) { Object.new }
81
-
82
- it do
83
- expect {
84
- subject.compile(*source_files, cfg: cfg)
85
- }.to raise_error(ArgumentError,"cfg value must be either a Hash or an Array: #{cfg.inspect}")
86
- end
87
- end
88
- end
89
-
90
- context "when system() returns false" do
91
- let(:output) { 'output' }
92
- let(:source_file) { 'foo.rs' }
93
-
94
- it do
95
- allow(subject).to receive(:system).and_return(false)
96
-
97
- expect {
98
- subject.compile(source_file, output: output)
99
- }.to raise_error(Ronin::Payloads::BuildFailed,"rustc command failed: rustc -o #{output} #{source_file}")
100
- end
101
- end
102
-
103
- context "when system() returns nil" do
104
- let(:output) { 'output' }
105
- let(:source_file) { 'foo.rs' }
106
-
107
- it do
108
- allow(subject).to receive(:system).and_return(nil)
109
-
110
- expect {
111
- subject.compile(source_file, output: output)
112
- }.to raise_error(Ronin::Payloads::BuildFailed,"rustc command not installed")
113
- end
114
- end
115
- end
116
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/shell_payload'
3
-
4
- describe Ronin::Payloads::ShellPayload do
5
- it "must inherit from Ronin::Payloads::CommandPayload" do
6
- expect(described_class.superclass).to be(Ronin::Payloads::CommandPayload)
7
- end
8
-
9
- describe ".encoder_class" do
10
- subject { described_class }
11
-
12
- it do
13
- expect(subject.encoder_class).to be(Ronin::Payloads::Encoders::ShellEncoder)
14
- end
15
- end
16
- end