ronin-exploits 0.3.1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (338) hide show
  1. checksums.yaml +7 -0
  2. data/.document +4 -0
  3. data/.editorconfig +11 -0
  4. data/.github/workflows/ruby.yml +31 -0
  5. data/.gitignore +13 -0
  6. data/.mailmap +1 -0
  7. data/.rspec +1 -0
  8. data/.ruby-version +1 -0
  9. data/.yardopts +1 -0
  10. data/COPYING.txt +161 -335
  11. data/{History.txt → ChangeLog.md} +119 -16
  12. data/Gemfile +50 -0
  13. data/README.md +454 -0
  14. data/Rakefile +37 -23
  15. data/bin/ronin-exploits +13 -6
  16. data/data/new/exploit.rb.erb +158 -0
  17. data/gemspec.yml +44 -0
  18. data/lib/ronin/exploits/advisory.rb +84 -0
  19. data/lib/ronin/exploits/cli/command.rb +39 -0
  20. data/lib/ronin/exploits/cli/commands/irb.rb +57 -0
  21. data/lib/ronin/exploits/cli/commands/list.rb +80 -0
  22. data/lib/ronin/exploits/cli/commands/new.rb +332 -0
  23. data/lib/ronin/exploits/cli/commands/run.rb +396 -0
  24. data/lib/ronin/exploits/cli/commands/show.rb +290 -0
  25. data/lib/ronin/exploits/cli/exploit_command.rb +114 -0
  26. data/lib/ronin/exploits/cli/exploit_methods.rb +114 -0
  27. data/lib/ronin/exploits/cli/ruby_shell.rb +51 -0
  28. data/lib/ronin/exploits/cli.rb +51 -0
  29. data/lib/ronin/exploits/client_side_web_vuln.rb +69 -0
  30. data/lib/ronin/exploits/exceptions.rb +27 -17
  31. data/lib/ronin/exploits/exploit.rb +501 -582
  32. data/lib/ronin/exploits/heap_overflow.rb +50 -0
  33. data/lib/ronin/exploits/lfi.rb +141 -0
  34. data/lib/ronin/exploits/loot/file.rb +113 -0
  35. data/lib/ronin/exploits/loot.rb +119 -0
  36. data/lib/ronin/exploits/memory_corruption.rb +53 -0
  37. data/lib/ronin/exploits/metadata/arch.rb +83 -0
  38. data/lib/ronin/exploits/metadata/cookie_param.rb +80 -0
  39. data/lib/ronin/exploits/metadata/default_filename.rb +69 -0
  40. data/lib/ronin/exploits/metadata/default_port.rb +69 -0
  41. data/lib/ronin/exploits/metadata/header_name.rb +80 -0
  42. data/lib/ronin/exploits/metadata/os.rb +117 -0
  43. data/lib/ronin/exploits/metadata/shouts.rb +85 -0
  44. data/lib/ronin/exploits/metadata/url_path.rb +82 -0
  45. data/lib/ronin/exploits/metadata/url_query_param.rb +80 -0
  46. data/lib/ronin/exploits/mixins/binary.rb +106 -0
  47. data/lib/ronin/exploits/mixins/build_dir.rb +61 -0
  48. data/lib/ronin/exploits/mixins/file_builder.rb +102 -0
  49. data/lib/ronin/exploits/mixins/format_string.rb +87 -0
  50. data/lib/ronin/exploits/mixins/has_payload.rb +202 -0
  51. data/lib/ronin/exploits/mixins/has_targets.rb +297 -0
  52. data/lib/ronin/exploits/mixins/html.rb +213 -0
  53. data/lib/ronin/exploits/mixins/http.rb +866 -0
  54. data/lib/ronin/exploits/mixins/loot.rb +84 -0
  55. data/lib/ronin/exploits/mixins/nops.rb +121 -0
  56. data/lib/ronin/exploits/mixins/remote_tcp.rb +272 -0
  57. data/lib/ronin/exploits/mixins/remote_udp.rb +264 -0
  58. data/lib/ronin/exploits/mixins/seh.rb +136 -0
  59. data/lib/ronin/exploits/mixins/stack_overflow.rb +124 -0
  60. data/lib/ronin/exploits/mixins/text.rb +65 -0
  61. data/lib/ronin/exploits/mixins.rb +32 -0
  62. data/lib/ronin/exploits/open_redirect.rb +103 -0
  63. data/lib/ronin/exploits/params/base_url.rb +84 -0
  64. data/lib/ronin/exploits/params/bind_host.rb +53 -0
  65. data/lib/ronin/exploits/params/bind_port.rb +53 -0
  66. data/lib/ronin/exploits/params/filename.rb +71 -0
  67. data/lib/ronin/exploits/params/host.rb +56 -0
  68. data/lib/ronin/exploits/params/port.rb +71 -0
  69. data/lib/ronin/exploits/registry.rb +32 -0
  70. data/lib/ronin/exploits/rfi.rb +106 -0
  71. data/lib/ronin/exploits/root.rb +28 -0
  72. data/lib/ronin/exploits/seh_overflow.rb +90 -0
  73. data/lib/ronin/exploits/sqli.rb +172 -0
  74. data/lib/ronin/exploits/ssti.rb +108 -0
  75. data/lib/ronin/exploits/stack_overflow.rb +90 -0
  76. data/lib/ronin/exploits/target.rb +63 -103
  77. data/lib/ronin/exploits/test_result.rb +80 -0
  78. data/lib/ronin/exploits/use_after_free.rb +50 -0
  79. data/lib/ronin/exploits/version.rb +11 -12
  80. data/lib/ronin/exploits/web.rb +18 -89
  81. data/lib/ronin/exploits/web_vuln.rb +378 -0
  82. data/lib/ronin/exploits/xss.rb +102 -0
  83. data/lib/ronin/exploits.rb +19 -26
  84. data/man/ronin-exploits-irb.1 +31 -0
  85. data/man/ronin-exploits-irb.1.md +22 -0
  86. data/man/ronin-exploits-list.1 +37 -0
  87. data/man/ronin-exploits-list.1.md +27 -0
  88. data/man/ronin-exploits-new.1 +98 -0
  89. data/man/ronin-exploits-new.1.md +73 -0
  90. data/man/ronin-exploits-run.1 +117 -0
  91. data/man/ronin-exploits-run.1.md +87 -0
  92. data/man/ronin-exploits-show.1 +45 -0
  93. data/man/ronin-exploits-show.1.md +33 -0
  94. data/man/ronin-exploits.1 +55 -0
  95. data/man/ronin-exploits.1.md +41 -0
  96. data/ronin-exploits.gemspec +62 -0
  97. data/spec/advisory_spec.rb +71 -0
  98. data/spec/cli/exploit_command_spec.rb +68 -0
  99. data/spec/cli/exploit_methods_spec.rb +208 -0
  100. data/spec/cli/ruby_shell_spec.rb +14 -0
  101. data/spec/client_side_web_vuln_spec.rb +117 -0
  102. data/spec/exploit_spec.rb +538 -0
  103. data/spec/exploits_spec.rb +3 -4
  104. data/spec/heap_overflow_spec.rb +14 -0
  105. data/spec/lfi_spec.rb +162 -0
  106. data/spec/loot/file_spec.rb +131 -0
  107. data/spec/loot_spec.rb +138 -0
  108. data/spec/memory_corruption_spec.rb +22 -0
  109. data/spec/metadata/arch_spec.rb +82 -0
  110. data/spec/metadata/cookie_param_spec.rb +67 -0
  111. data/spec/metadata/default_filename_spec.rb +62 -0
  112. data/spec/metadata/default_port_spec.rb +62 -0
  113. data/spec/metadata/header_name_spec.rb +67 -0
  114. data/spec/metadata/os_spec.rb +164 -0
  115. data/spec/metadata/shouts_spec.rb +100 -0
  116. data/spec/metadata/url_path_spec.rb +67 -0
  117. data/spec/metadata/url_query_param_spec.rb +67 -0
  118. data/spec/mixins/binary_spec.rb +129 -0
  119. data/spec/mixins/build_dir.rb +66 -0
  120. data/spec/mixins/file_builder_spec.rb +67 -0
  121. data/spec/mixins/format_string_spec.rb +44 -0
  122. data/spec/mixins/has_payload_spec.rb +333 -0
  123. data/spec/mixins/has_targets_spec.rb +434 -0
  124. data/spec/mixins/html_spec.rb +772 -0
  125. data/spec/mixins/http_spec.rb +1227 -0
  126. data/spec/mixins/loot_spec.rb +20 -0
  127. data/spec/mixins/nops_spec.rb +165 -0
  128. data/spec/mixins/remote_tcp_spec.rb +217 -0
  129. data/spec/mixins/remote_udp_spec.rb +217 -0
  130. data/spec/mixins/seh_spec.rb +89 -0
  131. data/spec/mixins/stack_overflow_spec.rb +87 -0
  132. data/spec/mixins/text_spec.rb +43 -0
  133. data/spec/open_redirect_spec.rb +71 -0
  134. data/spec/params/base_url_spec.rb +71 -0
  135. data/spec/params/bind_host_spec.rb +34 -0
  136. data/spec/params/bind_port_spec.rb +35 -0
  137. data/spec/params/filename_spec.rb +77 -0
  138. data/spec/params/host_spec.rb +34 -0
  139. data/spec/params/port_spec.rb +77 -0
  140. data/spec/rfi_spec.rb +107 -0
  141. data/spec/seh_overflow_spec.rb +18 -0
  142. data/spec/spec_helper.rb +6 -10
  143. data/spec/sqli_spec.rb +306 -0
  144. data/spec/ssti_spec.rb +121 -0
  145. data/spec/stack_overflow_spec.rb +18 -0
  146. data/spec/target_spec.rb +92 -0
  147. data/spec/test_result_spec.rb +32 -0
  148. data/spec/use_after_free_spec.rb +14 -0
  149. data/spec/web_spec.rb +12 -0
  150. data/spec/web_vuln_spec.rb +854 -0
  151. data/spec/xss_spec.rb +69 -0
  152. metadata +361 -324
  153. data/Manifest.txt +0 -196
  154. data/README.txt +0 -274
  155. data/bin/ronin-exploit +0 -12
  156. data/bin/ronin-gen-binary-payload +0 -12
  157. data/bin/ronin-gen-exploit +0 -12
  158. data/bin/ronin-gen-ftp-exploit +0 -12
  159. data/bin/ronin-gen-http-exploit +0 -12
  160. data/bin/ronin-gen-local-exploit +0 -12
  161. data/bin/ronin-gen-nops +0 -12
  162. data/bin/ronin-gen-payload +0 -12
  163. data/bin/ronin-gen-remote-exploit +0 -12
  164. data/bin/ronin-gen-remote-tcp-exploit +0 -12
  165. data/bin/ronin-gen-remote-udp-exploit +0 -12
  166. data/bin/ronin-gen-shellcode +0 -12
  167. data/bin/ronin-gen-web-exploit +0 -12
  168. data/bin/ronin-payload +0 -12
  169. data/bin/ronin-payloads +0 -12
  170. data/lib/ronin/controls/behaviors.rb +0 -133
  171. data/lib/ronin/controls/exceptions/not_implemented.rb +0 -27
  172. data/lib/ronin/controls/exceptions/program_not_found.rb +0 -27
  173. data/lib/ronin/controls/exceptions.rb +0 -23
  174. data/lib/ronin/controls/file_system.rb +0 -145
  175. data/lib/ronin/controls/helpers/command_exec.rb +0 -143
  176. data/lib/ronin/controls/helpers/dir_create.rb +0 -42
  177. data/lib/ronin/controls/helpers/dir_listing.rb +0 -62
  178. data/lib/ronin/controls/helpers/dir_remove.rb +0 -42
  179. data/lib/ronin/controls/helpers/file_ctime.rb +0 -52
  180. data/lib/ronin/controls/helpers/file_mtime.rb +0 -53
  181. data/lib/ronin/controls/helpers/file_ownership.rb +0 -53
  182. data/lib/ronin/controls/helpers/file_read.rb +0 -62
  183. data/lib/ronin/controls/helpers/file_remove.rb +0 -51
  184. data/lib/ronin/controls/helpers/file_write.rb +0 -62
  185. data/lib/ronin/controls/helpers/memory_read.rb +0 -39
  186. data/lib/ronin/controls/helpers/memory_write.rb +0 -39
  187. data/lib/ronin/controls/helpers.rb +0 -33
  188. data/lib/ronin/controls.rb +0 -23
  189. data/lib/ronin/exploits/control.rb +0 -47
  190. data/lib/ronin/exploits/exceptions/exception.rb +0 -27
  191. data/lib/ronin/exploits/exceptions/exploit_not_built.rb +0 -29
  192. data/lib/ronin/exploits/exceptions/payload_size.rb +0 -29
  193. data/lib/ronin/exploits/exceptions/restricted_char.rb +0 -29
  194. data/lib/ronin/exploits/exceptions/target_data_missing.rb +0 -29
  195. data/lib/ronin/exploits/exceptions/target_unspecified.rb +0 -29
  196. data/lib/ronin/exploits/exceptions/unknown_helper.rb +0 -29
  197. data/lib/ronin/exploits/exploit_author.rb +0 -33
  198. data/lib/ronin/exploits/ftp.rb +0 -42
  199. data/lib/ronin/exploits/helpers/binary.rb +0 -50
  200. data/lib/ronin/exploits/helpers/buffer_overflow.rb +0 -115
  201. data/lib/ronin/exploits/helpers/file_based.rb +0 -112
  202. data/lib/ronin/exploits/helpers/format_string.rb +0 -117
  203. data/lib/ronin/exploits/helpers/padding.rb +0 -101
  204. data/lib/ronin/exploits/helpers.rb +0 -26
  205. data/lib/ronin/exploits/http.rb +0 -49
  206. data/lib/ronin/exploits/local.rb +0 -40
  207. data/lib/ronin/exploits/remote.rb +0 -40
  208. data/lib/ronin/exploits/remote_tcp.rb +0 -87
  209. data/lib/ronin/exploits/remote_udp.rb +0 -87
  210. data/lib/ronin/exploits/targets/buffer_overflow.rb +0 -46
  211. data/lib/ronin/exploits/targets/format_string.rb +0 -43
  212. data/lib/ronin/exploits/targets.rb +0 -27
  213. data/lib/ronin/exploits/verifiers.rb +0 -121
  214. data/lib/ronin/generators/exploits/exploit.rb +0 -70
  215. data/lib/ronin/generators/exploits/ftp.rb +0 -42
  216. data/lib/ronin/generators/exploits/http.rb +0 -42
  217. data/lib/ronin/generators/exploits/local.rb +0 -42
  218. data/lib/ronin/generators/exploits/remote.rb +0 -42
  219. data/lib/ronin/generators/exploits/remote_tcp.rb +0 -44
  220. data/lib/ronin/generators/exploits/remote_udp.rb +0 -44
  221. data/lib/ronin/generators/exploits/static.rb +0 -30
  222. data/lib/ronin/generators/exploits/web.rb +0 -45
  223. data/lib/ronin/generators/exploits.rb +0 -23
  224. data/lib/ronin/generators/payloads/binary_payload.rb +0 -42
  225. data/lib/ronin/generators/payloads/nops.rb +0 -42
  226. data/lib/ronin/generators/payloads/payload.rb +0 -66
  227. data/lib/ronin/generators/payloads/shellcode.rb +0 -42
  228. data/lib/ronin/generators/payloads/static.rb +0 -30
  229. data/lib/ronin/generators/payloads.rb +0 -23
  230. data/lib/ronin/model/has_default_port.rb +0 -54
  231. data/lib/ronin/model/targets_arch.rb +0 -68
  232. data/lib/ronin/model/targets_os.rb +0 -69
  233. data/lib/ronin/model/targets_product.rb +0 -68
  234. data/lib/ronin/payloads/asm_payload.rb +0 -40
  235. data/lib/ronin/payloads/binary_payload.rb +0 -42
  236. data/lib/ronin/payloads/control.rb +0 -47
  237. data/lib/ronin/payloads/encoders/encoder.rb +0 -92
  238. data/lib/ronin/payloads/encoders/xor.rb +0 -79
  239. data/lib/ronin/payloads/encoders.rb +0 -32
  240. data/lib/ronin/payloads/exceptions/exception.rb +0 -27
  241. data/lib/ronin/payloads/exceptions/not_implemented.rb +0 -29
  242. data/lib/ronin/payloads/exceptions/unknown_helper.rb +0 -29
  243. data/lib/ronin/payloads/exceptions.rb +0 -23
  244. data/lib/ronin/payloads/has_payload.rb +0 -111
  245. data/lib/ronin/payloads/helpers/chained.rb +0 -61
  246. data/lib/ronin/payloads/helpers/rpc.rb +0 -93
  247. data/lib/ronin/payloads/helpers.rb +0 -23
  248. data/lib/ronin/payloads/nops.rb +0 -39
  249. data/lib/ronin/payloads/payload.rb +0 -350
  250. data/lib/ronin/payloads/payload_author.rb +0 -33
  251. data/lib/ronin/payloads/shellcode.rb +0 -40
  252. data/lib/ronin/payloads/web_payload.rb +0 -41
  253. data/lib/ronin/payloads.rb +0 -36
  254. data/lib/ronin/ui/command_line/commands/exploit.rb +0 -193
  255. data/lib/ronin/ui/command_line/commands/exploits.rb +0 -154
  256. data/lib/ronin/ui/command_line/commands/gen_binary_payload.rb +0 -34
  257. data/lib/ronin/ui/command_line/commands/gen_exploit.rb +0 -34
  258. data/lib/ronin/ui/command_line/commands/gen_ftp_exploit.rb +0 -34
  259. data/lib/ronin/ui/command_line/commands/gen_http_exploit.rb +0 -34
  260. data/lib/ronin/ui/command_line/commands/gen_local_exploit.rb +0 -34
  261. data/lib/ronin/ui/command_line/commands/gen_nops.rb +0 -34
  262. data/lib/ronin/ui/command_line/commands/gen_payload.rb +0 -34
  263. data/lib/ronin/ui/command_line/commands/gen_remote_exploit.rb +0 -34
  264. data/lib/ronin/ui/command_line/commands/gen_remote_tcp_exploit.rb +0 -34
  265. data/lib/ronin/ui/command_line/commands/gen_remote_udp_exploit.rb +0 -34
  266. data/lib/ronin/ui/command_line/commands/gen_shellcode.rb +0 -34
  267. data/lib/ronin/ui/command_line/commands/gen_web_exploit.rb +0 -34
  268. data/lib/ronin/ui/command_line/commands/payload.rb +0 -129
  269. data/lib/ronin/ui/command_line/commands/payloads.rb +0 -128
  270. data/lib/ronin/vuln/behavior.rb +0 -165
  271. data/spec/controls/behaviors_examples.rb +0 -38
  272. data/spec/exploits/binary_exploit_spec.rb +0 -44
  273. data/spec/exploits/buffer_overflow_exploit_spec.rb +0 -70
  274. data/spec/exploits/exploit_spec.rb +0 -313
  275. data/spec/exploits/file_based_exploit_spec.rb +0 -48
  276. data/spec/exploits/format_string_exploit_spec.rb +0 -32
  277. data/spec/exploits/ftp_spec.rb +0 -13
  278. data/spec/exploits/http_spec.rb +0 -17
  279. data/spec/exploits/padding_exploit_spec.rb +0 -44
  280. data/spec/exploits/remote_tcp_spec.rb +0 -28
  281. data/spec/exploits/remote_udp_spec.rb +0 -28
  282. data/spec/exploits/target_spec.rb +0 -98
  283. data/spec/exploits/targets/buffer_overflow_spec.rb +0 -22
  284. data/spec/exploits/web_spec.rb +0 -35
  285. data/spec/generators/exploits/exploit_examples.rb +0 -24
  286. data/spec/generators/exploits/exploit_spec.rb +0 -42
  287. data/spec/generators/exploits/ftp_spec.rb +0 -42
  288. data/spec/generators/exploits/http_spec.rb +0 -42
  289. data/spec/generators/exploits/local_spec.rb +0 -42
  290. data/spec/generators/exploits/remote_spec.rb +0 -42
  291. data/spec/generators/exploits/remote_tcp_spec.rb +0 -47
  292. data/spec/generators/exploits/remote_udp_spec.rb +0 -47
  293. data/spec/generators/exploits/web_spec.rb +0 -52
  294. data/spec/generators/payloads/binary_payload_spec.rb +0 -31
  295. data/spec/generators/payloads/nops_spec.rb +0 -31
  296. data/spec/generators/payloads/payload_examples.rb +0 -16
  297. data/spec/generators/payloads/payload_spec.rb +0 -31
  298. data/spec/generators/payloads/shellcode_spec.rb +0 -31
  299. data/spec/helpers/database.rb +0 -5
  300. data/spec/helpers/objects.rb +0 -22
  301. data/spec/model/has_default_port_spec.rb +0 -27
  302. data/spec/model/models/default_port_model.rb +0 -13
  303. data/spec/model/models/non_default_port_model.rb +0 -11
  304. data/spec/model/models/targets_arch_model.rb +0 -11
  305. data/spec/model/models/targets_os_model.rb +0 -11
  306. data/spec/model/models/targets_product_model.rb +0 -11
  307. data/spec/model/targets_arch_spec.rb +0 -32
  308. data/spec/model/targets_os_spec.rb +0 -33
  309. data/spec/model/targets_product_spec.rb +0 -35
  310. data/spec/objects/exploits/example.rb +0 -25
  311. data/spec/objects/exploits/simple.rb +0 -24
  312. data/spec/objects/payloads/simple.rb +0 -19
  313. data/spec/payloads/encoders/encoder_spec.rb +0 -30
  314. data/spec/payloads/encoders/xor_spec.rb +0 -20
  315. data/spec/payloads/payload_spec.rb +0 -156
  316. data/spec/vuln/behavior_spec.rb +0 -15
  317. data/static/ronin/generators/exploits/_cache.erb +0 -14
  318. data/static/ronin/generators/exploits/_header.erb +0 -1
  319. data/static/ronin/generators/exploits/_helpers.erb +0 -4
  320. data/static/ronin/generators/exploits/exploit.erb +0 -24
  321. data/static/ronin/generators/exploits/ftp.erb +0 -24
  322. data/static/ronin/generators/exploits/http.erb +0 -26
  323. data/static/ronin/generators/exploits/local.erb +0 -24
  324. data/static/ronin/generators/exploits/remote.erb +0 -24
  325. data/static/ronin/generators/exploits/remote_tcp.erb +0 -26
  326. data/static/ronin/generators/exploits/remote_udp.erb +0 -26
  327. data/static/ronin/generators/exploits/web.erb +0 -28
  328. data/static/ronin/generators/payloads/_cache.erb +0 -10
  329. data/static/ronin/generators/payloads/_header.erb +0 -1
  330. data/static/ronin/generators/payloads/_helpers.erb +0 -2
  331. data/static/ronin/generators/payloads/binary_payload.erb +0 -25
  332. data/static/ronin/generators/payloads/nops.erb +0 -19
  333. data/static/ronin/generators/payloads/payload.erb +0 -25
  334. data/static/ronin/generators/payloads/shellcode.erb +0 -25
  335. data/tasks/spec.rb +0 -10
  336. data/tasks/yard.rb +0 -13
  337. data.tar.gz.sig +0 -0
  338. metadata.gz.sig +0 -0
@@ -0,0 +1,1227 @@
1
+ require 'spec_helper'
2
+ require 'ronin/exploits/mixins/http'
3
+ require 'ronin/exploits/exploit'
4
+
5
+ describe Ronin::Exploits::Mixins::HTTP do
6
+ module TestMixinsHTTP
7
+ class TestExploit < Ronin::Exploits::Exploit
8
+ include Ronin::Exploits::Mixins::HTTP
9
+ end
10
+
11
+ class TestExploitWithDefaultHeaders < Ronin::Exploits::Exploit
12
+ include Ronin::Exploits::Mixins::HTTP
13
+
14
+ def http_headers
15
+ {'X-Foo' => 'bar'}
16
+ end
17
+ end
18
+ end
19
+
20
+ let(:test_class) { TestMixinsHTTP::TestExploit }
21
+
22
+ describe ".included" do
23
+ subject { test_class }
24
+
25
+ it "must define a 'http_proxy' param" do
26
+ expect(subject.params[:http_proxy]).to_not be_nil
27
+ expect(subject.params[:http_proxy].desc).to eq("The HTTP proxy to use")
28
+ end
29
+
30
+ it "must define a 'user_agent' param" do
31
+ expect(subject.params[:user_agent]).to_not be_nil
32
+ expect(subject.params[:user_agent].type).to be_kind_of(Ronin::Core::Params::Types::Enum)
33
+ expect(subject.params[:user_agent].type.values).to eq(
34
+ [
35
+ :random,
36
+ :chrome,
37
+ :firefox,
38
+ :safari,
39
+ :linux,
40
+ :macos,
41
+ :windows,
42
+ :iphone,
43
+ :ipad,
44
+ :android
45
+ ] + Ronin::Support::Network::HTTP::UserAgents::ALIASES.keys
46
+ )
47
+ expect(subject.params[:user_agent].desc).to eq("The HTTP User-Agent to select")
48
+ end
49
+
50
+ it "must define a 'raw_user_agent' param" do
51
+ expect(subject.params[:raw_user_agent]).to_not be_nil
52
+ expect(subject.params[:raw_user_agent].desc).to eq("The raw HTTP User-Agent string to use")
53
+ end
54
+ end
55
+
56
+ let(:base_url) { URI.parse("https://www.example.com/base") }
57
+
58
+ subject do
59
+ test_class.new(params: {base_url: base_url})
60
+ end
61
+
62
+ describe "#http_proxy" do
63
+ let(:proxy) { 'http://example.com:8080' }
64
+
65
+ subject do
66
+ test_class.new(params: {base_url: base_url, http_proxy: proxy})
67
+ end
68
+
69
+ it "must return params[:http_proxy]" do
70
+ expect(subject.http_proxy).to be(subject.params[:http_proxy])
71
+ end
72
+ end
73
+
74
+ describe "#http_headers" do
75
+ it "must return an empty Hash by default" do
76
+ expect(subject.http_headers).to eq({})
77
+ end
78
+ end
79
+
80
+ describe "#http_user_agent" do
81
+ context "when params[:user_agent] is set" do
82
+ let(:user_agent) { :random }
83
+
84
+ subject do
85
+ test_class.new(
86
+ params: {
87
+ base_url: base_url,
88
+ user_agent: user_agent
89
+ }
90
+ )
91
+ end
92
+
93
+ it "must return params[:user_agent]" do
94
+ expect(subject.http_user_agent).to be(subject.params[:user_agent])
95
+ end
96
+ end
97
+
98
+ context "when params[:raw_user_agent] is set" do
99
+ let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
100
+
101
+ subject do
102
+ test_class.new(
103
+ params: {
104
+ base_url: base_url,
105
+ raw_user_agent: raw_user_agent
106
+ }
107
+ )
108
+ end
109
+
110
+ it "must return params[:raw_user_agent]" do
111
+ expect(subject.http_user_agent).to be(
112
+ subject.params[:raw_user_agent]
113
+ )
114
+ end
115
+ end
116
+
117
+ context "when both params[:user_agent] and params[:raw_user_agent] are set" do
118
+ let(:user_agent) { :random }
119
+ let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
120
+
121
+ subject do
122
+ test_class.new(
123
+ params: {
124
+ base_url: base_url,
125
+ user_agent: user_agent,
126
+ raw_user_agent: raw_user_agent
127
+ }
128
+ )
129
+ end
130
+
131
+ it "must return params[:raw_user_agent]" do
132
+ expect(subject.http_user_agent).to be(
133
+ subject.params[:raw_user_agent]
134
+ )
135
+ end
136
+ end
137
+ end
138
+
139
+ describe "#http_cookie" do
140
+ context "when the http_cookie param is set" do
141
+ let(:cookie) { "foo=1; bar=2" }
142
+
143
+ subject do
144
+ test_class.new(
145
+ params: {
146
+ base_url: base_url,
147
+ http_cookie: cookie
148
+ }
149
+ )
150
+ end
151
+
152
+ it "must return params[:http_cookie]" do
153
+ expect(subject.http_cookie).to eq(cookie)
154
+ end
155
+ end
156
+ end
157
+
158
+ let(:proxy) { URI('https://proxy.example.com:8080') }
159
+ let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
160
+ let(:cookie) { "foo=1; bar=2" }
161
+ let(:user) { 'bob' }
162
+ let(:password) { 'secret' }
163
+
164
+ subject do
165
+ test_class.new(
166
+ params: {
167
+ base_url: base_url,
168
+ http_proxy: proxy,
169
+ raw_user_agent: raw_user_agent,
170
+ http_cookie: cookie,
171
+ http_user: user,
172
+ http_password: password
173
+ }
174
+ )
175
+ end
176
+
177
+ describe "#http" do
178
+ it "must call Ronin::Support::Network::HTTP.connect_uri with #params[:base_url], proxy: #http_proxy, headers: #http_headers, user_agent: #http_user_agent, cookie: #http_cookie, user: #http_user, password: #http_password" do
179
+ expect(Ronin::Support::Network::HTTP).to receive(:connect_uri).with(
180
+ subject.params[:base_url], proxy: subject.http_proxy,
181
+ headers: subject.http_headers,
182
+ user_agent: subject.http_user_agent,
183
+ cookie: subject.http_cookie,
184
+ user: subject.http_user,
185
+ password: subject.http_password
186
+ )
187
+
188
+ subject.http
189
+ end
190
+
191
+ it "must return a Ronin::Support::Network::HTTP instance" do
192
+ expect(subject.http).to be_kind_of(Ronin::Support::Network::HTTP)
193
+ end
194
+
195
+ it "must return the same instance each time" do
196
+ expect(subject.http).to be(subject.http)
197
+ end
198
+
199
+ context "when #http_headers is overriden" do
200
+ let(:test_class) { TestMixinsHTTP::TestExploitWithDefaultHeaders }
201
+
202
+ it "must initialize #http.headers to the value of #http_headers" do
203
+ expect(subject.http.headers).to eq(subject.http_headers)
204
+ end
205
+ end
206
+ end
207
+
208
+ describe "#http_request" do
209
+ context "when given a request method and a path" do
210
+ let(:request_method) { :get }
211
+ let(:path) { '/foo' }
212
+
213
+ it "must call #http.request with the request method and path" do
214
+ expect(subject.http).to receive(:request).with(request_method,path)
215
+
216
+ subject.http_request(request_method,path)
217
+ end
218
+
219
+ context "when debug messages are enabled" do
220
+ before { Ronin::Support::CLI::Printing.debug = true }
221
+
222
+ it "must print a debugging message" do
223
+ url = subject.url_for(path)
224
+
225
+ allow(subject.http).to receive(:request).with(
226
+ request_method, path
227
+ )
228
+
229
+ expect(subject).to receive(:print_debug).with(
230
+ "Sending #{request_method.upcase} request to #{url} ..."
231
+ )
232
+
233
+ subject.http_request(request_method,path)
234
+ end
235
+
236
+ after { Ronin::Support::CLI::Printing.debug = false }
237
+ end
238
+ end
239
+ end
240
+
241
+ describe "#http_response_status" do
242
+ context "when given a request method and a path" do
243
+ let(:request_method) { :get }
244
+ let(:path) { '/foo' }
245
+
246
+ it "must call #http.response_status with the request method and path" do
247
+ expect(subject.http).to receive(:response_status).with(
248
+ request_method, path
249
+ )
250
+
251
+ subject.http_response_status(request_method,path)
252
+ end
253
+
254
+ context "when debug messages are enabled" do
255
+ before { Ronin::Support::CLI::Printing.debug = true }
256
+
257
+ it "must print a debugging message" do
258
+ url = subject.url_for(path)
259
+
260
+ allow(subject.http).to receive(:response_status).with(
261
+ request_method, path
262
+ )
263
+
264
+ expect(subject).to receive(:print_debug).with(
265
+ "Checking response status for #{request_method.upcase} #{url} ..."
266
+ )
267
+
268
+ subject.http_response_status(request_method,path)
269
+ end
270
+
271
+ after { Ronin::Support::CLI::Printing.debug = false }
272
+ end
273
+ end
274
+ end
275
+
276
+ describe "#http_ok?" do
277
+ context "when given a path" do
278
+ let(:path) { '/foo' }
279
+
280
+ it "must call #http.ok? with :head and the path" do
281
+ expect(subject.http).to receive(:ok?).with(:head,path)
282
+
283
+ subject.http_ok?(path)
284
+ end
285
+
286
+ context "when debug messages are enabled" do
287
+ before { Ronin::Support::CLI::Printing.debug = true }
288
+
289
+ it "must print a debugging message" do
290
+ url = subject.url_for(path)
291
+
292
+ allow(subject.http).to receive(:ok?).with(:head,path)
293
+
294
+ expect(subject).to receive(:print_debug).with(
295
+ "Checking if response status for HEAD #{url} is 200 ..."
296
+ )
297
+
298
+ subject.http_ok?(path)
299
+ end
300
+
301
+ after { Ronin::Support::CLI::Printing.debug = false }
302
+ end
303
+ end
304
+
305
+ context "when given a request method and a path" do
306
+ let(:request_method) { :get }
307
+ let(:path) { '/foo' }
308
+
309
+ it "must call #http.ok? with the request method and the path" do
310
+ expect(subject.http).to receive(:ok?).with(request_method,path)
311
+
312
+ subject.http_ok?(request_method,path)
313
+ end
314
+
315
+ context "when debug messages are enabled" do
316
+ before { Ronin::Support::CLI::Printing.debug = true }
317
+
318
+ it "must print a debugging message" do
319
+ url = subject.url_for(path)
320
+
321
+ allow(subject.http).to receive(:ok?).with(request_method,path)
322
+
323
+ expect(subject).to receive(:print_debug).with(
324
+ "Checking if response status for #{request_method.upcase} #{url} is 200 ..."
325
+ )
326
+
327
+ subject.http_ok?(request_method,path)
328
+ end
329
+
330
+ after { Ronin::Support::CLI::Printing.debug = false }
331
+ end
332
+ end
333
+ end
334
+
335
+ describe "#http_response_headers" do
336
+ context "when given a path" do
337
+ let(:request_method) { :get }
338
+ let(:path) { '/foo' }
339
+
340
+ it "must call #http.ok? with :head and the path" do
341
+ expect(subject.http).to receive(:response_headers).with(:head,path)
342
+
343
+ subject.http_response_headers(path)
344
+ end
345
+
346
+ context "when debug messages are enabled" do
347
+ before { Ronin::Support::CLI::Printing.debug = true }
348
+
349
+ it "must print a debugging message" do
350
+ url = subject.url_for(path)
351
+
352
+ allow(subject.http).to receive(:response_headers).with(:head,path)
353
+
354
+ expect(subject).to receive(:print_debug).with(
355
+ "Requesting response headers for HEAD #{url} ..."
356
+ )
357
+
358
+ subject.http_response_headers(path)
359
+ end
360
+
361
+ after { Ronin::Support::CLI::Printing.debug = false }
362
+ end
363
+ end
364
+
365
+ context "when given a request method and a path" do
366
+ let(:request_method) { :get }
367
+ let(:path) { '/foo' }
368
+
369
+ it "must call #http.ok? with the request method and the path" do
370
+ expect(subject.http).to receive(:response_headers).with(
371
+ request_method, path
372
+ )
373
+
374
+ subject.http_response_headers(request_method,path)
375
+ end
376
+
377
+ context "when debug messages are enabled" do
378
+ before { Ronin::Support::CLI::Printing.debug = true }
379
+
380
+ it "must print a debugging message" do
381
+ url = subject.url_for(path)
382
+
383
+ allow(subject.http).to receive(:response_headers).with(
384
+ request_method, path
385
+ )
386
+
387
+ expect(subject).to receive(:print_debug).with(
388
+ "Requesting response headers for #{request_method.upcase} #{url} ..."
389
+ )
390
+
391
+ subject.http_response_headers(request_method,path)
392
+ end
393
+
394
+ after { Ronin::Support::CLI::Printing.debug = false }
395
+ end
396
+ end
397
+ end
398
+
399
+ describe "#http_server_header" do
400
+ context "when given a path" do
401
+ let(:path) { '/foo' }
402
+
403
+ it "must call #http.server_header with the path and method: :head" do
404
+ expect(subject.http).to receive(:server_header).with(
405
+ path, method: :head
406
+ )
407
+
408
+ subject.http_server_header(path)
409
+ end
410
+
411
+ context "when debug messages are enabled" do
412
+ before { Ronin::Support::CLI::Printing.debug = true }
413
+
414
+ it "must print a debugging message" do
415
+ url = subject.url_for(path)
416
+
417
+ allow(subject.http).to receive(:server_header).with(
418
+ path, method: :head
419
+ )
420
+
421
+ expect(subject).to receive(:print_debug).with(
422
+ "Requesting the 'Server' header for HEAD #{url} ..."
423
+ )
424
+
425
+ subject.http_server_header(path)
426
+ end
427
+
428
+ after { Ronin::Support::CLI::Printing.debug = false }
429
+ end
430
+ end
431
+
432
+ context "when given a path and the method: keyword argument" do
433
+ let(:request_method) { :get }
434
+ let(:path) { '/foo' }
435
+
436
+ it "must call #http.server_header with the path and the method: keyword argument" do
437
+ expect(subject.http).to receive(:server_header).with(
438
+ path, method: request_method
439
+ )
440
+
441
+ subject.http_server_header(path, method: request_method)
442
+ end
443
+
444
+ context "when debug messages are enabled" do
445
+ before { Ronin::Support::CLI::Printing.debug = true }
446
+
447
+ it "must print a debugging message" do
448
+ url = subject.url_for(path)
449
+
450
+ allow(subject.http).to receive(:server_header).with(
451
+ path, method: request_method
452
+ )
453
+
454
+ expect(subject).to receive(:print_debug).with(
455
+ "Requesting the 'Server' header for #{request_method.upcase} #{url} ..."
456
+ )
457
+
458
+ subject.http_server_header(path, method: request_method)
459
+ end
460
+
461
+ after { Ronin::Support::CLI::Printing.debug = false }
462
+ end
463
+ end
464
+ end
465
+
466
+ describe "#http_powered_by_header" do
467
+ context "when given a path" do
468
+ let(:path) { '/foo' }
469
+
470
+ it "must call #http.powered_by_header with the path and method: :head" do
471
+ expect(subject.http).to receive(:powered_by_header).with(
472
+ path, method: :head
473
+ )
474
+
475
+ subject.http_powered_by_header(path)
476
+ end
477
+
478
+ context "when debug messages are enabled" do
479
+ before { Ronin::Support::CLI::Printing.debug = true }
480
+
481
+ it "must print a debugging message" do
482
+ url = subject.url_for(path)
483
+
484
+ allow(subject.http).to receive(:powered_by_header).with(
485
+ path, method: :head
486
+ )
487
+
488
+ expect(subject).to receive(:print_debug).with(
489
+ "Requesting the 'X-Powered-By' header for HEAD #{url} ..."
490
+ )
491
+
492
+ subject.http_powered_by_header(path)
493
+ end
494
+
495
+ after { Ronin::Support::CLI::Printing.debug = false }
496
+ end
497
+ end
498
+
499
+ context "when given a path and a method: keyword argument" do
500
+ let(:request_method) { :get }
501
+ let(:path) { '/foo' }
502
+
503
+ it "must call #http.powered_by_header with the path and the method: keyword argument" do
504
+ expect(subject.http).to receive(:powered_by_header).with(
505
+ path, method: request_method,
506
+ )
507
+
508
+ subject.http_powered_by_header(path, method: request_method)
509
+ end
510
+
511
+ context "when debug messages are enabled" do
512
+ before { Ronin::Support::CLI::Printing.debug = true }
513
+
514
+ it "must print a debugging message" do
515
+ url = subject.url_for(path)
516
+
517
+ allow(subject.http).to receive(:powered_by_header).with(
518
+ path, method: request_method
519
+ )
520
+
521
+ expect(subject).to receive(:print_debug).with(
522
+ "Requesting the 'X-Powered-By' header for #{request_method.upcase} #{url} ..."
523
+ )
524
+
525
+ subject.http_powered_by_header(path, method: request_method)
526
+ end
527
+
528
+ after { Ronin::Support::CLI::Printing.debug = false }
529
+ end
530
+ end
531
+ end
532
+
533
+ describe "#http_response_body" do
534
+ context "when given a path" do
535
+ let(:path) { '/foo' }
536
+
537
+ it "must call #http.response_body with :head and the path" do
538
+ expect(subject.http).to receive(:response_body).with(:get,path)
539
+
540
+ subject.http_response_body(path)
541
+ end
542
+
543
+ context "when debug messages are enabled" do
544
+ before { Ronin::Support::CLI::Printing.debug = true }
545
+
546
+ it "must print a debugging message" do
547
+ url = subject.url_for(path)
548
+
549
+ allow(subject.http).to receive(:response_body).with(
550
+ :get, path
551
+ )
552
+
553
+ expect(subject).to receive(:print_debug).with(
554
+ "Requesting response body for GET #{url} ..."
555
+ )
556
+
557
+ subject.http_response_body(path)
558
+ end
559
+
560
+ after { Ronin::Support::CLI::Printing.debug = false }
561
+ end
562
+ end
563
+
564
+ context "when given a request method and a path" do
565
+ let(:request_method) { :head }
566
+ let(:path) { '/foo' }
567
+
568
+ it "must call #http.response_body with request method and the path" do
569
+ expect(subject.http).to receive(:response_body).with(
570
+ request_method, path
571
+ )
572
+
573
+ subject.http_response_body(request_method,path)
574
+ end
575
+
576
+ context "when debug messages are enabled" do
577
+ before { Ronin::Support::CLI::Printing.debug = true }
578
+
579
+ it "must print a debugging message" do
580
+ url = subject.url_for(path)
581
+
582
+ allow(subject.http).to receive(:response_body).with(
583
+ request_method, path
584
+ )
585
+
586
+ expect(subject).to receive(:print_debug).with(
587
+ "Requesting response body for #{request_method.upcase} #{url} ..."
588
+ )
589
+
590
+ subject.http_response_body(request_method,path)
591
+ end
592
+
593
+ after { Ronin::Support::CLI::Printing.debug = false }
594
+ end
595
+ end
596
+ end
597
+
598
+ describe "#http_copy" do
599
+ context "when given a path" do
600
+ let(:path) { '/foo' }
601
+
602
+ it "must call #http.copy with the path" do
603
+ expect(subject.http).to receive(:copy).with(path)
604
+
605
+ subject.http_copy(path)
606
+ end
607
+
608
+ context "when debug messages are enabled" do
609
+ before { Ronin::Support::CLI::Printing.debug = true }
610
+
611
+ it "must print a debugging message" do
612
+ url = subject.url_for(path)
613
+
614
+ allow(subject.http).to receive(:copy).with(path)
615
+
616
+ expect(subject).to receive(:print_debug).with(
617
+ "Requesting COPY #{url} ..."
618
+ )
619
+
620
+ subject.http_copy(path)
621
+ end
622
+
623
+ after { Ronin::Support::CLI::Printing.debug = false }
624
+ end
625
+ end
626
+ end
627
+
628
+ describe "#http_delete" do
629
+ context "when given a path" do
630
+ let(:path) { '/foo' }
631
+
632
+ it "must call #http.delete with the path" do
633
+ expect(subject.http).to receive(:delete).with(path)
634
+
635
+ subject.http_delete(path)
636
+ end
637
+
638
+ context "when debug messages are enabled" do
639
+ before { Ronin::Support::CLI::Printing.debug = true }
640
+
641
+ it "must print a debugging message" do
642
+ url = subject.url_for(path)
643
+
644
+ allow(subject.http).to receive(:delete).with(path)
645
+
646
+ expect(subject).to receive(:print_debug).with(
647
+ "Requesting DELETE #{url} ..."
648
+ )
649
+
650
+ subject.http_delete(path)
651
+ end
652
+
653
+ after { Ronin::Support::CLI::Printing.debug = false }
654
+ end
655
+ end
656
+ end
657
+
658
+ describe "#http_get" do
659
+ context "when given a path" do
660
+ let(:path) { '/foo' }
661
+
662
+ it "must call #http.get with the path" do
663
+ expect(subject.http).to receive(:get).with(path)
664
+
665
+ subject.http_get(path)
666
+ end
667
+
668
+ context "when debug messages are enabled" do
669
+ before { Ronin::Support::CLI::Printing.debug = true }
670
+
671
+ it "must print a debugging message" do
672
+ url = subject.url_for(path)
673
+
674
+ allow(subject.http).to receive(:get).with(path)
675
+
676
+ expect(subject).to receive(:print_debug).with(
677
+ "Requesting GET #{url} ..."
678
+ )
679
+
680
+ subject.http_get(path)
681
+ end
682
+
683
+ after { Ronin::Support::CLI::Printing.debug = false }
684
+ end
685
+ end
686
+ end
687
+
688
+ describe "#http_get_headers" do
689
+ context "when given a path" do
690
+ let(:path) { '/foo' }
691
+
692
+ it "must call #http.get_headers with the path" do
693
+ expect(subject.http).to receive(:get_headers).with(path)
694
+
695
+ subject.http_get_headers(path)
696
+ end
697
+
698
+ context "when debug messages are enabled" do
699
+ before { Ronin::Support::CLI::Printing.debug = true }
700
+
701
+ it "must print a debugging message" do
702
+ url = subject.url_for(path)
703
+
704
+ allow(subject.http).to receive(:get_headers).with(path)
705
+
706
+ expect(subject).to receive(:print_debug).with(
707
+ "Requesting headers for GET #{url} ..."
708
+ )
709
+
710
+ subject.http_get_headers(path)
711
+ end
712
+
713
+ after { Ronin::Support::CLI::Printing.debug = false }
714
+ end
715
+ end
716
+ end
717
+
718
+ describe "#http_get_cookies" do
719
+ context "when given a path" do
720
+ let(:path) { '/foo' }
721
+
722
+ it "must call #http.get_cookies with the path" do
723
+ expect(subject.http).to receive(:get_cookies).with(path)
724
+
725
+ subject.http_get_cookies(path)
726
+ end
727
+
728
+ context "when debug messages are enabled" do
729
+ before { Ronin::Support::CLI::Printing.debug = true }
730
+
731
+ it "must print a debugging message" do
732
+ url = subject.url_for(path)
733
+
734
+ allow(subject.http).to receive(:get_cookies).with(path)
735
+
736
+ expect(subject).to receive(:print_debug).with(
737
+ "Getting cookies for #{url} ..."
738
+ )
739
+
740
+ subject.http_get_cookies(path)
741
+ end
742
+
743
+ after { Ronin::Support::CLI::Printing.debug = false }
744
+ end
745
+ end
746
+ end
747
+
748
+ describe "#http_get_body" do
749
+ context "when given a path" do
750
+ let(:path) { '/foo' }
751
+
752
+ it "must call #http.get_body with the path" do
753
+ expect(subject.http).to receive(:get_body).with(path)
754
+
755
+ subject.http_get_body(path)
756
+ end
757
+
758
+ context "when debug messages are enabled" do
759
+ before { Ronin::Support::CLI::Printing.debug = true }
760
+
761
+ it "must print a debugging message" do
762
+ url = subject.url_for(path)
763
+
764
+ allow(subject.http).to receive(:get_body).with(path)
765
+
766
+ expect(subject).to receive(:print_debug).with(
767
+ "Requesting body for GET #{url} ..."
768
+ )
769
+
770
+ subject.http_get_body(path)
771
+ end
772
+
773
+ after { Ronin::Support::CLI::Printing.debug = false }
774
+ end
775
+ end
776
+ end
777
+
778
+ describe "#http_head" do
779
+ context "when given a path" do
780
+ let(:path) { '/foo' }
781
+
782
+ it "must call #http.head with the path" do
783
+ expect(subject.http).to receive(:head).with(path)
784
+
785
+ subject.http_head(path)
786
+ end
787
+
788
+ context "when debug messages are enabled" do
789
+ before { Ronin::Support::CLI::Printing.debug = true }
790
+
791
+ it "must print a debugging message" do
792
+ url = subject.url_for(path)
793
+
794
+ allow(subject.http).to receive(:head).with(path)
795
+
796
+ expect(subject).to receive(:print_debug).with(
797
+ "Requesting HEAD #{url} ..."
798
+ )
799
+
800
+ subject.http_head(path)
801
+ end
802
+
803
+ after { Ronin::Support::CLI::Printing.debug = false }
804
+ end
805
+ end
806
+ end
807
+
808
+ describe "#http_lock" do
809
+ context "when given a path" do
810
+ let(:path) { '/foo' }
811
+
812
+ it "must call #http.lock with the path" do
813
+ expect(subject.http).to receive(:lock).with(path)
814
+
815
+ subject.http_lock(path)
816
+ end
817
+
818
+ context "when debug messages are enabled" do
819
+ before { Ronin::Support::CLI::Printing.debug = true }
820
+
821
+ it "must print a debugging message" do
822
+ url = subject.url_for(path)
823
+
824
+ allow(subject.http).to receive(:lock).with(path)
825
+
826
+ expect(subject).to receive(:print_debug).with(
827
+ "Requesting LOCK #{url} ..."
828
+ )
829
+
830
+ subject.http_lock(path)
831
+ end
832
+
833
+ after { Ronin::Support::CLI::Printing.debug = false }
834
+ end
835
+ end
836
+ end
837
+
838
+ describe "#http_mkcol" do
839
+ context "when given a path" do
840
+ let(:path) { '/foo' }
841
+
842
+ it "must call #http.mkcol with the path" do
843
+ expect(subject.http).to receive(:mkcol).with(path)
844
+
845
+ subject.http_mkcol(path)
846
+ end
847
+
848
+ context "when debug messages are enabled" do
849
+ before { Ronin::Support::CLI::Printing.debug = true }
850
+
851
+ it "must print a debugging message" do
852
+ url = subject.url_for(path)
853
+
854
+ allow(subject.http).to receive(:mkcol).with(path)
855
+
856
+ expect(subject).to receive(:print_debug).with(
857
+ "Requesting MKCOL #{url} ..."
858
+ )
859
+
860
+ subject.http_mkcol(path)
861
+ end
862
+
863
+ after { Ronin::Support::CLI::Printing.debug = false }
864
+ end
865
+ end
866
+ end
867
+
868
+ describe "#http_move" do
869
+ context "when given a path" do
870
+ let(:path) { '/foo' }
871
+
872
+ it "must call #http.move with the path" do
873
+ expect(subject.http).to receive(:move).with(path)
874
+
875
+ subject.http_move(path)
876
+ end
877
+
878
+ context "when debug messages are enabled" do
879
+ before { Ronin::Support::CLI::Printing.debug = true }
880
+
881
+ it "must print a debugging message" do
882
+ url = subject.url_for(path)
883
+
884
+ allow(subject.http).to receive(:move).with(path)
885
+
886
+ expect(subject).to receive(:print_debug).with(
887
+ "Requesting MOVE #{url} ..."
888
+ )
889
+
890
+ subject.http_move(path)
891
+ end
892
+
893
+ after { Ronin::Support::CLI::Printing.debug = false }
894
+ end
895
+ end
896
+ end
897
+
898
+ describe "#http_options" do
899
+ context "when given a path" do
900
+ let(:path) { '/foo' }
901
+
902
+ it "must call #http.options with the path" do
903
+ expect(subject.http).to receive(:options).with(path)
904
+
905
+ subject.http_options(path)
906
+ end
907
+
908
+ context "when debug messages are enabled" do
909
+ before { Ronin::Support::CLI::Printing.debug = true }
910
+
911
+ it "must print a debugging message" do
912
+ url = subject.url_for(path)
913
+
914
+ allow(subject.http).to receive(:options).with(path)
915
+
916
+ expect(subject).to receive(:print_debug).with(
917
+ "Requesting OPTIONS #{url} ..."
918
+ )
919
+
920
+ subject.http_options(path)
921
+ end
922
+
923
+ after { Ronin::Support::CLI::Printing.debug = false }
924
+ end
925
+ end
926
+ end
927
+
928
+ describe "#http_allowed_methods" do
929
+ context "when given a path" do
930
+ let(:path) { '/foo' }
931
+
932
+ it "must call #http.allowed_methods with the path" do
933
+ expect(subject.http).to receive(:allowed_methods).with(path)
934
+
935
+ subject.http_allowed_methods(path)
936
+ end
937
+
938
+ context "when debug messages are enabled" do
939
+ before { Ronin::Support::CLI::Printing.debug = true }
940
+
941
+ it "must print a debugging message" do
942
+ url = subject.url_for(path)
943
+
944
+ allow(subject.http).to receive(:allowed_methods).with(path)
945
+
946
+ expect(subject).to receive(:print_debug).with(
947
+ "Checking allowed HTTP methods for #{url} ..."
948
+ )
949
+
950
+ subject.http_allowed_methods(path)
951
+ end
952
+
953
+ after { Ronin::Support::CLI::Printing.debug = false }
954
+ end
955
+ end
956
+ end
957
+
958
+ describe "#http_patch" do
959
+ context "when given a path" do
960
+ let(:path) { '/foo' }
961
+
962
+ it "must call #http.patch with the path" do
963
+ expect(subject.http).to receive(:patch).with(path)
964
+
965
+ subject.http_patch(path)
966
+ end
967
+
968
+ context "when debug messages are enabled" do
969
+ before { Ronin::Support::CLI::Printing.debug = true }
970
+
971
+ it "must print a debugging message" do
972
+ url = subject.url_for(path)
973
+
974
+ allow(subject.http).to receive(:patch).with(path)
975
+
976
+ expect(subject).to receive(:print_debug).with(
977
+ "Requesting PATCH #{url} ..."
978
+ )
979
+
980
+ subject.http_patch(path)
981
+ end
982
+
983
+ after { Ronin::Support::CLI::Printing.debug = false }
984
+ end
985
+ end
986
+ end
987
+
988
+ describe "#http_post" do
989
+ context "when given a path" do
990
+ let(:path) { '/foo' }
991
+
992
+ it "must call #http.post with the path" do
993
+ expect(subject.http).to receive(:post).with(path)
994
+
995
+ subject.http_post(path)
996
+ end
997
+
998
+ context "when debug messages are enabled" do
999
+ before { Ronin::Support::CLI::Printing.debug = true }
1000
+
1001
+ it "must print a debugging message" do
1002
+ url = subject.url_for(path)
1003
+
1004
+ allow(subject.http).to receive(:post).with(path)
1005
+
1006
+ expect(subject).to receive(:print_debug).with(
1007
+ "Requesting POST #{url} ..."
1008
+ )
1009
+
1010
+ subject.http_post(path)
1011
+ end
1012
+
1013
+ after { Ronin::Support::CLI::Printing.debug = false }
1014
+ end
1015
+ end
1016
+ end
1017
+
1018
+ describe "#http_post_headers" do
1019
+ context "when given a path" do
1020
+ let(:path) { '/foo' }
1021
+
1022
+ it "must call #http.post_headers with the path" do
1023
+ expect(subject.http).to receive(:post_headers).with(path)
1024
+
1025
+ subject.http_post_headers(path)
1026
+ end
1027
+
1028
+ context "when debug messages are enabled" do
1029
+ before { Ronin::Support::CLI::Printing.debug = true }
1030
+
1031
+ it "must print a debugging message" do
1032
+ url = subject.url_for(path)
1033
+
1034
+ allow(subject.http).to receive(:post_headers).with(path)
1035
+
1036
+ expect(subject).to receive(:print_debug).with(
1037
+ "Requesting response headers for POST #{url} ..."
1038
+ )
1039
+
1040
+ subject.http_post_headers(path)
1041
+ end
1042
+
1043
+ after { Ronin::Support::CLI::Printing.debug = false }
1044
+ end
1045
+ end
1046
+ end
1047
+
1048
+ describe "#http_post_body" do
1049
+ context "when given a path" do
1050
+ let(:path) { '/foo' }
1051
+
1052
+ it "must call #http.post_body with the path" do
1053
+ expect(subject.http).to receive(:post_body).with(path)
1054
+
1055
+ subject.http_post_body(path)
1056
+ end
1057
+
1058
+ context "when debug messages are enabled" do
1059
+ before { Ronin::Support::CLI::Printing.debug = true }
1060
+
1061
+ it "must print a debugging message" do
1062
+ url = subject.url_for(path)
1063
+
1064
+ allow(subject.http).to receive(:post_body).with(path)
1065
+
1066
+ expect(subject).to receive(:print_debug).with(
1067
+ "Requesting response body for POST #{url} ..."
1068
+ )
1069
+
1070
+ subject.http_post_body(path)
1071
+ end
1072
+
1073
+ after { Ronin::Support::CLI::Printing.debug = false }
1074
+ end
1075
+ end
1076
+ end
1077
+
1078
+ describe "#http_propfind" do
1079
+ context "when given a path" do
1080
+ let(:path) { '/foo' }
1081
+
1082
+ it "must call #http.propfind with the path" do
1083
+ expect(subject.http).to receive(:propfind).with(path)
1084
+
1085
+ subject.http_propfind(path)
1086
+ end
1087
+
1088
+ context "when debug messages are enabled" do
1089
+ before { Ronin::Support::CLI::Printing.debug = true }
1090
+
1091
+ it "must print a debugging message" do
1092
+ url = subject.url_for(path)
1093
+
1094
+ allow(subject.http).to receive(:propfind).with(path)
1095
+
1096
+ expect(subject).to receive(:print_debug).with(
1097
+ "Requesting PROPFIND #{url} ..."
1098
+ )
1099
+
1100
+ subject.http_propfind(path)
1101
+ end
1102
+
1103
+ after { Ronin::Support::CLI::Printing.debug = false }
1104
+ end
1105
+ end
1106
+ end
1107
+
1108
+ describe "#http_proppatch" do
1109
+ context "when given a path" do
1110
+ let(:path) { '/foo' }
1111
+
1112
+ it "must call #http.proppatch with the path" do
1113
+ expect(subject.http).to receive(:proppatch).with(path)
1114
+
1115
+ subject.http_proppatch(path)
1116
+ end
1117
+
1118
+ context "when debug messages are enabled" do
1119
+ before { Ronin::Support::CLI::Printing.debug = true }
1120
+
1121
+ it "must print a debugging message" do
1122
+ url = subject.url_for(path)
1123
+
1124
+ expect(subject.http).to receive(:proppatch).with(path)
1125
+
1126
+ expect(subject).to receive(:print_debug).with(
1127
+ "Requesting PROPPATCH #{url} ..."
1128
+ )
1129
+
1130
+ subject.http_proppatch(path)
1131
+ end
1132
+
1133
+ after { Ronin::Support::CLI::Printing.debug = false }
1134
+ end
1135
+ end
1136
+ end
1137
+
1138
+ describe "#http_put" do
1139
+ context "when given a path" do
1140
+ let(:path) { '/foo' }
1141
+
1142
+ it "must call #http.put with the path" do
1143
+ expect(subject.http).to receive(:put).with(path)
1144
+
1145
+ subject.http_put(path)
1146
+ end
1147
+
1148
+ context "when debug messages are enabled" do
1149
+ before { Ronin::Support::CLI::Printing.debug = true }
1150
+
1151
+ it "must print a debugging message" do
1152
+ url = subject.url_for(path)
1153
+
1154
+ allow(subject.http).to receive(:put).with(path)
1155
+
1156
+ expect(subject).to receive(:print_debug).with(
1157
+ "Requesting PUT #{url} ..."
1158
+ )
1159
+
1160
+ subject.http_put(path)
1161
+ end
1162
+
1163
+ after { Ronin::Support::CLI::Printing.debug = false }
1164
+ end
1165
+ end
1166
+ end
1167
+
1168
+ describe "#http_trace" do
1169
+ context "when given a path" do
1170
+ let(:path) { '/foo' }
1171
+
1172
+ it "must call #http.trace with the path" do
1173
+ expect(subject.http).to receive(:trace).with(path)
1174
+
1175
+ subject.http_trace(path)
1176
+ end
1177
+
1178
+ context "when debug messages are enabled" do
1179
+ before { Ronin::Support::CLI::Printing.debug = true }
1180
+
1181
+ it "must print a debugging message" do
1182
+ url = subject.url_for(path)
1183
+
1184
+ allow(subject.http).to receive(:trace).with(path)
1185
+
1186
+ expect(subject).to receive(:print_debug).with(
1187
+ "Requesting TRACE #{url} ..."
1188
+ )
1189
+
1190
+ subject.http_trace(path)
1191
+ end
1192
+
1193
+ after { Ronin::Support::CLI::Printing.debug = false }
1194
+ end
1195
+ end
1196
+ end
1197
+
1198
+ describe "#http_unlock" do
1199
+ context "when given a path" do
1200
+ let(:path) { '/foo' }
1201
+
1202
+ it "must call #http.unlock with the path" do
1203
+ expect(subject.http).to receive(:unlock).with(path)
1204
+
1205
+ subject.http_unlock(path)
1206
+ end
1207
+
1208
+ context "when debug messages are enabled" do
1209
+ before { Ronin::Support::CLI::Printing.debug = true }
1210
+
1211
+ it "must print a debugging message" do
1212
+ url = subject.url_for(path)
1213
+
1214
+ allow(subject.http).to receive(:unlock).with(path)
1215
+
1216
+ expect(subject).to receive(:print_debug).with(
1217
+ "Requesting UNLOCK #{url} ..."
1218
+ )
1219
+
1220
+ subject.http_unlock(path)
1221
+ end
1222
+
1223
+ after { Ronin::Support::CLI::Printing.debug = false }
1224
+ end
1225
+ end
1226
+ end
1227
+ end