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,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders/xml_encoder'
3
-
4
- describe Ronin::Payloads::Encoders::XMLEncoder 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,25 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/encoders'
3
- require 'ronin/payloads/root'
4
-
5
- describe Ronin::Payloads::Encoders do
6
- it "must include Ronin::Core::ClassRegistry" do
7
- expect(subject).to include(Ronin::Core::ClassRegistry)
8
- end
9
-
10
- it "must include Ronin::Repos::ClassDir" do
11
- expect(subject).to include(Ronin::Repos::ClassDir)
12
- end
13
-
14
- it "must set .class_dir to 'ronin/payloads/encoders/builtin'" do
15
- expect(subject.class_dir).to eq(
16
- File.join(
17
- Ronin::Payloads::ROOT, 'lib', 'ronin', 'payloads', 'encoders', 'builtin'
18
- )
19
- )
20
- end
21
-
22
- it "must set .repo_class_dir to 'encoders'" do
23
- expect(subject.repo_class_dir).to eq('encoders')
24
- end
25
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/go_payload'
3
-
4
- describe Ronin::Payloads::GoPayload 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.go bar.go baz.go] }
11
-
12
- it "must call system with `go build` and source files" do
13
- expect(subject).to receive(:system).with(
14
- 'go', 'build', *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 'go build', the output, and source files" do
24
- expect(subject).to receive(:system).with(
25
- 'go', 'build','-o', output, *source_files
26
- ).and_return(true)
27
-
28
- subject.compile(*source_files, output: output)
29
- end
30
- end
31
-
32
- context "when system() returns false" do
33
- let(:source_file) { 'foo.go' }
34
-
35
- it do
36
- allow(subject).to receive(:system).and_return(false)
37
-
38
- expect {
39
- subject.compile(source_file)
40
- }.to raise_error(Ronin::Payloads::BuildFailed,"go command failed: go build #{source_file}")
41
- end
42
- end
43
-
44
- context "when system() returns nil" do
45
- let(:source_file) { 'foo.go' }
46
-
47
- it do
48
- allow(subject).to receive(:system).and_return(nil)
49
-
50
- expect {
51
- subject.compile(source_file)
52
- }.to raise_error(Ronin::Payloads::BuildFailed,"go command not installed")
53
- end
54
- end
55
- end
56
- end
@@ -1,9 +0,0 @@
1
- require 'ronin/encoders/encoder'
2
-
3
- module Helpers
4
- ENCODERS_DIR = File.expand_path(File.join(File.dirname(__FILE__),'scripts','encoders'))
5
-
6
- def load_encoder(name,base=Ronin::Encoders::Encoder)
7
- base.load_object(File.join(ENCODERS_DIR,"#{name}.rb"))
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require 'ronin/payloads/payload'
2
-
3
- module Helpers
4
- PAYLOADS_DIR = File.expand_path(File.join(File.dirname(__FILE__),'scripts','payloads'))
5
-
6
- def load_payload(name,base=Ronin::Payloads::Payload)
7
- base.load_object(File.join(PAYLOADS_DIR,"#{name}.rb"))
8
- end
9
- end
@@ -1,22 +0,0 @@
1
- require 'ronin/payloads/payload'
2
-
3
- Ronin::Payloads::Payload.object do
4
- parameter :custom,
5
- :type => Symbol,
6
- :default => :func,
7
- :description => 'Custom value to use in building the payload'
8
-
9
- cache do
10
- self.name = 'simple'
11
-
12
- author :name => 'Anonymous', :email => 'anonymous@example.com'
13
- end
14
-
15
- build do
16
- @raw_payload = "code.#{@custom}"
17
- end
18
-
19
- def some_method
20
- :some_result
21
- end
22
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/html_payload'
3
-
4
- describe Ronin::Payloads::HTMLPayload do
5
- describe ".encoder_class" do
6
- subject { described_class }
7
-
8
- it do
9
- expect(subject.encoder_class).to be(Ronin::Payloads::Encoders::HTMLEncoder)
10
- end
11
- end
12
- end
@@ -1,97 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/java_payload'
3
-
4
- describe Ronin::Payloads::JavaPayload do
5
- it "must inherit from Ronin::Payloads::Payload" do
6
- expect(described_class).to be < Ronin::Payloads::Payload
7
- end
8
-
9
- describe ".javac" do
10
- subject { described_class }
11
-
12
- context "when ENV['JAVAC'] is set" do
13
- let(:javac) { '/path/to/javac' }
14
-
15
- before { ENV['JAVAC'] = javac }
16
-
17
- it "must return ENV['JAVAC']" do
18
- expect(subject.javac).to eq(javac)
19
- end
20
- end
21
-
22
- context "when ENV['JAVAC'] is not set" do
23
- before(:all) do
24
- @javac = ENV['JAVAC']
25
- ENV.delete('JAVAC')
26
- end
27
-
28
- it "must return 'javac'" do
29
- expect(subject.javac).to eq('javac')
30
- end
31
-
32
- after(:all) do
33
- ENV['JAVAC'] = @javac if @javac
34
- end
35
- end
36
- end
37
-
38
- describe "params" do
39
- subject { described_class }
40
-
41
- it "must define a :javac param" do
42
- expect(subject.params[:javac]).to_not be_nil
43
- end
44
-
45
- it "must default the :javac param to #{described_class}.javac" do
46
- expect(subject.params[:javac].default_value).to eq(subject.javac)
47
- end
48
- end
49
-
50
- describe "#compile" do
51
- let(:source_files) { %w[foo.java bar.java baz.java] }
52
-
53
- it "must call system with params[:javac] and additional arguments" do
54
- expect(subject).to receive(:system).with(
55
- subject.params[:javac], *source_files
56
- ).and_return(true)
57
-
58
- subject.compile(*source_files)
59
- end
60
-
61
- context "when the dest_dir: keyword argument is given" do
62
- let(:dest_dir) { '/path/to/dest/dir' }
63
-
64
- it "must pass the `-d` option to the `javac` command" do
65
- expect(subject).to receive(:system).with(
66
- subject.params[:javac], '-d', dest_dir, *source_files
67
- ).and_return(true)
68
-
69
- subject.compile(*source_files, dest_dir: dest_dir)
70
- end
71
- end
72
-
73
- context "when system() returns false" do
74
- let(:source_file) { 'Foo.java' }
75
-
76
- it do
77
- allow(subject).to receive(:system).and_return(false)
78
-
79
- expect {
80
- subject.compile(source_file)
81
- }.to raise_error(Ronin::Payloads::BuildFailed,"javac command failed: #{subject.params[:javac]} #{source_file}")
82
- end
83
- end
84
-
85
- context "when system() returns nil" do
86
- let(:source_file) { 'Foo.java' }
87
-
88
- it do
89
- allow(subject).to receive(:system).and_return(nil)
90
-
91
- expect {
92
- subject.compile(source_file)
93
- }.to raise_error(Ronin::Payloads::BuildFailed,"javac command not installed")
94
- end
95
- end
96
- end
97
- end
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/javascript_payload'
3
-
4
- describe Ronin::Payloads::JavaScriptPayload do
5
- describe ".encoder_class" do
6
- subject { described_class }
7
-
8
- it do
9
- expect(subject.encoder_class).to be(Ronin::Payloads::Encoders::JavaScriptEncoder)
10
- end
11
- end
12
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/jsp_payload'
3
-
4
- describe Ronin::Payloads::JSPPayload do
5
- it "must inherit from Ronin::Payloads::Payload" do
6
- expect(described_class).to be < Ronin::Payloads::Payload
7
- end
8
- end
@@ -1,82 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/metadata/arch'
3
-
4
- describe Ronin::Payloads::Metadata::Arch do
5
- module TestMetadataArch
6
- class WithNoArchSet
7
- include Ronin::Payloads::Metadata::Arch
8
- end
9
-
10
- class WithArchSet
11
- include Ronin::Payloads::Metadata::Arch
12
-
13
- arch :x86_64
14
- end
15
-
16
- class InheritsItsArch < WithArchSet
17
- include Ronin::Payloads::Metadata::Arch
18
- end
19
-
20
- class OverridesItsInheritedArch < WithArchSet
21
- include Ronin::Payloads::Metadata::Arch
22
-
23
- arch :armbe
24
- end
25
- end
26
-
27
- describe ".arch" do
28
- subject { test_class }
29
-
30
- context "and when arch is not set in the class" do
31
- let(:test_class) { TestMetadataArch::WithNoArchSet }
32
-
33
- it "must default to nil" do
34
- expect(subject.arch).to be(nil)
35
- end
36
- end
37
-
38
- context "and when arch is set in the class" do
39
- let(:test_class) { TestMetadataArch::WithArchSet }
40
-
41
- it "must return the set arch" do
42
- expect(subject.arch).to eq(:x86_64)
43
- end
44
- end
45
-
46
- context "but when the arch was set in the superclass" do
47
- let(:test_class) { TestMetadataArch::InheritsItsArch }
48
-
49
- it "must return the arch set in the superclass" do
50
- expect(subject.arch).to eq(:x86_64)
51
- end
52
-
53
- context "but the arch is overridden in the sub-class" do
54
- let(:test_class) { TestMetadataArch::OverridesItsInheritedArch }
55
-
56
- it "must return the arch set in the sub-class" do
57
- expect(subject.arch).to eq(:armbe)
58
- end
59
- end
60
- end
61
- end
62
-
63
- describe "#arch" do
64
- subject { test_class.new }
65
-
66
- context "when the Payload class has .arch set" do
67
- let(:test_class) { TestMetadataArch::WithArchSet }
68
-
69
- it "must return the Payload class'es .arch" do
70
- expect(subject.arch).to eq(test_class.arch)
71
- end
72
- end
73
-
74
- context "when the Payload class does not have .arch set" do
75
- let(:test_class) { TestMetadataArch::WithNoArchSet }
76
-
77
- it "must return nil" do
78
- expect(subject.arch).to be(nil)
79
- end
80
- end
81
- end
82
- end
@@ -1,164 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/metadata/os'
3
-
4
- describe Ronin::Payloads::Metadata::OS do
5
- module TestMetadataOS
6
- class WithNoOSSet
7
- include Ronin::Payloads::Metadata::OS
8
- end
9
-
10
- class WithOSSet
11
- include Ronin::Payloads::Metadata::OS
12
-
13
- os :linux
14
- end
15
-
16
- class InheritsItsOS < WithOSSet
17
- include Ronin::Payloads::Metadata::OS
18
- end
19
-
20
- class OverridesItsInheritedOS < WithOSSet
21
- include Ronin::Payloads::Metadata::OS
22
-
23
- os :macos
24
- end
25
-
26
- class WithNoOSVersionSet
27
- include Ronin::Payloads::Metadata::OS
28
-
29
- os :linux
30
- end
31
-
32
- class WithOSVersionSet
33
- include Ronin::Payloads::Metadata::OS
34
-
35
- os :linux
36
- os_version '5.x'
37
- end
38
-
39
- class InheritsItsOSVersion < WithOSVersionSet
40
- include Ronin::Payloads::Metadata::OS
41
- end
42
-
43
- class OverridesItsInheritedOSVersion < WithOSVersionSet
44
- include Ronin::Payloads::Metadata::OS
45
-
46
- os :macos
47
- os_version '13'
48
- end
49
- end
50
-
51
- describe ".os" do
52
- subject { test_class }
53
-
54
- context "and when os is not set in the class" do
55
- let(:test_class) { TestMetadataOS::WithNoOSSet }
56
-
57
- it "must default to nil" do
58
- expect(subject.os).to be(nil)
59
- end
60
- end
61
-
62
- context "and when os is set in the class" do
63
- let(:test_class) { TestMetadataOS::WithOSSet }
64
-
65
- it "must return the set os" do
66
- expect(subject.os).to eq(:linux)
67
- end
68
- end
69
-
70
- context "but when the os was set in the superclass" do
71
- let(:test_class) { TestMetadataOS::InheritsItsOS }
72
-
73
- it "must return the os set in the superclass" do
74
- expect(subject.os).to eq(:linux)
75
- end
76
-
77
- context "but the os is overridden in the sub-class" do
78
- let(:test_class) { TestMetadataOS::OverridesItsInheritedOS }
79
-
80
- it "must return the os set in the sub-class" do
81
- expect(subject.os).to eq(:macos)
82
- end
83
- end
84
- end
85
- end
86
-
87
- describe ".os_version" do
88
- subject { test_class }
89
-
90
- context "and when os is not set in the class" do
91
- let(:test_class) { TestMetadataOS::WithNoOSVersionSet }
92
-
93
- it "must default to nil" do
94
- expect(subject.os_version).to be(nil)
95
- end
96
- end
97
-
98
- context "and when os_version is set in the class" do
99
- let(:test_class) { TestMetadataOS::WithOSVersionSet }
100
-
101
- it "must return the set os_version" do
102
- expect(subject.os_version).to eq('5.x')
103
- end
104
- end
105
-
106
- context "but when the os was set in the superclass" do
107
- let(:test_class) { TestMetadataOS::InheritsItsOSVersion }
108
-
109
- it "must return the os_version set in the superclass" do
110
- expect(subject.os_version).to eq('5.x')
111
- end
112
-
113
- context "but the os is overridden in the sub-class" do
114
- let(:test_class) do
115
- TestMetadataOS::OverridesItsInheritedOSVersion
116
- end
117
-
118
- it "must return the os_version set in the sub-class" do
119
- expect(subject.os_version).to eq('13')
120
- end
121
- end
122
- end
123
- end
124
-
125
- describe "#os" do
126
- subject { test_class.new }
127
-
128
- context "when the Payload class has .os set" do
129
- let(:test_class) { TestMetadataOS::WithOSSet }
130
-
131
- it "must return the Payload classes .os" do
132
- expect(subject.os).to eq(test_class.os)
133
- end
134
- end
135
-
136
- context "when the Payload class does not have .os set" do
137
- let(:test_class) { TestMetadataOS::WithNoOSSet }
138
-
139
- it "must return nil" do
140
- expect(subject.os).to be(nil)
141
- end
142
- end
143
- end
144
-
145
- describe "#os_version" do
146
- subject { test_class.new }
147
-
148
- context "when the Payload class has .os_version set" do
149
- let(:test_class) { TestMetadataOS::WithOSVersionSet }
150
-
151
- it "must return the Payload classes .os_version" do
152
- expect(subject.os_version).to eq(test_class.os_version)
153
- end
154
- end
155
-
156
- context "when the Payload class does not have .os_version set" do
157
- let(:test_class) { TestMetadataOS::WithNoOSVersionSet }
158
-
159
- it "must return nil" do
160
- expect(subject.os_version).to be(nil)
161
- end
162
- end
163
- end
164
- end
@@ -1,129 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/payloads/mixins/binary'
3
-
4
- require 'ronin/payloads/payload'
5
- require 'ronin/payloads/metadata/arch'
6
- require 'ronin/payloads/metadata/os'
7
-
8
- describe Ronin::Payloads::Mixins::Binary do
9
- module TestBinaryMixin
10
- class PayloadWithArchSet < Ronin::Payloads::Payload
11
- include Ronin::Payloads::Metadata::Arch
12
- include Ronin::Payloads::Mixins::Binary
13
-
14
- arch :x86
15
- end
16
-
17
- class PayloadWithoutArch < Ronin::Payloads::Payload
18
- include Ronin::Payloads::Mixins::Binary
19
- end
20
-
21
- class PayloadWithoutArchSet < Ronin::Payloads::Payload
22
- include Ronin::Payloads::Metadata::Arch
23
- include Ronin::Payloads::Mixins::Binary
24
- end
25
-
26
- class PayloadWithArchSetButWithoutOSSet < Ronin::Payloads::Payload
27
- include Ronin::Payloads::Metadata::Arch
28
- include Ronin::Payloads::Metadata::OS
29
- include Ronin::Payloads::Mixins::Binary
30
-
31
- arch :x86
32
- end
33
-
34
- class PayloadWithArchAndOSSet < Ronin::Payloads::Payload
35
- include Ronin::Payloads::Metadata::Arch
36
- include Ronin::Payloads::Metadata::OS
37
- include Ronin::Payloads::Mixins::Binary
38
-
39
- arch :x86
40
- os :linux
41
- end
42
- end
43
-
44
- subject { payload_class.new }
45
-
46
- describe "#perform_validate" do
47
- context "when the payload class does not define an #arch method" do
48
- let(:payload_class) { TestBinaryMixin::PayloadWithoutArch }
49
-
50
- it do
51
- expect {
52
- subject.perform_validate
53
- }.to raise_error(Ronin::Payloads::ValidationError,"payload #{payload_class} did not include Ronin::Payloads::Metadata::Arch")
54
- end
55
- end
56
-
57
- context "when the payload class's #arch method returns nil" do
58
- let(:payload_class) { TestBinaryMixin::PayloadWithoutArchSet }
59
-
60
- it do
61
- expect {
62
- subject.perform_validate
63
- }.to raise_error(Ronin::Payloads::ValidationError,"payload #{payload_class} did not include define an architecture")
64
- end
65
- end
66
-
67
- context "when the payload class defines an architecture" do
68
- let(:payload_class) { TestBinaryMixin::PayloadWithArchSet }
69
-
70
- it do
71
- expect {
72
- subject.perform_validate
73
- }.to_not raise_error
74
- end
75
- end
76
- end
77
-
78
- describe "#platform" do
79
- context "when #arch returns nil" do
80
- let(:payload_class) { TestBinaryMixin::PayloadWithoutArchSet }
81
-
82
- it "must return Ronin::Support::Binary::CTypes" do
83
- expect(subject.platform).to be(Ronin::Support::Binary::CTypes)
84
- end
85
- end
86
-
87
- context "when #arch returns a architecture name" do
88
- let(:payload_class) { TestBinaryMixin::PayloadWithArchSet }
89
-
90
- it "must return the according Ronin::Support::Binary::CTypes::Arch:: module" do
91
- expect(subject.platform).to be(Ronin::Support::Binary::CTypes::Arch::X86)
92
- end
93
-
94
- context "and when #os is defined" do
95
- context "and it returns an OS name" do
96
- let(:payload_class) do
97
- TestBinaryMixin::PayloadWithArchAndOSSet
98
- end
99
-
100
- it "must return the according Ronin::Support::Binary::CTypes::OS object with the according Ronin::Support::Binary::CTypes::Arch:: module inside it" do
101
- expect(subject.platform).to be_kind_of(Ronin::Support::Binary::CTypes::OS::Linux)
102
- expect(subject.platform.types).to be(Ronin::Support::Binary::CTypes::Arch::X86)
103
- end
104
- end
105
-
106
- context "but it returns nil" do
107
- let(:payload_class) do
108
- TestBinaryMixin::PayloadWithArchSetButWithoutOSSet
109
- end
110
-
111
- it "must still return the according Ronin::Support::Binary::CTypes::Arch:: module" do
112
- expect(subject.platform).to be(Ronin::Support::Binary::CTypes::Arch::X86)
113
- end
114
- end
115
- end
116
- end
117
- end
118
-
119
- describe "#pack" do
120
- let(:payload_class) { TestBinaryMixin::PayloadWithArchSet }
121
-
122
- let(:type) { :uint32 }
123
- let(:value) { 0x12345678 }
124
-
125
- it "must pack the value using the type from #platform" do
126
- expect(subject.pack(type,value)).to eq("\x78\x56\x34\x12".b)
127
- end
128
- end
129
- end