ronin-support 0.4.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (224) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.github/workflows/ruby.yml +28 -0
  4. data/.ruby-version +1 -0
  5. data/.yardopts +1 -1
  6. data/ChangeLog.md +121 -33
  7. data/Gemfile +17 -18
  8. data/README.md +57 -33
  9. data/Rakefile +10 -3
  10. data/gemspec.yml +16 -7
  11. data/lib/ronin/binary.rb +21 -0
  12. data/lib/ronin/binary/hexdump.rb +20 -0
  13. data/lib/ronin/binary/hexdump/parser.rb +403 -0
  14. data/lib/ronin/binary/struct.rb +567 -0
  15. data/lib/ronin/binary/template.rb +454 -0
  16. data/lib/ronin/extensions.rb +5 -5
  17. data/lib/ronin/extensions/enumerable.rb +5 -5
  18. data/lib/ronin/extensions/file.rb +39 -33
  19. data/lib/ronin/extensions/ip_addr.rb +29 -31
  20. data/lib/ronin/extensions/kernel.rb +5 -5
  21. data/lib/ronin/extensions/meta.rb +5 -5
  22. data/lib/ronin/extensions/regexp.rb +50 -5
  23. data/lib/ronin/extensions/resolv.rb +7 -9
  24. data/lib/ronin/extensions/string.rb +10 -10
  25. data/lib/ronin/formatting.rb +5 -5
  26. data/lib/ronin/formatting/binary.rb +5 -5
  27. data/lib/ronin/formatting/digest.rb +5 -5
  28. data/lib/ronin/formatting/extensions.rb +5 -5
  29. data/lib/ronin/formatting/extensions/binary.rb +7 -5
  30. data/lib/ronin/formatting/extensions/binary/array.rb +61 -0
  31. data/lib/ronin/formatting/extensions/binary/base64.rb +106 -0
  32. data/lib/ronin/formatting/extensions/binary/file.rb +44 -11
  33. data/lib/ronin/formatting/extensions/binary/float.rb +65 -0
  34. data/lib/ronin/formatting/extensions/binary/integer.rb +66 -50
  35. data/lib/ronin/formatting/extensions/binary/string.rb +81 -205
  36. data/lib/ronin/formatting/extensions/digest.rb +5 -5
  37. data/lib/ronin/formatting/extensions/digest/file.rb +5 -5
  38. data/lib/ronin/formatting/extensions/digest/string.rb +5 -5
  39. data/lib/ronin/formatting/extensions/html.rb +5 -5
  40. data/lib/ronin/formatting/extensions/html/integer.rb +9 -13
  41. data/lib/ronin/formatting/extensions/html/string.rb +31 -39
  42. data/lib/ronin/formatting/extensions/http.rb +5 -5
  43. data/lib/ronin/formatting/extensions/http/integer.rb +6 -6
  44. data/lib/ronin/formatting/extensions/http/string.rb +7 -7
  45. data/lib/ronin/formatting/extensions/sql.rb +5 -5
  46. data/lib/ronin/formatting/extensions/sql/string.rb +22 -24
  47. data/lib/ronin/formatting/extensions/text.rb +5 -5
  48. data/lib/ronin/formatting/extensions/text/array.rb +13 -11
  49. data/lib/ronin/formatting/extensions/text/string.rb +70 -13
  50. data/lib/ronin/formatting/html.rb +5 -5
  51. data/lib/ronin/formatting/http.rb +5 -5
  52. data/lib/ronin/formatting/sql.rb +5 -5
  53. data/lib/ronin/formatting/text.rb +5 -5
  54. data/lib/ronin/fuzzing.rb +5 -5
  55. data/lib/ronin/fuzzing/extensions.rb +5 -5
  56. data/lib/ronin/fuzzing/extensions/string.rb +42 -213
  57. data/lib/ronin/fuzzing/fuzzer.rb +110 -0
  58. data/lib/ronin/fuzzing/fuzzing.rb +33 -26
  59. data/lib/ronin/fuzzing/mutator.rb +161 -0
  60. data/lib/ronin/fuzzing/repeater.rb +81 -0
  61. data/lib/ronin/fuzzing/template.rb +133 -0
  62. data/lib/ronin/mixin.rb +2 -2
  63. data/lib/ronin/network.rb +7 -5
  64. data/lib/ronin/network/dns.rb +64 -24
  65. data/lib/ronin/network/esmtp.rb +5 -5
  66. data/lib/ronin/network/extensions.rb +5 -5
  67. data/lib/ronin/network/extensions/dns.rb +5 -5
  68. data/lib/ronin/network/extensions/dns/net.rb +5 -5
  69. data/lib/ronin/network/extensions/esmtp.rb +5 -5
  70. data/lib/ronin/network/extensions/esmtp/net.rb +5 -5
  71. data/lib/ronin/network/extensions/http.rb +5 -5
  72. data/lib/ronin/network/extensions/http/net.rb +5 -5
  73. data/lib/ronin/network/extensions/http/uri/http.rb +5 -5
  74. data/lib/ronin/network/extensions/imap.rb +5 -5
  75. data/lib/ronin/network/extensions/imap/net.rb +5 -5
  76. data/lib/ronin/network/extensions/pop3.rb +5 -5
  77. data/lib/ronin/network/extensions/pop3/net.rb +5 -5
  78. data/lib/ronin/network/extensions/smtp.rb +5 -5
  79. data/lib/ronin/network/extensions/smtp/net.rb +5 -5
  80. data/lib/ronin/network/extensions/ssl.rb +5 -5
  81. data/lib/ronin/network/extensions/ssl/net.rb +5 -5
  82. data/lib/ronin/network/extensions/tcp.rb +5 -5
  83. data/lib/ronin/network/extensions/tcp/net.rb +5 -5
  84. data/lib/ronin/network/extensions/telnet.rb +5 -5
  85. data/lib/ronin/network/extensions/telnet/net.rb +5 -5
  86. data/lib/ronin/network/extensions/udp.rb +5 -5
  87. data/lib/ronin/network/extensions/udp/net.rb +5 -5
  88. data/lib/ronin/network/ftp.rb +149 -0
  89. data/lib/ronin/network/http.rb +5 -5
  90. data/lib/ronin/network/http/exceptions.rb +5 -5
  91. data/lib/ronin/network/http/exceptions/unknown_request.rb +5 -5
  92. data/lib/ronin/network/http/http.rb +65 -70
  93. data/lib/ronin/network/http/proxy.rb +5 -5
  94. data/lib/ronin/network/imap.rb +16 -15
  95. data/lib/ronin/network/mixins.rb +6 -5
  96. data/lib/ronin/network/mixins/dns.rb +5 -5
  97. data/lib/ronin/network/mixins/esmtp.rb +5 -5
  98. data/lib/ronin/network/mixins/ftp.rb +155 -0
  99. data/lib/ronin/network/mixins/http.rb +58 -587
  100. data/lib/ronin/network/mixins/imap.rb +5 -5
  101. data/lib/ronin/network/mixins/mixin.rb +5 -5
  102. data/lib/ronin/network/mixins/pop3.rb +5 -5
  103. data/lib/ronin/network/mixins/smtp.rb +5 -5
  104. data/lib/ronin/network/mixins/ssl.rb +5 -5
  105. data/lib/ronin/network/mixins/tcp.rb +43 -10
  106. data/lib/ronin/network/mixins/telnet.rb +5 -5
  107. data/lib/ronin/network/mixins/udp.rb +126 -6
  108. data/lib/ronin/network/mixins/unix.rb +279 -0
  109. data/lib/ronin/network/network.rb +5 -5
  110. data/lib/ronin/network/pop3.rb +10 -10
  111. data/lib/ronin/network/proxy.rb +578 -0
  112. data/lib/ronin/network/smtp.rb +5 -5
  113. data/lib/ronin/network/smtp/email.rb +6 -6
  114. data/lib/ronin/network/smtp/smtp.rb +12 -13
  115. data/lib/ronin/network/ssl.rb +16 -17
  116. data/lib/ronin/network/tcp.rb +7 -310
  117. data/lib/ronin/network/tcp/proxy.rb +417 -0
  118. data/lib/ronin/network/tcp/tcp.rb +452 -0
  119. data/lib/ronin/network/telnet.rb +34 -28
  120. data/lib/ronin/network/udp.rb +7 -271
  121. data/lib/ronin/network/udp/proxy.rb +191 -0
  122. data/lib/ronin/network/udp/udp.rb +452 -0
  123. data/lib/ronin/network/unix.rb +286 -0
  124. data/lib/ronin/path.rb +35 -39
  125. data/lib/ronin/spec/ui/output.rb +6 -12
  126. data/lib/ronin/support.rb +6 -5
  127. data/lib/ronin/support/inflector.rb +8 -12
  128. data/lib/ronin/support/support.rb +7 -5
  129. data/lib/ronin/support/version.rb +6 -6
  130. data/lib/ronin/templates.rb +5 -5
  131. data/lib/ronin/templates/erb.rb +5 -5
  132. data/lib/ronin/templates/template.rb +5 -5
  133. data/lib/ronin/ui/output.rb +5 -5
  134. data/lib/ronin/ui/output/helpers.rb +42 -28
  135. data/lib/ronin/ui/output/output.rb +17 -21
  136. data/lib/ronin/ui/output/terminal.rb +5 -5
  137. data/lib/ronin/ui/output/terminal/color.rb +15 -9
  138. data/lib/ronin/ui/output/terminal/raw.rb +5 -5
  139. data/lib/ronin/ui/shell.rb +8 -11
  140. data/lib/ronin/wordlist.rb +110 -30
  141. data/ronin-support.gemspec +39 -109
  142. data/spec/binary/hexdump/helpers/hexdumps.rb +13 -0
  143. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/ascii.bin +0 -0
  144. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -0
  145. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_bytes.txt +0 -0
  146. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_hex_shorts.txt +0 -0
  147. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_bytes.txt +0 -0
  148. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_octal_shorts.txt +0 -0
  149. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/hexdump_repeated.txt +0 -0
  150. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_bytes.txt +0 -0
  151. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_ints.txt +0 -0
  152. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_quads.txt +0 -0
  153. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_decimal_shorts.txt +0 -0
  154. data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +17 -0
  155. data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +17 -0
  156. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_bytes.txt +0 -0
  157. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_ints.txt +0 -0
  158. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_quads.txt +0 -0
  159. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_hex_shorts.txt +0 -0
  160. data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +17 -0
  161. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_bytes.txt +0 -0
  162. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_ints.txt +0 -0
  163. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_quads.txt +0 -0
  164. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_octal_shorts.txt +0 -0
  165. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/od_repeated.txt +0 -0
  166. data/spec/{formatting/binary → binary/hexdump}/helpers/hexdumps/repeated.bin +0 -0
  167. data/spec/binary/hexdump/parser_spec.rb +302 -0
  168. data/spec/binary/struct_spec.rb +496 -0
  169. data/spec/binary/template_spec.rb +416 -0
  170. data/spec/extensions/enumerable_spec.rb +4 -4
  171. data/spec/extensions/file_spec.rb +12 -14
  172. data/spec/extensions/ip_addr_spec.rb +76 -50
  173. data/spec/extensions/kernel_spec.rb +7 -7
  174. data/spec/extensions/regexp_spec.rb +119 -59
  175. data/spec/extensions/resolv_spec.rb +2 -2
  176. data/spec/extensions/string_spec.rb +31 -30
  177. data/spec/formatting/binary/array_spec.rb +26 -0
  178. data/spec/formatting/binary/base64_spec.rb +50 -0
  179. data/spec/formatting/binary/float_spec.rb +36 -0
  180. data/spec/formatting/binary/integer_spec.rb +76 -50
  181. data/spec/formatting/binary/string_spec.rb +91 -198
  182. data/spec/formatting/digest/string_spec.rb +5 -5
  183. data/spec/formatting/html/integer_spec.rb +6 -6
  184. data/spec/formatting/html/string_spec.rb +10 -10
  185. data/spec/formatting/http/integer_spec.rb +3 -3
  186. data/spec/formatting/http/string_spec.rb +5 -5
  187. data/spec/formatting/sql/string_spec.rb +21 -19
  188. data/spec/formatting/text/array_spec.rb +15 -15
  189. data/spec/formatting/text/string_spec.rb +58 -28
  190. data/spec/fuzzing/extensions/string_spec.rb +87 -0
  191. data/spec/fuzzing/fuzzer_spec.rb +109 -0
  192. data/spec/fuzzing/fuzzing_spec.rb +24 -0
  193. data/spec/fuzzing/mutator_spec.rb +112 -0
  194. data/spec/fuzzing/repeater_spec.rb +57 -0
  195. data/spec/fuzzing/template_spec.rb +54 -0
  196. data/spec/mixin_spec.rb +10 -12
  197. data/spec/network/dns_spec.rb +89 -23
  198. data/spec/network/ftp_spec.rb +81 -0
  199. data/spec/network/http/http_spec.rb +237 -144
  200. data/spec/network/http/proxy_spec.rb +37 -37
  201. data/spec/network/network_spec.rb +2 -2
  202. data/spec/network/proxy_spec.rb +121 -0
  203. data/spec/network/shared/unix_server.rb +31 -0
  204. data/spec/network/smtp/email_spec.rb +14 -14
  205. data/spec/network/ssl_spec.rb +53 -3
  206. data/spec/network/tcp/proxy_spec.rb +118 -0
  207. data/spec/network/tcp/tcp_spec.rb +316 -0
  208. data/spec/network/telnet_spec.rb +67 -0
  209. data/spec/network/udp/udp_spec.rb +298 -0
  210. data/spec/network/unix_spec.rb +182 -0
  211. data/spec/path_spec.rb +43 -18
  212. data/spec/spec_helper.rb +2 -3
  213. data/spec/support/inflector_spec.rb +4 -4
  214. data/spec/support_spec.rb +1 -1
  215. data/spec/templates/erb_spec.rb +3 -3
  216. data/spec/templates/template_spec.rb +10 -10
  217. data/spec/ui/shell_spec.rb +15 -15
  218. data/spec/wordlist_spec.rb +80 -19
  219. metadata +176 -121
  220. data/.gemtest +0 -0
  221. data/spec/formatting/binary/helpers/hexdumps.rb +0 -16
  222. data/spec/fuzzing/string_spec.rb +0 -158
  223. data/spec/network/tcp_spec.rb +0 -247
  224. data/spec/network/udp_spec.rb +0 -248
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/extensions/ip_addr'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/ssl'
@@ -36,7 +36,7 @@ module Ronin
36
36
  #
37
37
  # @api public
38
38
  #
39
- def IMAP.default_port
39
+ def self.default_port
40
40
  @default_port ||= DEFAULT_PORT
41
41
  end
42
42
 
@@ -48,7 +48,7 @@ module Ronin
48
48
  #
49
49
  # @api public
50
50
  #
51
- def IMAP.default_port=(port)
51
+ def self.default_port=(port)
52
52
  @default_port = port
53
53
  end
54
54
 
@@ -90,19 +90,20 @@ module Ronin
90
90
  # @api public
91
91
  #
92
92
  def imap_connect(host,options={})
93
- host = host.to_s
94
- port = (options[:port] || IMAP.default_port)
95
- certs = options[:certs]
96
- auth = options[:auth]
97
- user = options[:user]
93
+ host = host.to_s
94
+ port = (options[:port] || IMAP.default_port)
95
+ certs = options[:certs]
96
+ auth = options[:auth]
97
+ user = options[:user]
98
98
  passwd = options[:password]
99
99
 
100
100
  if options[:ssl]
101
- ssl = true
102
- ssl_certs = options[:ssl][:certs]
101
+ ssl = true
102
+ ssl_certs = options[:ssl][:certs]
103
103
  ssl_verify = SSL::VERIFY[options[:ssl][:verify]]
104
104
  else
105
- ssl = false
105
+ ssl = false
106
+ ssl_certs = nil
106
107
  ssl_verify = false
107
108
  end
108
109
 
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/dns'
@@ -25,4 +25,5 @@ require 'ronin/network/mixins/esmtp'
25
25
  require 'ronin/network/mixins/pop3'
26
26
  require 'ronin/network/mixins/imap'
27
27
  require 'ronin/network/mixins/telnet'
28
+ require 'ronin/network/mixins/ftp'
28
29
  require 'ronin/network/mixins/http'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -0,0 +1,155 @@
1
+ #
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ #
4
+ # This file is part of ronin-support.
5
+ #
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU Lesser General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # ronin-support is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public License
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'ronin/network/mixins/mixin'
21
+ require 'ronin/network/ftp'
22
+
23
+ module Ronin
24
+ module Network
25
+ module Mixins
26
+ #
27
+ # Adds FTP convenience methods and connection parameters to a class.
28
+ #
29
+ # Defines the following parameters:
30
+ #
31
+ # * `host` (`String`) - FTP host.
32
+ # * `port` (`Integer`) - FTP port.
33
+ # * `ftp_user` (`String`) - FTP user to login as.
34
+ # * `ftp_password` (`String`) - FTP password to login with.
35
+ # * `ftp_account` (`String`) - FTP account information to send.
36
+ #
37
+ # @since 0.5.0
38
+ #
39
+ module FTP
40
+ include Mixin, Network::FTP
41
+
42
+ # FTP host
43
+ parameter :host, :type => String,
44
+ :description => 'FTP host'
45
+
46
+ # FTP port
47
+ parameter :port, :type => Integer,
48
+ :description => 'FTP port'
49
+
50
+ # FTP user to login as
51
+ parameter :ftp_user, :type => String,
52
+ :description => 'FTP user to login as'
53
+
54
+ # FTP password to login with
55
+ parameter :ftp_password, :type => String,
56
+ :description => 'FTP password to login with'
57
+
58
+ # FTP account information to send
59
+ parameter :ftp_password, :type => String,
60
+ :description => 'FTP account information'
61
+
62
+ protected
63
+
64
+ #
65
+ # Creates a connection to the FTP server. The `host`, `port`,
66
+ # `ftp_user`, `ftp_password` and `ftp_account` parameters
67
+ # will also be used to connect to the server.
68
+ #
69
+ # @param [Hash] options
70
+ # Additional options.
71
+ #
72
+ # @option options [Integer] :port (Network::FTP.default_port)
73
+ # The port to connect to.
74
+ #
75
+ # @option options [String] :user
76
+ # The username to authenticate with.
77
+ #
78
+ # @option options [String] :password
79
+ # The password to authenticate with.
80
+ #
81
+ # @option options [String] :account
82
+ # The account information to send via the FTP `ACCT` command.
83
+ #
84
+ # @yield [session]
85
+ # If a block is given, it will be passed an FTP session object.
86
+ #
87
+ # @yieldparam [Net::FTP] session
88
+ # The FTP session.
89
+ #
90
+ # @return [Net::FTP]
91
+ # The FTP session.
92
+ #
93
+ # @see Network::FTP#ftp_connect
94
+ #
95
+ # @api public
96
+ #
97
+ def ftp_connect(options={},&block)
98
+ print_info "Connecting to #{host_port} ..."
99
+
100
+ return super(self.host,ftp_merge_options(options),&block)
101
+ end
102
+
103
+ #
104
+ # Starts a session with the FTP server. The `host`, `port`,
105
+ # `ftp_login`, `ftp_user` and `ftp_password` parameters
106
+ # will also be used to connect to the server.
107
+ #
108
+ # @yield [session]
109
+ # If a block is given, it will be passed an FTP session object.
110
+ # After the block has returned, the session will be closed.
111
+ #
112
+ # @yieldparam [Net::FTP] session
113
+ # The FTP session.
114
+ #
115
+ # @see Network::FTP#ftp_session
116
+ #
117
+ # @api public
118
+ #
119
+ def ftp_session(options={},&block)
120
+ super(ftp_merge_options(options)) do |sess|
121
+ yield sess if block_given?
122
+
123
+ print_info "Logging out ..."
124
+ end
125
+
126
+ print_info "Disconnected to #{host_port}"
127
+ return nil
128
+ end
129
+
130
+ private
131
+
132
+ #
133
+ # Merges the FTP parameters into the options for {Network::FTP}
134
+ # methods.
135
+ #
136
+ # @param [Hash] options
137
+ # The original options.
138
+ #
139
+ # @return [Hash]
140
+ # The merged options.
141
+ #
142
+ # @api private
143
+ #
144
+ def ftp_merge_options(options={})
145
+ options[:port] ||= self.port
146
+ options[:user] ||= self.ftp_user
147
+ options[:password] ||= self.ftp_password
148
+ options[:account] ||= self.ftp_account
149
+
150
+ return options
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
@@ -1,20 +1,20 @@
1
1
  #
2
- # Copyright (c) 2006-2012 Hal Brodigan (postmodern.mod3 at gmail.com)
2
+ # Copyright (c) 2006-2021 Hal Brodigan (postmodern.mod3 at gmail.com)
3
3
  #
4
- # This file is part of Ronin Support.
4
+ # This file is part of ronin-support.
5
5
  #
6
- # Ronin Support is free software: you can redistribute it and/or modify
6
+ # ronin-support is free software: you can redistribute it and/or modify
7
7
  # it under the terms of the GNU Lesser General Public License as published
8
8
  # by the Free Software Foundation, either version 3 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
- # Ronin Support is distributed in the hope that it will be useful,
11
+ # ronin-support is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Lesser General Public License for more details.
15
15
  #
16
16
  # You should have received a copy of the GNU Lesser General Public License
17
- # along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
17
+ # along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
20
  require 'ronin/network/mixins/mixin'
@@ -78,7 +78,7 @@ module Ronin
78
78
  end
79
79
 
80
80
  #
81
- # Connects to the HTTP server.
81
+ # Starts a HTTP connection with the server.
82
82
  #
83
83
  # @param [Hash] options
84
84
  # Additional options
@@ -86,51 +86,46 @@ module Ronin
86
86
  # @option options [String, URI::HTTP] :url
87
87
  # The full URL to request.
88
88
  #
89
- # @option options [String] :user
90
- # The user to authenticate with when connecting to the HTTP
91
- # server.
92
- #
93
- # @option options [String] :password
94
- # The password to authenticate with when connecting to the HTTP
95
- # server.
96
- #
97
89
  # @option options [String] :host
98
90
  # The host the HTTP server is running on.
99
91
  #
100
92
  # @option options [Integer] :port (Net::HTTP.default_port)
101
93
  # The port the HTTP server is listening on.
102
94
  #
103
- # @option options [String] :path
104
- # The path to request from the HTTP server.
95
+ # @option options [String, Hash] :proxy (HTTP.proxy)
96
+ # A Hash of proxy settings to use when connecting to the HTTP server.
105
97
  #
106
- # @yield [session]
107
- # If a block is given, it will be passes the new HTTP session
108
- # object.
98
+ # @option options [String] :user
99
+ # The user to authenticate with when connecting to the HTTP server.
109
100
  #
110
- # @yieldparam [Net::HTTP] session
101
+ # @option options [String] :password
102
+ # The password to authenticate with when connecting to the HTTP
103
+ # server.
104
+ #
105
+ # @option options [Boolean, Hash] :ssl
106
+ # Enables SSL for the HTTP connection.
107
+ #
108
+ # @option :ssl [Symbol] :verify
109
+ # Specifies the SSL certificate verification mode.
110
+ #
111
+ # @yield [http]
112
+ # If a block is given, it will be passed the newly created HTTP
113
+ # session object.
114
+ #
115
+ # @yieldparam [Net::HTTP] http
111
116
  # The newly created HTTP session.
112
117
  #
113
118
  # @return [Net::HTTP]
114
119
  # The HTTP session object.
115
120
  #
116
- # @see Network::HTTP#http_session
121
+ # @see Network::HTTP#http_connect
117
122
  #
118
123
  # @api public
119
124
  #
120
- def http_session(options={},&block)
121
- options = http_merge_options(options)
122
-
123
- super(options) do |http,expanded_options|
124
- print_info "Starting HTTP Session with #{host_port}"
125
-
126
- if block.arity == 2
127
- block.call(http,expanded_options)
128
- else
129
- block.call(http)
130
- end
131
-
132
- print_info "Closing HTTP Session with #{host_port}"
133
- end
125
+ # @since 0.5.0
126
+ #
127
+ def http_connect(options={},&block)
128
+ super(http_merge_options(options),&block)
134
129
  end
135
130
 
136
131
  #
@@ -149,13 +144,13 @@ module Ronin
149
144
  # If the block has an arity of 2, it will also be passed the
150
145
  # expanded version of the given options.
151
146
  #
152
- # @yieldparam [Net::HTTP::Request] request
147
+ # @yieldparam [Net::HTTPRequest] request
153
148
  # The HTTP request object to use in the request.
154
149
  #
155
150
  # @yieldparam [Hash] options
156
151
  # The expanded version of the given options.
157
152
  #
158
- # @return [Net::HTTP::Response]
153
+ # @return [Net::HTTPResponse]
159
154
  # The response of the HTTP request.
160
155
  #
161
156
  # @see Network::HTTP#http_request
@@ -163,523 +158,32 @@ module Ronin
163
158
  # @api public
164
159
  #
165
160
  def http_request(options={},&block)
166
- options = http_merge_options(options)
167
- print_info "HTTP #{options[:method]} #{http_options_to_s(options)}"
168
-
169
- return super(options,&block)
170
- end
171
-
172
- #
173
- # Returns the Status Code of the Response.
174
- #
175
- # @param [Hash] options
176
- # Additional options.
177
- #
178
- # @option options [Symbol, String] :method (:head)
179
- # The method to use for the request.
180
- #
181
- # @return [Integer]
182
- # The HTTP Response Status.
183
- #
184
- # @see Network::HTTP#http_status
185
- #
186
- # @since 1.1.0
187
- #
188
- # @api public
189
- #
190
- def http_status(options={})
191
- options = http_merge_options(options)
192
-
193
- if (result = super(options))
194
- print_debug "HTTP #{result} #{http_options_to_s(options)}"
195
- end
161
+ response = super(options) do |request,expanded_options|
162
+ if block
163
+ if block.arity == 2
164
+ block.call(request,expanded_options)
165
+ else
166
+ block.call(request)
167
+ end
168
+ end
196
169
 
197
- return result
198
- end
170
+ host = options.fetch(:host,self.host)
171
+ port = options.fetch(:port,self.port)
199
172
 
200
- #
201
- # Checks if the response has an HTTP OK status code.
202
- #
203
- # @param [Hash] options
204
- # Additional options.
205
- #
206
- # @option options [Symbol, String] :method (:head)
207
- # The method to use for the request.
208
- #
209
- # @return [Boolean]
210
- # Specifies whether the response had an HTTP OK status code or not.
211
- #
212
- # @see Network::HTTP#http_ok?
213
- #
214
- # @since 1.1.0
215
- #
216
- # @api public
217
- #
218
- def http_ok?(options={})
219
- options = http_merge_options(options)
173
+ print_info "HTTP #{request.method} #{host}:#{port} #{request.path}"
220
174
 
221
- if (result = super(options))
222
- print_debug "HTTP 200 OK #{http_options_to_s(options)}"
175
+ request.each_capitalized do |name,value|
176
+ print_debug " #{name}: #{value}"
177
+ end
223
178
  end
224
179
 
225
- return result
226
- end
227
-
228
- #
229
- # Sends a HTTP Head request and returns the HTTP Server header.
230
- #
231
- # @param [Hash] options
232
- # Additional options.
233
- #
234
- # @option options [Symbol, String] :method (:head)
235
- # The method to use for the request.
236
- #
237
- # @return [String]
238
- # The HTTP `Server` header.
239
- #
240
- # @see Network::HTTP#http_server
241
- #
242
- # @since 1.1.0
243
- #
244
- # @api public
245
- #
246
- def http_server(options={})
247
- options = http_merge_options(options)
180
+ print_info "HTTP #{response.code} #{response.message}"
248
181
 
249
- if (result = super(options))
250
- print_debug "HTTP Server: #{result}"
182
+ response.each_capitalized do |name,value|
183
+ print_debug " #{name}: #{value}"
251
184
  end
252
185
 
253
- return result
254
- end
255
-
256
- #
257
- # Sends an HTTP Head request and returns the HTTP X-Powered-By header.
258
- #
259
- # @param [Hash] options
260
- # Additional options.
261
- #
262
- # @option options [Symbol, String] :method (:get)
263
- # The method to use for the request.
264
- #
265
- # @return [String]
266
- # The HTTP `X-Powered-By` header.
267
- #
268
- # @see Network::HTTP#http_powered_by
269
- #
270
- # @since 1.1.0
271
- #
272
- # @api public
273
- #
274
- def http_powered_by(options={})
275
- options = http_merge_options(options)
276
-
277
- if (result = super(options))
278
- print_debug "HTTP X-Powered-By: #{result}"
279
- end
280
-
281
- return result
282
- end
283
-
284
- #
285
- # Performs an HTTP Copy request.
286
- #
287
- # @yield [response]
288
- # If a block is given, it will be passed the response received
289
- # from the request.
290
- #
291
- # @yieldparam [Net::HTTP::Response] response
292
- # The HTTP response object.
293
- #
294
- # @return [Net::HTTP::Response]
295
- # The response of the HTTP request.
296
- #
297
- # @see Network::HTTP#http_copy
298
- #
299
- # @api public
300
- #
301
- def http_copy(options={},&block)
302
- options = http_merge_options(options)
303
- print_info "HTTP COPY #{http_options_to_s(options)}"
304
-
305
- return super(options,&block)
306
- end
307
-
308
- #
309
- # Performs an HTTP Delete request.
310
- #
311
- # @yield [response]
312
- # If a block is given, it will be passed the response received
313
- # from the request.
314
- #
315
- # @yieldparam [Net::HTTP::Response] response
316
- # The HTTP response object.
317
- #
318
- # @return [Net::HTTP::Response]
319
- # The response of the HTTP request.
320
- #
321
- # @see Network::HTTP#http_delete
322
- #
323
- # @api public
324
- #
325
- def http_delete(options={},&block)
326
- options = http_merge_options(options)
327
- print_info "HTTP DELETE #{http_options_to_s(options)}"
328
-
329
- return super(options,&block)
330
- end
331
-
332
- #
333
- # Performs an HTTP Get request.
334
- #
335
- # @yield [response]
336
- # If a block is given, it will be passed the response received
337
- # from the request.
338
- #
339
- # @yieldparam [Net::HTTP::Response] response
340
- # The HTTP response object.
341
- #
342
- # @return [Net::HTTP::Response]
343
- # The response of the HTTP request.
344
- #
345
- # @see Network::HTTP#http_get
346
- #
347
- # @api public
348
- #
349
- def http_get(options={},&block)
350
- options = http_merge_options(options)
351
- print_info "HTTP GET #{http_options_to_s(options)}"
352
-
353
- return super(options,&block)
354
- end
355
-
356
- #
357
- # Performs an HTTP Get request.
358
- #
359
- # @yield [response]
360
- # If a block is given, it will be passed the response received
361
- # from the request.
362
- #
363
- # @yieldparam [Net::HTTP::Response] response
364
- # The HTTP response object.
365
- #
366
- # @return [String]
367
- # The body of the HTTP Get request.
368
- #
369
- # @see Network::HTTP#http_get_body
370
- #
371
- # @api public
372
- #
373
- def http_get_body(options={},&block)
374
- options = http_merge_options(options)
375
- print_info "HTTP GET #{http_options_to_s(options)}"
376
-
377
- return super(options,&block)
378
- end
379
-
380
- #
381
- # Performs an HTTP Head request.
382
- #
383
- # @yield [response]
384
- # If a block is given, it will be passed the response received
385
- # from the request.
386
- #
387
- # @yieldparam [Net::HTTP::Response] response
388
- # The HTTP response object.
389
- #
390
- # @return [Net::HTTP::Response]
391
- # The response of the HTTP request.
392
- #
393
- # @see Network::HTTP#http_head
394
- #
395
- # @api public
396
- #
397
- def http_head(options={},&block)
398
- options = http_merge_options(options)
399
- print_info "HTTP HEAD #{http_options_to_s(options)}"
400
-
401
- return super(options,&block)
402
- end
403
-
404
- #
405
- # Performs an HTTP Lock request.
406
- #
407
- # @yield [response]
408
- # If a block is given, it will be passed the response received
409
- # from the request.
410
- #
411
- # @yieldparam [Net::HTTP::Response] response
412
- # The HTTP response object.
413
- #
414
- # @return [Net::HTTP::Response]
415
- # The response of the HTTP request.
416
- #
417
- # @see Network::HTTP#http_lock
418
- #
419
- # @api public
420
- #
421
- def http_lock(options={},&block)
422
- options = http_merge_options(options)
423
- print_info "HTTP LOCK #{http_options_to_s(options)}"
424
-
425
- return super(options,&block)
426
- end
427
-
428
- #
429
- # Performs an HTTP Mkcol request.
430
- #
431
- # @yield [response]
432
- # If a block is given, it will be passed the response received
433
- # from the request.
434
- #
435
- # @yieldparam [Net::HTTP::Response] response
436
- # The HTTP response object.
437
- #
438
- # @return [Net::HTTP::Response]
439
- # The response of the HTTP request.
440
- #
441
- # @see Network::HTTP#http_mkcol
442
- #
443
- # @api public
444
- #
445
- def http_mkcol(options={},&block)
446
- options = http_merge_options(options)
447
- print_info "HTTP MKCOL #{http_options_to_s(options)}"
448
-
449
- return super(options,&block)
450
- end
451
-
452
- #
453
- # Performs an HTTP Move request.
454
- #
455
- # @yield [response]
456
- # If a block is given, it will be passed the response received
457
- # from the request.
458
- #
459
- # @yieldparam [Net::HTTP::Response] response
460
- # The HTTP response object.
461
- #
462
- # @return [Net::HTTP::Response]
463
- # The response of the HTTP request.
464
- #
465
- # @see Network::HTTP#http_move
466
- #
467
- # @api public
468
- #
469
- def http_move(options={},&block)
470
- options = http_merge_options(options)
471
- print_info "HTTP MOVE #{http_options_to_s(options)}"
472
-
473
- return super(options,&block)
474
- end
475
-
476
- #
477
- # Performs an HTTP Options request.
478
- #
479
- # @yield [response]
480
- # If a block is given, it will be passed the response received
481
- # from the request.
482
- #
483
- # @yieldparam [Net::HTTP::Response] response
484
- # The HTTP response object.
485
- #
486
- # @return [Net::HTTP::Response]
487
- # The response of the HTTP request.
488
- #
489
- # @see Network::HTTP#http_options
490
- #
491
- # @api public
492
- #
493
- def http_options(options={},&block)
494
- options = http_merge_options(options)
495
- print_info "HTTP OPTIONS #{http_options_to_s(options)}"
496
-
497
- return super(options,&block)
498
- end
499
-
500
- #
501
- # Performs an HTTP Post request.
502
- #
503
- # @param [Hash] options
504
- # Additional options.
505
- #
506
- # @option options [String] :post_data
507
- # The `POSTDATA` to send with the HTTP Post request.
508
- #
509
- # @yield [response]
510
- # If a block is given, it will be passed the response received
511
- # from the request.
512
- #
513
- # @yieldparam [Net::HTTP::Response] response
514
- # The HTTP response object.
515
- #
516
- # @return [Net::HTTP::Response]
517
- # The response of the HTTP request.
518
- #
519
- # @see Network::HTTP#http_post
520
- #
521
- # @api public
522
- #
523
- def http_post(options={},&block)
524
- options = http_merge_options(options)
525
- print_info "HTTP POST #{http_options_to_s(options)}"
526
-
527
- return super(options,&block)
528
- end
529
-
530
- #
531
- # Performs an HTTP Post request.
532
- #
533
- # @yield [response]
534
- # If a block is given, it will be passed the response received
535
- # from the request.
536
- #
537
- # @yieldparam [Net::HTTP::Response] response
538
- # The HTTP response object.
539
- #
540
- # @return [String]
541
- # The body of the Post request.
542
- #
543
- # @see Network::HTTP#http_post_body
544
- #
545
- # @api public
546
- #
547
- def http_post_body(options={},&block)
548
- options = http_merge_options(options)
549
- print_info "HTTP POST #{http_options_to_s(options)}"
550
-
551
- return super(options,&block)
552
- end
553
-
554
- #
555
- # Performs an HTTP PUT request.
556
- #
557
- # @param [Hash] options
558
- # Additional options.
559
- #
560
- # @option options [String] :body
561
- # The body for the request.
562
- #
563
- # @option options [String] :post_data
564
- # The `POSTDATA` to send with the HTTP PUT request.
565
- #
566
- # @yield [response]
567
- # If a block is given, it will be passed the response received
568
- # from the request.
569
- #
570
- # @yieldparam [Net::HTTP::Response] response
571
- # The HTTP response object.
572
- #
573
- # @return [Net::HTTP::Response]
574
- # The response of the HTTP request.
575
- #
576
- # @see Network::HTTP#http_put
577
- #
578
- # @since 0.4.0
579
- #
580
- # @api public
581
- #
582
- def http_put(options={},&block)
583
- options = http_merge_options(options)
584
- print_info "HTTP PUT #{http_options_to_s(options)}"
585
-
586
- return super(options,&block)
587
- end
588
-
589
- #
590
- # Performs an HTTP Propfind request.
591
- #
592
- # @yield [response]
593
- # If a block is given, it will be passed the response received
594
- # from the request.
595
- #
596
- # @yieldparam [Net::HTTP::Response] response
597
- # The HTTP response object.
598
- #
599
- # @return [Net::HTTP::Response]
600
- # The response of the HTTP request.
601
- #
602
- # @see Network::HTTP#http_prop_find
603
- #
604
- # @api public
605
- #
606
- def http_prop_find(options={},&block)
607
- options = http_merge_options(options)
608
- print_info "HTTP PROPFIND #{http_options_to_s(options)}"
609
-
610
- return super(options,&block)
611
- end
612
-
613
- #
614
- # Performs an HTTP Proppatch request.
615
- #
616
- # @yield [response]
617
- # If a block is given, it will be passed the response received
618
- # from the request.
619
- #
620
- # @yieldparam [Net::HTTP::Response] response
621
- # The HTTP response object.
622
- #
623
- # @return [Net::HTTP::Response]
624
- # The response of the HTTP request.
625
- #
626
- # @see Network::HTTP#http_prop_patch
627
- #
628
- # @api public
629
- #
630
- def http_prop_patch(options={},&block)
631
- options = http_merge_options(options)
632
- print_info "HTTP PROPPATCH #{http_options_to_s(options)}"
633
-
634
- return super(options,&block)
635
- end
636
-
637
- #
638
- # Performs an HTTP Trace request.
639
- #
640
- # @yield [response]
641
- # If a block is given, it will be passed the response received
642
- # from the request.
643
- #
644
- # @yieldparam [Net::HTTP::Response] response
645
- # The HTTP response object.
646
- #
647
- # @return [Net::HTTP::Response]
648
- # The response of the HTTP request.
649
- #
650
- # @see Network::HTTP#http_trace
651
- #
652
- # @api public
653
- #
654
- def http_trace(options={},&block)
655
- options = http_merge_options(options)
656
- print_info "HTTP TRACE #{http_options_to_s(options)}"
657
-
658
- return super(options,&block)
659
- end
660
-
661
- #
662
- # Performs an HTTP Unlock request.
663
- #
664
- # @yield [response]
665
- # If a block is given, it will be passed the response received
666
- # from the request.
667
- #
668
- # @yieldparam [Net::HTTP::Response] response
669
- # The HTTP response object.
670
- #
671
- # @return [Net::HTTP::Response]
672
- # The response of the HTTP request.
673
- #
674
- # @see Network::HTTP#http_unlock
675
- #
676
- # @api public
677
- #
678
- def http_unlock(options={},&block)
679
- options = http_merge_options(options)
680
- print_info "HTTP UNLOCK #{http_options_to_s(options)}"
681
-
682
- return super(options,&block)
186
+ return response
683
187
  end
684
188
 
685
189
  private
@@ -698,58 +202,25 @@ module Ronin
698
202
  # @api private
699
203
  #
700
204
  def http_merge_options(options={})
701
- options[:host] ||= self.host if self.host
702
- options[:port] ||= self.port if self.port
205
+ options = options.dup
206
+
207
+ options[:proxy] ||= self.http_proxy if self.http_proxy
208
+ options[:host] ||= self.host if self.host
209
+ options[:port] ||= self.port if self.port
703
210
 
704
211
  if (self.http_vhost || self.http_user_agent)
705
- headers = options.fetch(:headers,{})
212
+ headers = (options[:headers] ||= {})
706
213
 
707
- headers[:host] ||= self.http_vhost if self.http_vhost
214
+ headers[:host] ||= self.http_vhost if self.http_vhost
708
215
  headers[:user_agent] ||= self.http_user_agent if self.http_user_agent
709
-
710
- options[:headers] = headers
711
216
  end
712
217
 
713
- options[:user] ||= self.http_user if self.http_user
218
+ options[:user] ||= self.http_user if self.http_user
714
219
  options[:password] ||= self.http_password if self.http_password
715
220
 
716
- options[:proxy] ||= self.http_proxy if self.http_proxy
717
-
718
221
  return options
719
222
  end
720
223
 
721
- #
722
- # Converts the HTTP options to a printable String.
723
- #
724
- # @param [Hash] options
725
- # HTTP options.
726
- #
727
- # @return [String]
728
- # The printable String.
729
- #
730
- # @since 1.1.0
731
- #
732
- # @api private
733
- #
734
- def http_options_to_s(options)
735
- fields = ["#{options[:host]}:#{options[:port]}"]
736
-
737
- if (options[:user] || options[:password])
738
- fields << "#{options[:user]}:#{options[:password]}"
739
- end
740
-
741
- path = options[:path]
742
- path += "?#{options[:query]}" if options[:query]
743
-
744
- fields << path
745
-
746
- if options[:headers]
747
- fields << ("%p" % options[:headers])
748
- end
749
-
750
- return fields.join(' ')
751
- end
752
-
753
224
  end
754
225
  end
755
226
  end