ronin-support 1.0.7 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (319) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +28 -0
  3. data/ChangeLog.md +109 -7
  4. data/README.md +5 -1
  5. data/lib/ronin/support/archive/core_ext/file.rb +1 -1
  6. data/lib/ronin/support/archive/core_ext.rb +1 -1
  7. data/lib/ronin/support/archive/mixin.rb +1 -1
  8. data/lib/ronin/support/archive/tar/reader.rb +1 -1
  9. data/lib/ronin/support/archive/tar/writer.rb +1 -1
  10. data/lib/ronin/support/archive/tar.rb +1 -1
  11. data/lib/ronin/support/archive/zip/reader/entry.rb +1 -1
  12. data/lib/ronin/support/archive/zip/reader/statistics.rb +1 -1
  13. data/lib/ronin/support/archive/zip/reader.rb +1 -1
  14. data/lib/ronin/support/archive/zip/writer.rb +1 -1
  15. data/lib/ronin/support/archive/zip.rb +1 -1
  16. data/lib/ronin/support/archive.rb +1 -1
  17. data/lib/ronin/support/binary/array.rb +1 -1
  18. data/lib/ronin/support/binary/bit_flip/core_ext/integer.rb +1 -1
  19. data/lib/ronin/support/binary/bit_flip/core_ext/string.rb +1 -1
  20. data/lib/ronin/support/binary/bit_flip/core_ext.rb +1 -1
  21. data/lib/ronin/support/binary/bit_flip.rb +1 -1
  22. data/lib/ronin/support/binary/buffer.rb +1 -1
  23. data/lib/ronin/support/binary/byte_slice.rb +1 -1
  24. data/lib/ronin/support/binary/core_ext/array.rb +1 -1
  25. data/lib/ronin/support/binary/core_ext/float.rb +3 -2
  26. data/lib/ronin/support/binary/core_ext/integer.rb +3 -2
  27. data/lib/ronin/support/binary/core_ext/io.rb +1 -1
  28. data/lib/ronin/support/binary/core_ext/string.rb +1 -1
  29. data/lib/ronin/support/binary/core_ext.rb +1 -1
  30. data/lib/ronin/support/binary/cstring.rb +1 -1
  31. data/lib/ronin/support/binary/ctypes/aggregate_type.rb +1 -1
  32. data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +1 -1
  33. data/lib/ronin/support/binary/ctypes/arch/arm.rb +1 -1
  34. data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +1 -1
  35. data/lib/ronin/support/binary/ctypes/arch/arm64.rb +1 -1
  36. data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +1 -1
  37. data/lib/ronin/support/binary/ctypes/arch/mips.rb +1 -1
  38. data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +1 -1
  39. data/lib/ronin/support/binary/ctypes/arch/mips64.rb +1 -1
  40. data/lib/ronin/support/binary/ctypes/arch/ppc.rb +1 -1
  41. data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +1 -1
  42. data/lib/ronin/support/binary/ctypes/arch/x86.rb +1 -1
  43. data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +1 -1
  44. data/lib/ronin/support/binary/ctypes/arch.rb +1 -1
  45. data/lib/ronin/support/binary/ctypes/array_object_type.rb +1 -1
  46. data/lib/ronin/support/binary/ctypes/array_type.rb +1 -1
  47. data/lib/ronin/support/binary/ctypes/big_endian.rb +1 -1
  48. data/lib/ronin/support/binary/ctypes/char_type.rb +1 -1
  49. data/lib/ronin/support/binary/ctypes/char_types.rb +1 -1
  50. data/lib/ronin/support/binary/ctypes/enum_type.rb +1 -1
  51. data/lib/ronin/support/binary/ctypes/float32_type.rb +1 -1
  52. data/lib/ronin/support/binary/ctypes/float64_type.rb +1 -1
  53. data/lib/ronin/support/binary/ctypes/float_type.rb +1 -1
  54. data/lib/ronin/support/binary/ctypes/int16_type.rb +1 -1
  55. data/lib/ronin/support/binary/ctypes/int32_type.rb +1 -1
  56. data/lib/ronin/support/binary/ctypes/int64_type.rb +1 -1
  57. data/lib/ronin/support/binary/ctypes/int8_type.rb +1 -1
  58. data/lib/ronin/support/binary/ctypes/int_type.rb +1 -1
  59. data/lib/ronin/support/binary/ctypes/little_endian.rb +1 -1
  60. data/lib/ronin/support/binary/ctypes/mixin.rb +11 -5
  61. data/lib/ronin/support/binary/ctypes/native.rb +1 -1
  62. data/lib/ronin/support/binary/ctypes/network.rb +1 -1
  63. data/lib/ronin/support/binary/ctypes/object_type.rb +1 -1
  64. data/lib/ronin/support/binary/ctypes/os/android.rb +39 -0
  65. data/lib/ronin/support/binary/ctypes/os/apple_ios.rb +39 -0
  66. data/lib/ronin/support/binary/ctypes/os/bsd.rb +1 -1
  67. data/lib/ronin/support/binary/ctypes/os/freebsd.rb +1 -1
  68. data/lib/ronin/support/binary/ctypes/os/linux.rb +1 -1
  69. data/lib/ronin/support/binary/ctypes/os/macos.rb +1 -1
  70. data/lib/ronin/support/binary/ctypes/os/netbsd.rb +1 -1
  71. data/lib/ronin/support/binary/ctypes/os/openbsd.rb +1 -1
  72. data/lib/ronin/support/binary/ctypes/os/unix.rb +1 -1
  73. data/lib/ronin/support/binary/ctypes/os/windows.rb +1 -1
  74. data/lib/ronin/support/binary/ctypes/os.rb +8 -3
  75. data/lib/ronin/support/binary/ctypes/scalar_type.rb +1 -1
  76. data/lib/ronin/support/binary/ctypes/string_type.rb +1 -1
  77. data/lib/ronin/support/binary/ctypes/struct_object_type.rb +1 -1
  78. data/lib/ronin/support/binary/ctypes/struct_type.rb +1 -1
  79. data/lib/ronin/support/binary/ctypes/type.rb +1 -1
  80. data/lib/ronin/support/binary/ctypes/type_resolver.rb +7 -3
  81. data/lib/ronin/support/binary/ctypes/uint16_type.rb +1 -1
  82. data/lib/ronin/support/binary/ctypes/uint32_type.rb +1 -1
  83. data/lib/ronin/support/binary/ctypes/uint64_type.rb +1 -1
  84. data/lib/ronin/support/binary/ctypes/uint8_type.rb +1 -1
  85. data/lib/ronin/support/binary/ctypes/uint_type.rb +1 -1
  86. data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +1 -1
  87. data/lib/ronin/support/binary/ctypes/union_object_type.rb +1 -1
  88. data/lib/ronin/support/binary/ctypes/union_type.rb +1 -1
  89. data/lib/ronin/support/binary/ctypes.rb +16 -10
  90. data/lib/ronin/support/binary/memory.rb +1 -1
  91. data/lib/ronin/support/binary/packet.rb +1 -1
  92. data/lib/ronin/support/binary/stack.rb +1 -1
  93. data/lib/ronin/support/binary/stream/methods.rb +1 -1
  94. data/lib/ronin/support/binary/stream.rb +1 -1
  95. data/lib/ronin/support/binary/struct/member.rb +1 -1
  96. data/lib/ronin/support/binary/struct.rb +3 -2
  97. data/lib/ronin/support/binary/template.rb +1 -1
  98. data/lib/ronin/support/binary/unhexdump/core_ext/file.rb +1 -1
  99. data/lib/ronin/support/binary/unhexdump/core_ext/string.rb +1 -1
  100. data/lib/ronin/support/binary/unhexdump/core_ext.rb +1 -1
  101. data/lib/ronin/support/binary/unhexdump/parser.rb +1 -1
  102. data/lib/ronin/support/binary/unhexdump.rb +1 -1
  103. data/lib/ronin/support/binary/union.rb +1 -1
  104. data/lib/ronin/support/binary.rb +1 -1
  105. data/lib/ronin/support/cli/ansi.rb +1 -1
  106. data/lib/ronin/support/cli/io_shell/core_ext/io.rb +1 -1
  107. data/lib/ronin/support/cli/io_shell/core_ext.rb +1 -1
  108. data/lib/ronin/support/cli/io_shell.rb +1 -1
  109. data/lib/ronin/support/cli/printing.rb +1 -1
  110. data/lib/ronin/support/cli.rb +1 -1
  111. data/lib/ronin/support/compression/core_ext/file.rb +1 -1
  112. data/lib/ronin/support/compression/core_ext/string.rb +1 -1
  113. data/lib/ronin/support/compression/core_ext.rb +1 -1
  114. data/lib/ronin/support/compression/gzip/reader.rb +1 -1
  115. data/lib/ronin/support/compression/gzip/writer.rb +1 -1
  116. data/lib/ronin/support/compression/gzip.rb +1 -1
  117. data/lib/ronin/support/compression/mixin.rb +1 -1
  118. data/lib/ronin/support/compression/zlib.rb +1 -1
  119. data/lib/ronin/support/compression.rb +1 -1
  120. data/lib/ronin/support/core_ext/enumerable.rb +1 -1
  121. data/lib/ronin/support/core_ext/file.rb +1 -1
  122. data/lib/ronin/support/core_ext/integer.rb +1 -1
  123. data/lib/ronin/support/core_ext/ipaddr.rb +1 -1
  124. data/lib/ronin/support/core_ext/kernel.rb +1 -1
  125. data/lib/ronin/support/core_ext/string.rb +1 -1
  126. data/lib/ronin/support/core_ext.rb +1 -1
  127. data/lib/ronin/support/crypto/cert.rb +50 -8
  128. data/lib/ronin/support/crypto/cert_chain.rb +1 -1
  129. data/lib/ronin/support/crypto/cipher/aes.rb +1 -1
  130. data/lib/ronin/support/crypto/cipher/aes128.rb +1 -1
  131. data/lib/ronin/support/crypto/cipher/aes256.rb +1 -1
  132. data/lib/ronin/support/crypto/cipher.rb +1 -1
  133. data/lib/ronin/support/crypto/core_ext/file.rb +1 -1
  134. data/lib/ronin/support/crypto/core_ext/string.rb +1 -1
  135. data/lib/ronin/support/crypto/core_ext.rb +1 -1
  136. data/lib/ronin/support/crypto/hmac.rb +1 -1
  137. data/lib/ronin/support/crypto/key/dh.rb +1 -1
  138. data/lib/ronin/support/crypto/key/dsa.rb +1 -1
  139. data/lib/ronin/support/crypto/key/ec.rb +25 -1
  140. data/lib/ronin/support/crypto/key/methods.rb +1 -1
  141. data/lib/ronin/support/crypto/key/rsa.rb +1 -1
  142. data/lib/ronin/support/crypto/key.rb +48 -4
  143. data/lib/ronin/support/crypto/mixin.rb +1 -1
  144. data/lib/ronin/support/crypto/openssl.rb +1 -1
  145. data/lib/ronin/support/crypto.rb +1 -1
  146. data/lib/ronin/support/encoding/base16/core_ext/string.rb +1 -1
  147. data/lib/ronin/support/encoding/base16/core_ext.rb +1 -1
  148. data/lib/ronin/support/encoding/base16.rb +1 -1
  149. data/lib/ronin/support/encoding/base32/core_ext/string.rb +1 -1
  150. data/lib/ronin/support/encoding/base32/core_ext.rb +1 -1
  151. data/lib/ronin/support/encoding/base32.rb +1 -1
  152. data/lib/ronin/support/encoding/base36/core_ext/integer.rb +43 -0
  153. data/lib/ronin/support/encoding/base36/core_ext/string.rb +43 -0
  154. data/lib/ronin/support/encoding/base36/core_ext.rb +20 -0
  155. data/lib/ronin/support/encoding/base36.rb +67 -0
  156. data/lib/ronin/support/encoding/base62/core_ext/integer.rb +43 -0
  157. data/lib/ronin/support/encoding/base62/core_ext/string.rb +43 -0
  158. data/lib/ronin/support/encoding/base62/core_ext.rb +20 -0
  159. data/lib/ronin/support/encoding/base62.rb +93 -0
  160. data/lib/ronin/support/encoding/base64/core_ext/string.rb +1 -1
  161. data/lib/ronin/support/encoding/base64/core_ext.rb +1 -1
  162. data/lib/ronin/support/encoding/base64.rb +1 -1
  163. data/lib/ronin/support/encoding/c/core_ext/integer.rb +1 -1
  164. data/lib/ronin/support/encoding/c/core_ext/string.rb +1 -1
  165. data/lib/ronin/support/encoding/c/core_ext.rb +1 -1
  166. data/lib/ronin/support/encoding/c.rb +1 -1
  167. data/lib/ronin/support/encoding/core_ext/string.rb +1 -1
  168. data/lib/ronin/support/encoding/core_ext.rb +1 -1
  169. data/lib/ronin/support/encoding/hex/core_ext/integer.rb +1 -1
  170. data/lib/ronin/support/encoding/hex/core_ext/string.rb +1 -1
  171. data/lib/ronin/support/encoding/hex/core_ext.rb +1 -1
  172. data/lib/ronin/support/encoding/hex.rb +1 -1
  173. data/lib/ronin/support/encoding/html/core_ext/integer.rb +1 -1
  174. data/lib/ronin/support/encoding/html/core_ext/string.rb +1 -1
  175. data/lib/ronin/support/encoding/html/core_ext.rb +1 -1
  176. data/lib/ronin/support/encoding/html.rb +1 -1
  177. data/lib/ronin/support/encoding/http/core_ext/integer.rb +1 -1
  178. data/lib/ronin/support/encoding/http/core_ext/string.rb +1 -1
  179. data/lib/ronin/support/encoding/http/core_ext.rb +1 -1
  180. data/lib/ronin/support/encoding/http.rb +1 -1
  181. data/lib/ronin/support/encoding/js/core_ext/integer.rb +1 -1
  182. data/lib/ronin/support/encoding/js/core_ext/string.rb +1 -1
  183. data/lib/ronin/support/encoding/js/core_ext.rb +1 -1
  184. data/lib/ronin/support/encoding/js.rb +10 -16
  185. data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +1 -1
  186. data/lib/ronin/support/encoding/powershell/core_ext/string.rb +1 -1
  187. data/lib/ronin/support/encoding/powershell/core_ext.rb +1 -1
  188. data/lib/ronin/support/encoding/powershell.rb +1 -1
  189. data/lib/ronin/support/encoding/punycode/core_ext/string.rb +1 -1
  190. data/lib/ronin/support/encoding/punycode/core_ext.rb +1 -1
  191. data/lib/ronin/support/encoding/punycode.rb +1 -1
  192. data/lib/ronin/support/encoding/quoted_printable/core_ext/string.rb +1 -1
  193. data/lib/ronin/support/encoding/quoted_printable/core_ext.rb +1 -1
  194. data/lib/ronin/support/encoding/quoted_printable.rb +1 -1
  195. data/lib/ronin/support/encoding/ruby/core_ext/string.rb +1 -1
  196. data/lib/ronin/support/encoding/ruby/core_ext.rb +1 -1
  197. data/lib/ronin/support/encoding/ruby.rb +1 -1
  198. data/lib/ronin/support/encoding/shell/core_ext/integer.rb +1 -1
  199. data/lib/ronin/support/encoding/shell/core_ext/string.rb +1 -1
  200. data/lib/ronin/support/encoding/shell/core_ext.rb +1 -1
  201. data/lib/ronin/support/encoding/shell.rb +1 -1
  202. data/lib/ronin/support/encoding/smtp.rb +1 -1
  203. data/lib/ronin/support/encoding/sql/core_ext/string.rb +1 -1
  204. data/lib/ronin/support/encoding/sql/core_ext.rb +1 -1
  205. data/lib/ronin/support/encoding/sql.rb +1 -1
  206. data/lib/ronin/support/encoding/uri/core_ext/integer.rb +1 -1
  207. data/lib/ronin/support/encoding/uri/core_ext/string.rb +1 -1
  208. data/lib/ronin/support/encoding/uri/core_ext.rb +1 -1
  209. data/lib/ronin/support/encoding/uri.rb +1 -1
  210. data/lib/ronin/support/encoding/uuencoding/core_ext/string.rb +1 -1
  211. data/lib/ronin/support/encoding/uuencoding/core_ext.rb +1 -1
  212. data/lib/ronin/support/encoding/uuencoding.rb +1 -1
  213. data/lib/ronin/support/encoding/xml/core_ext/integer.rb +1 -1
  214. data/lib/ronin/support/encoding/xml/core_ext/string.rb +1 -1
  215. data/lib/ronin/support/encoding/xml/core_ext.rb +1 -1
  216. data/lib/ronin/support/encoding/xml.rb +1 -1
  217. data/lib/ronin/support/encoding.rb +7 -1
  218. data/lib/ronin/support/home.rb +1 -1
  219. data/lib/ronin/support/mixin.rb +1 -1
  220. data/lib/ronin/support/network/asn/dns_record.rb +1 -1
  221. data/lib/ronin/support/network/asn/list.rb +1 -1
  222. data/lib/ronin/support/network/asn/record.rb +1 -1
  223. data/lib/ronin/support/network/asn/record_set.rb +1 -1
  224. data/lib/ronin/support/network/asn.rb +1 -1
  225. data/lib/ronin/support/network/core_ext.rb +1 -1
  226. data/lib/ronin/support/network/dns/idn.rb +1 -1
  227. data/lib/ronin/support/network/dns/mixin.rb +1 -1
  228. data/lib/ronin/support/network/dns/resolver.rb +1 -1
  229. data/lib/ronin/support/network/dns.rb +1 -1
  230. data/lib/ronin/support/network/domain.rb +1 -1
  231. data/lib/ronin/support/network/email_address.rb +1 -1
  232. data/lib/ronin/support/network/esmtp/mixin.rb +1 -1
  233. data/lib/ronin/support/network/exceptions.rb +1 -1
  234. data/lib/ronin/support/network/ftp/mixin.rb +1 -1
  235. data/lib/ronin/support/network/host.rb +1 -1
  236. data/lib/ronin/support/network/http/cookie.rb +1 -1
  237. data/lib/ronin/support/network/http/core_ext/uri/http.rb +1 -1
  238. data/lib/ronin/support/network/http/core_ext.rb +1 -1
  239. data/lib/ronin/support/network/http/mixin.rb +42 -1
  240. data/lib/ronin/support/network/http/request.rb +86 -9
  241. data/lib/ronin/support/network/http/set_cookie.rb +1 -1
  242. data/lib/ronin/support/network/http/user_agents.rb +1 -1
  243. data/lib/ronin/support/network/http.rb +138 -6
  244. data/lib/ronin/support/network/imap/mixin.rb +1 -1
  245. data/lib/ronin/support/network/ip/mixin.rb +1 -1
  246. data/lib/ronin/support/network/ip.rb +42 -1
  247. data/lib/ronin/support/network/ip_range/cidr.rb +123 -1
  248. data/lib/ronin/support/network/ip_range/glob.rb +150 -10
  249. data/lib/ronin/support/network/ip_range/range.rb +34 -2
  250. data/lib/ronin/support/network/ip_range.rb +120 -5
  251. data/lib/ronin/support/network/mixin.rb +1 -11
  252. data/lib/ronin/support/network/packet.rb +1 -1
  253. data/lib/ronin/support/network/pop3/mixin.rb +1 -1
  254. data/lib/ronin/support/network/proxy.rb +1 -1
  255. data/lib/ronin/support/network/public_suffix/list.rb +1 -1
  256. data/lib/ronin/support/network/public_suffix/suffix.rb +1 -1
  257. data/lib/ronin/support/network/public_suffix/suffix_set.rb +1 -1
  258. data/lib/ronin/support/network/public_suffix.rb +1 -1
  259. data/lib/ronin/support/network/smtp/email.rb +1 -1
  260. data/lib/ronin/support/network/smtp/mixin.rb +1 -1
  261. data/lib/ronin/support/network/smtp.rb +1 -1
  262. data/lib/ronin/support/network/ssl/local_cert.rb +1 -1
  263. data/lib/ronin/support/network/ssl/local_key.rb +1 -1
  264. data/lib/ronin/support/network/ssl/mixin.rb +169 -400
  265. data/lib/ronin/support/network/ssl/openssl.rb +1 -1
  266. data/lib/ronin/support/network/ssl/proxy.rb +1 -1
  267. data/lib/ronin/support/network/ssl.rb +592 -13
  268. data/lib/ronin/support/network/tcp/mixin.rb +1 -1
  269. data/lib/ronin/support/network/tcp/proxy.rb +1 -1
  270. data/lib/ronin/support/network/tcp.rb +1 -1
  271. data/lib/ronin/support/network/telnet/mixin.rb +1 -1
  272. data/lib/ronin/support/network/telnet.rb +1 -1
  273. data/lib/ronin/support/network/tld/list.rb +1 -1
  274. data/lib/ronin/support/network/tld.rb +1 -1
  275. data/lib/ronin/support/network/tls/mixin.rb +174 -348
  276. data/lib/ronin/support/network/tls/proxy.rb +1 -1
  277. data/lib/ronin/support/network/tls.rb +492 -6
  278. data/lib/ronin/support/network/udp/mixin.rb +1 -1
  279. data/lib/ronin/support/network/udp/proxy.rb +1 -1
  280. data/lib/ronin/support/network/udp.rb +1 -1
  281. data/lib/ronin/support/network/unix/mixin.rb +1 -1
  282. data/lib/ronin/support/network/wildcard.rb +88 -0
  283. data/lib/ronin/support/network.rb +1 -1
  284. data/lib/ronin/support/path.rb +1 -1
  285. data/lib/ronin/support/text/core_ext/regexp.rb +1 -1
  286. data/lib/ronin/support/text/core_ext/string.rb +1 -1
  287. data/lib/ronin/support/text/core_ext.rb +1 -1
  288. data/lib/ronin/support/text/entropy/core_ext/string.rb +1 -1
  289. data/lib/ronin/support/text/entropy/core_ext.rb +1 -1
  290. data/lib/ronin/support/text/entropy.rb +1 -1
  291. data/lib/ronin/support/text/erb/mixin.rb +1 -1
  292. data/lib/ronin/support/text/erb.rb +1 -1
  293. data/lib/ronin/support/text/homoglyph/core_ext/string.rb +1 -1
  294. data/lib/ronin/support/text/homoglyph/core_ext.rb +1 -1
  295. data/lib/ronin/support/text/homoglyph/exceptions.rb +1 -1
  296. data/lib/ronin/support/text/homoglyph/table.rb +1 -1
  297. data/lib/ronin/support/text/homoglyph.rb +1 -1
  298. data/lib/ronin/support/text/mixin.rb +1 -1
  299. data/lib/ronin/support/text/patterns/credentials.rb +1 -1
  300. data/lib/ronin/support/text/patterns/crypto.rb +1 -1
  301. data/lib/ronin/support/text/patterns/file_system.rb +1 -1
  302. data/lib/ronin/support/text/patterns/language.rb +1 -1
  303. data/lib/ronin/support/text/patterns/network/public_suffix.rb +1 -1
  304. data/lib/ronin/support/text/patterns/network.rb +1 -1
  305. data/lib/ronin/support/text/patterns/numeric.rb +1 -1
  306. data/lib/ronin/support/text/patterns/pii.rb +1 -1
  307. data/lib/ronin/support/text/patterns/source_code.rb +1 -1
  308. data/lib/ronin/support/text/patterns.rb +1 -1
  309. data/lib/ronin/support/text/random/mixin.rb +1 -1
  310. data/lib/ronin/support/text/random.rb +1 -1
  311. data/lib/ronin/support/text/typo/core_ext/string.rb +1 -1
  312. data/lib/ronin/support/text/typo/core_ext.rb +1 -1
  313. data/lib/ronin/support/text/typo/exceptions.rb +1 -1
  314. data/lib/ronin/support/text/typo/generator.rb +1 -1
  315. data/lib/ronin/support/text/typo.rb +1 -1
  316. data/lib/ronin/support/text.rb +1 -1
  317. data/lib/ronin/support/version.rb +2 -2
  318. data/lib/ronin/support.rb +1 -1
  319. metadata +13 -2
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
3
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
4
4
  #
5
5
  # Ronin Support is free software: you can redistribute it and/or modify
6
6
  # it under the terms of the GNU Lesser General Public License as published
@@ -17,8 +17,6 @@
17
17
  #
18
18
 
19
19
  require 'ronin/support/network/ssl'
20
- require 'ronin/support/network/tcp/mixin'
21
- require 'ronin/support/crypto/cert'
22
20
 
23
21
  module Ronin
24
22
  module Support
@@ -28,50 +26,55 @@ module Ronin
28
26
  # Provides helper methods for communicating with SSL-enabled services.
29
27
  #
30
28
  module Mixin
31
- include TCP::Mixin
32
-
33
29
  #
34
- # Creates a new SSL Context.
30
+ # @!macro context_kwargs
31
+ # @option kwargs [1, 1.1, 1.2, 1.3, Symbol, nil] :version
32
+ # The SSL version to use.
35
33
  #
36
- # @param [Hash{Symbol => Object}] kwargs
37
- # Additional keyword arguments.
34
+ # @option kwargs [Symbol, Boolean] :verify
35
+ # Specifies whether to verify the SSL certificate.
36
+ # May be one of the following:
37
+ #
38
+ # * `:none`
39
+ # * `:peer`
40
+ # * `:fail_if_no_peer_cert`
41
+ # * `:client_once`
38
42
  #
39
- # @option kwargs [1, 1.1, 1.2, String, Symbol, nil] :version
40
- # The SSL version to use.
43
+ # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
44
+ # The RSA key to use for the SSL context.
41
45
  #
42
- # @option kwargs [Symbol, Boolean] :verify
43
- # Specifies whether to verify the SSL certificate.
44
- # May be one of the following:
46
+ # @option kwargs [String] :key_file
47
+ # The path to the SSL `.key` file.
45
48
  #
46
- # * `:none`
47
- # * `:peer`
48
- # * `:fail_if_no_peer_cert`
49
- # * `:client_once`
49
+ # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
50
+ # The X509 certificate to use for the SSL context.
50
51
  #
51
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
52
- # The RSA key to use for the SSL context.
52
+ # @option kwargs [String] :cert_file
53
+ # The path to the SSL `.crt` file.
53
54
  #
54
- # @option kwargs [String] :key_file
55
- # The path to the SSL `.key` file.
55
+ # @option kwargs [String] :ca_bundle
56
+ # Path to the CA certificate file or directory.
56
57
  #
57
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
58
- # The X509 certificate to use for the SSL context.
58
+
59
+ #
60
+ # Creates a new SSL Context.
59
61
  #
60
- # @option kwargs [String] :cert_file
61
- # The path to the SSL `.crt` file.
62
+ # @param [Hash{Symbol => Object}] kwargs
63
+ # Additional keyword arguments.
62
64
  #
63
- # @option kwargs [String] :ca_bundle
64
- # Path to the CA certificate file or directory.
65
+ # @!macro context_kwargs
65
66
  #
66
67
  # @return [OpenSSL::SSL::SSLContext]
67
68
  # The newly created SSL Context.
68
69
  #
69
70
  # @api semipublic
70
71
  #
72
+ # @see SSL.context
73
+ #
71
74
  # @since 0.6.0
72
75
  #
73
76
  def ssl_context(**kwargs)
74
- Network::SSL.context(**kwargs)
77
+ SSL.context(**kwargs)
75
78
  end
76
79
 
77
80
  #
@@ -83,44 +86,32 @@ module Ronin
83
86
  # @param [Hash{Symbol => Object}] kwargs
84
87
  # Additional keyword arguments for {#ssl_context}.
85
88
  #
86
- # @option kwargs [Symbol, Boolean] :verify
87
- # Specifies whether to verify the SSL certificate.
88
- # May be one of the following:
89
- #
90
- # * `:none`
91
- # * `:peer`
92
- # * `:fail_if_no_peer_cert`
93
- # * `:client_once`
94
- #
95
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
96
- # The RSA key to use for the SSL context.
97
- #
98
- # @option kwargs [String] :key_file
99
- # The path to the SSL `.key` file.
100
- #
101
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
102
- # The X509 certificate to use for the SSL context.
103
- #
104
- # @option kwargs [String] :cert_file
105
- # The path to the SSL `.crt` file.
106
- #
107
- # @option kwargs [String] :ca_bundle
108
- # Path to the CA certificate file or directory.
89
+ # @!macro context_kwargs
109
90
  #
110
91
  # @return [OpenSSL::SSL::SSLSocket]
111
92
  # The new SSL Socket.
112
93
  #
113
94
  # @api public
114
95
  #
96
+ # @see SSL.socket
97
+ #
115
98
  # @since 0.6.0
116
99
  #
117
100
  def ssl_socket(socket,**kwargs)
118
- ssl_socket = OpenSSL::SSL::SSLSocket.new(socket,ssl_context(**kwargs))
119
-
120
- ssl_socket.sync_close = true
121
- return ssl_socket
101
+ SSL.socket(socket,**kwargs)
122
102
  end
123
103
 
104
+ #
105
+ # @!macro connect_kwargs
106
+ # @option kwargs [String] :bind_host
107
+ # The local host to bind to.
108
+ #
109
+ # @option kwargs [Integer] :bind_port
110
+ # The local port to bind to.
111
+ #
112
+ # @!macro context_kwargs
113
+ #
114
+
124
115
  #
125
116
  # Tests whether a remote SSLed TCP port is open.
126
117
  #
@@ -130,41 +121,13 @@ module Ronin
130
121
  # @param [Integer] port
131
122
  # The port to connect to.
132
123
  #
133
- # @param [String] bind_host
134
- # The local host to bind to.
135
- #
136
- # @param [Integer] bind_port
137
- # The local port to bind to.
138
- #
139
- # @param [Integer] timeout (5)
140
- # The maximum time to attempt connecting.
141
- #
142
124
  # @param [Hash{Symbol => Object}] kwargs
143
125
  # Additional keyword arguments for {#ssl_connect}.
144
126
  #
145
- # @option options [Symbol, Boolean] :verify
146
- # Specifies whether to verify the SSL certificate.
147
- # May be one of the following:
148
- #
149
- # * `:none`
150
- # * `:peer`
151
- # * `:fail_if_no_peer_cert`
152
- # * `:client_once`
153
- #
154
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
155
- # The RSA key to use for the SSL context.
127
+ # @!macro connect_kwargs
156
128
  #
157
- # @option kwargs [String] :key_file
158
- # The path to the SSL `.key` file.
159
- #
160
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
161
- # The X509 certificate to use for the SSL context.
162
- #
163
- # @option kwargs [String] :cert_file
164
- # The path to the SSL `.crt` file.
165
- #
166
- # @option kwargs [String] :ca_bundle
167
- # Path to the CA certificate file or directory.
129
+ # @option kwargs [Integer] :timeout (5)
130
+ # The maximum time to attempt connecting.
168
131
  #
169
132
  # @return [Boolean, nil]
170
133
  # Specifies whether the remote SSLed TCP port is open.
@@ -179,21 +142,12 @@ module Ronin
179
142
  #
180
143
  # @api public
181
144
  #
145
+ # @see SSL.open?
146
+ #
182
147
  # @since 0.6.0
183
148
  #
184
- def ssl_open?(host,port, bind_host: nil, bind_port: nil, timeout: 5,
185
- **kwargs)
186
- Timeout.timeout(timeout) do
187
- ssl_connect(host,port, bind_host: bind_host,
188
- bind_port: bind_port,
189
- **kwargs)
190
- end
191
-
192
- return true
193
- rescue Timeout::Error
194
- return nil
195
- rescue SocketError, SystemCallError
196
- return false
149
+ def ssl_open?(host,port,**kwargs)
150
+ SSL.open?(host,port,**kwargs)
197
151
  end
198
152
 
199
153
  #
@@ -205,38 +159,10 @@ module Ronin
205
159
  # @param [Integer] port
206
160
  # The port to connect to.
207
161
  #
208
- # @param [String] bind_host
209
- # The local host to bind to.
210
- #
211
- # @param [Integer] bind_port
212
- # The local port to bind to.
213
- #
214
162
  # @param [Hash{Symbol => Object}] kwargs
215
163
  # Additional keyword arguments for {#ssl_socket}.
216
164
  #
217
- # @option kwargs [Symbol, Boolean] :verify
218
- # Specifies whether to verify the SSL certificate.
219
- # May be one of the following:
220
- #
221
- # * `:none`
222
- # * `:peer`
223
- # * `:fail_if_no_peer_cert`
224
- # * `:client_once`
225
- #
226
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
227
- # The RSA key to use for the SSL context.
228
- #
229
- # @option kwargs [String] :key_file
230
- # The path to the SSL `.key` file.
231
- #
232
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
233
- # The X509 certificate to use for the SSL context.
234
- #
235
- # @option kwargs [String] :cert_file
236
- # The path to the SSL `.crt` file.
237
- #
238
- # @option kwargs [String] :ca_bundle
239
- # Path to the CA certificate file or directory.
165
+ # @!macro connect_kwargs
240
166
  #
241
167
  # @yield [ssl_socket]
242
168
  # The given block will be passed the new SSL socket. Once the block
@@ -260,23 +186,12 @@ module Ronin
260
186
  # end
261
187
  #
262
188
  # @see http://rubydoc.info/stdlib/openssl/OpenSSL/SSL/SSLSocket
189
+ # @see SSL.connect
263
190
  #
264
191
  # @api public
265
192
  #
266
- def ssl_connect(host,port, bind_host: nil, bind_port: nil, **kwargs)
267
- socket = tcp_connect(host,port,bind_host: bind_host,
268
- bind_port: bind_port)
269
- ssl_socket = ssl_socket(socket,**kwargs)
270
-
271
- ssl_socket.hostname = host
272
- ssl_socket.connect
273
-
274
- if block_given?
275
- yield ssl_socket
276
- ssl_socket.close
277
- else
278
- return ssl_socket
279
- end
193
+ def ssl_connect(host,port,**kwargs,&block)
194
+ SSL.connect(host,port,**kwargs,&block)
280
195
  end
281
196
 
282
197
  #
@@ -291,38 +206,10 @@ module Ronin
291
206
  # @param [Integer] port
292
207
  # The port to connect to.
293
208
  #
294
- # @param [String] bind_host
295
- # The local host to bind to.
296
- #
297
- # @param [Integer] bind_port
298
- # The local port to bind to.
299
- #
300
209
  # @param [Hash{Symbol => Object}] kwargs
301
210
  # Additional keyword arguments for {#ssl_connect}.
302
211
  #
303
- # @option kwargs [Symbol, Boolean] :verify
304
- # Specifies whether to verify the SSL certificate.
305
- # May be one of the following:
306
- #
307
- # * `:none`
308
- # * `:peer`
309
- # * `:fail_if_no_peer_cert`
310
- # * `:client_once`
311
- #
312
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
313
- # The RSA key to use for the SSL context.
314
- #
315
- # @option kwargs [String] :key_file
316
- # The path to the SSL `.key` file.
317
- #
318
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
319
- # The X509 certificate to use for the SSL context.
320
- #
321
- # @option kwargs [String] :cert_file
322
- # The path to the SSL `.crt` file.
323
- #
324
- # @option kwargs [String] :ca_bundle
325
- # Path to the CA certificate file or directory.
212
+ # @!macro connect_kwargs
326
213
  #
327
214
  # @yield [ssl_socket]
328
215
  # The given block will be passed the newly created SSL Socket.
@@ -332,18 +219,12 @@ module Ronin
332
219
  #
333
220
  # @api public
334
221
  #
222
+ # @see SSL.connect_and_send
223
+ #
335
224
  # @since 0.6.0
336
225
  #
337
- def ssl_connect_and_send(data,host,port, bind_host: nil,
338
- bind_port: nil,
339
- **kwargs)
340
- socket = ssl_connect(host,port, bind_host: bind_host,
341
- bind_port: bind_port,
342
- **kwargs)
343
- socket.write(data)
344
-
345
- yield socket if block_given?
346
- return socket
226
+ def ssl_connect_and_send(data,host,port,**kwargs,&block)
227
+ SSL.connect_and_send(data,host,port,**kwargs,&block)
347
228
  end
348
229
 
349
230
  #
@@ -356,47 +237,17 @@ module Ronin
356
237
  # The port to connect to.
357
238
  #
358
239
  # @param [Hash{Symbol => Object}] kwargs
359
- # Additional keyword arguments.
360
- #
361
- # @option kwargs [String] :bind_host
362
- # The local host to bind to.
363
- #
364
- # @option kwargs [Integer] :bind_port
365
- # The local port to bind to.
366
- #
367
- # @option kwargs [Symbol, Boolean] :verify
368
- # Specifies whether to verify the SSL certificate.
369
- # May be one of the following:
240
+ # Additional keyword arguments {#ssl_connect}.
370
241
  #
371
- # * `:none`
372
- # * `:peer`
373
- # * `:fail_if_no_peer_cert`
374
- # * `:client_once`
375
- #
376
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
377
- # The RSA key to use for the SSL context.
378
- #
379
- # @option kwargs [String] :key_file
380
- # The path to the SSL `.key` file.
381
- #
382
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
383
- # The X509 certificate to use for the SSL context.
384
- #
385
- # @option kwargs [String] :cert_file
386
- # The path to the SSL `.crt` file.
387
- #
388
- # @option kwargs [String] :ca_bundle
389
- # Path to the CA certificate file or directory.
242
+ # @!macro connect_kwargs
390
243
  #
391
244
  # @return [Crypto::Cert]
392
245
  # The server's certificate.
393
246
  #
247
+ # @see SSL.get_cert
248
+ #
394
249
  def ssl_cert(host,port,**kwargs)
395
- socket = ssl_connect(host,port,**kwargs)
396
- cert = Crypto::Cert(socket.peer_cert)
397
-
398
- socket.close
399
- return cert
250
+ SSL.get_cert(host,port,**kwargs)
400
251
  end
401
252
 
402
253
  #
@@ -409,38 +260,10 @@ module Ronin
409
260
  # @param [Integer] port
410
261
  # The port to connect to.
411
262
  #
412
- # @param [String] bind_host
413
- # The local host to bind to.
414
- #
415
- # @param [Integer] bind_port
416
- # The local port to bind to.
417
- #
418
263
  # @param [Hash{Symbol => Object}] kwargs
419
264
  # Additional keyword arguments for {#ssl_connect}.
420
265
  #
421
- # @option kwargs [Symbol, Boolean] :verify
422
- # Specifies whether to verify the SSL certificate.
423
- # May be one of the following:
424
- #
425
- # * `:none`
426
- # * `:peer`
427
- # * `:fail_if_no_peer_cert`
428
- # * `:client_once`
429
- #
430
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
431
- # The RSA key to use for the SSL context.
432
- #
433
- # @option kwargs [String] :key_file
434
- # The path to the SSL `.key` file.
435
- #
436
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
437
- # The X509 certificate to use for the SSL context.
438
- #
439
- # @option kwargs [String] :cert_file
440
- # The path to the SSL `.crt` file.
441
- #
442
- # @option kwargs [String] :ca_bundle
443
- # Path to the CA certificate file or directory.
266
+ # @!macro connect_kwargs
444
267
  #
445
268
  # @yield [banner]
446
269
  # If a block is given, it will be passed the grabbed banner.
@@ -457,19 +280,12 @@ module Ronin
457
280
  #
458
281
  # @api public
459
282
  #
283
+ # @see SSL.banner
284
+ #
460
285
  # @since 0.6.0
461
286
  #
462
- def ssl_banner(host,port, bind_host: nil, bind_port: nil, **kwargs)
463
- banner = nil
464
-
465
- ssl_connect(host,port, bind_host: bind_host,
466
- bind_port: bind_port,
467
- **kwargs) do |ssl_socket|
468
- banner = ssl_socket.readline.strip
469
- end
470
-
471
- yield banner if block_given?
472
- return banner
287
+ def ssl_banner(host,port,**kwargs,&block)
288
+ SSL.banner(host,port,**kwargs,&block)
473
289
  end
474
290
 
475
291
  #
@@ -485,38 +301,10 @@ module Ronin
485
301
  # @param [Integer] port
486
302
  # The port to connect to.
487
303
  #
488
- # @param [String] bind_host
489
- # The local host to bind to.
490
- #
491
- # @param [Integer] bind_port
492
- # The local port to bind to.
493
- #
494
304
  # @param [Hash{Symbol => Object}] kwargs
495
305
  # Additional keyword arguments for {#ssl_connect}.
496
306
  #
497
- # @option kwargs [Symbol, Boolean] :verify
498
- # Specifies whether to verify the SSL certificate.
499
- # May be one of the following:
500
- #
501
- # * `:none`
502
- # * `:peer`
503
- # * `:fail_if_no_peer_cert`
504
- # * `:client_once`
505
- #
506
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key
507
- # The RSA key to use for the SSL context.
508
- #
509
- # @option kwargs [String] :key_file
510
- # The path to the SSL `.key` file.
511
- #
512
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert
513
- # The X509 certificate to use for the SSL context.
514
- #
515
- # @option kwargs [String] :cert_file
516
- # The path to the SSL `.crt` file.
517
- #
518
- # @option kwargs [String] :ca_bundle
519
- # Path to the CA certificate file or directory.
307
+ # @!macro connect_kwargs
520
308
  #
521
309
  # @return [true]
522
310
  # The data was successfully sent.
@@ -528,102 +316,123 @@ module Ronin
528
316
  #
529
317
  # @api public
530
318
  #
319
+ # @see SSL.send
320
+ #
531
321
  # @since 0.6.0
532
322
  #
533
- def ssl_send(data,host,port, bind_host: nil, bind_port: nil,**kwargs)
534
- ssl_connect(host,port, bind_host: bind_host,
535
- bind_port: bind_port,**kwargs) do |socket|
536
- socket.write(data)
537
- end
538
-
539
- return true
323
+ def ssl_send(data,host,port,**kwargs)
324
+ SSL.send(data,host,port,**kwargs)
540
325
  end
541
326
 
327
+ #
328
+ # @!macro server_context_kwargs
329
+ # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key (SSL.key)
330
+ # The RSA key to use for the SSL context.
331
+ #
332
+ # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert (SSL.cert)
333
+ # The X509 certificate to use for the SSL context.
334
+ #
335
+ # @!macro context_kwargs
336
+ #
337
+
542
338
  #
543
339
  # Accepts an SSL session from an existing TCP socket.
544
340
  #
545
341
  # @param [TCPSocket] socket
546
342
  # The existing TCP socket.
547
343
  #
548
- # @param [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] key
549
- # The RSA key to use for the SSL context.
550
- #
551
- # @param [Crypto::Cert, OpenSSL::X509::Certificate, nil] cert
552
- # The X509 certificate to use for the SSL context.
553
- #
554
344
  # @param [Hash{Symbol => Object}] kwargs
555
345
  # Additional keyword arguments for {#ssl_socket}.
556
346
  #
557
- # @option kwargs [Symbol, Boolean] :verify
558
- # Specifies whether to verify the SSL certificate.
559
- # May be one of the following:
560
- #
561
- # * `:none`
562
- # * `:peer`
563
- # * `:fail_if_no_peer_cert`
564
- # * `:client_once`
565
- #
566
- # @option kwargs [String] :key_file
567
- # The path to the SSL `.key` file.
568
- #
569
- # @option kwargs [String] :cert_file
570
- # The path to the SSL `.crt` file.
571
- #
572
- # @option kwargs [String] :ca_bundle
573
- # Path to the CA certificate file or directory.
347
+ # @!macro server_context_kwargs
574
348
  #
575
349
  # @return [OpenSSL::SSL::SSLSocket]
576
350
  # The new SSL Socket.
577
351
  #
578
352
  # @api public
579
353
  #
354
+ # @see SSL.server_socket
355
+ #
580
356
  # @since 0.6.0
581
357
  #
582
- def ssl_server_socket(socket, key: Network::SSL.key,
583
- cert: Network::SSL.cert,
584
- **kwargs)
585
- return ssl_socket(socket, cert: cert, key: key, **kwargs)
358
+ def ssl_server_socket(socket,**kwargs)
359
+ SSL.server_socket(socket,**kwargs)
586
360
  end
587
361
 
588
362
  #
589
- # Creates a new SSL socket listening on a given host and port,
590
- # accepting clients in a loop.
363
+ # @!macro server_kwargs
364
+ # @option kwargs [Integer] :port (0)
365
+ # The local port to listen on.
591
366
  #
592
- # @param [Integer] port
593
- # The local port to listen on.
367
+ # @option kwargs [String, nil] :host
368
+ # The host to bind to.
594
369
  #
595
- # @param [String] host
596
- # The host to bind to.
370
+ # @option kwargs [Integer] :backlog (5)
371
+ # The maximum backlog of pending connections.
372
+ #
373
+ # @!macro server_context_kwargs
374
+ #
375
+
376
+ #
377
+ # Creates a new SSL server listening on a given host and port.
378
+ #
379
+ # @param [Hash{Symbol => Object}] kwargs
380
+ # Additional keyword arguments for {#ssl_context}.
381
+ #
382
+ # @!macro server_kwargs
383
+ #
384
+ # @yield [server]
385
+ # The given block will be passed the newly created SSL server.
386
+ #
387
+ # @yieldparam [OpenSSL::SSL::SSLServer] server
388
+ # The newly created SSL server.
389
+ #
390
+ # @return [OpenSSL::SSL::SSLServer]
391
+ # The newly created SSL server.
392
+ #
393
+ # @api public
394
+ #
395
+ # @since 1.1.0
597
396
  #
598
- # @param [Integer] backlog (5)
599
- # The maximum backlog of pending connections.
397
+ def ssl_server(**kwargs,&block)
398
+ SSL.server(**kwargs,&block)
399
+ end
400
+
401
+ #
402
+ # Creates a new temporary SSL server listening on a given host and
403
+ # port.
600
404
  #
601
405
  # @param [Hash{Symbol => Object}] kwargs
602
- # Additional keyword arguments for {#ssl_server_socket}.
406
+ # Additional keyword arguments for {#ssl_context}.
603
407
  #
604
- # @option kwargs [Symbol, Boolean] :verify
605
- # Specifies whether to verify the SSL certificate.
606
- # May be one of the following:
408
+ # @!macro server_kwargs
607
409
  #
608
- # * `:none`
609
- # * `:peer`
610
- # * `:fail_if_no_peer_cert`
611
- # * `:client_once`
410
+ # @yield [server]
411
+ # The given block will be passed the newly created SSL server.
412
+ # Once the block has finished, the server will be closed.
612
413
  #
613
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key (Network::SSL.key)
614
- # The RSA key to use for the SSL context.
414
+ # @yieldparam [OpenSSL::SSL::SSLServer] server
415
+ # The newly created SSL server.
615
416
  #
616
- # @option kwargs [String] :key_file
617
- # The path to the SSL `.key` file.
417
+ # @return [OpenSSL::SSL::SSLServer]
418
+ # The newly created SSL server.
419
+ #
420
+ # @api public
421
+ #
422
+ # @since 1.1.0
423
+ #
424
+ def ssl_server_session(**kwargs,&block)
425
+ SSL.server_session(**kwargs,&block)
426
+ end
427
+
618
428
  #
619
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert (Network::SSL.cert)
620
- # The X509 certificate to use for the SSL context.
429
+ # Creates a new SSL socket listening on a given host and port,
430
+ # accepting clients in a loop.
621
431
  #
622
- # @option kwargs [String] :cert_file
623
- # The path to the SSL `.crt` file.
432
+ # @param [Hash{Symbol => Object}] kwargs
433
+ # Additional keyword arguments for {#ssl_context}.
624
434
  #
625
- # @option kwargs [String] :ca_bundle
626
- # Path to the CA certificate file or directory.
435
+ # @!macro server_kwargs
627
436
  #
628
437
  # @yield [client]
629
438
  # The given block will be passed the newly connected client.
@@ -645,62 +454,22 @@ module Ronin
645
454
  #
646
455
  # @api public
647
456
  #
457
+ # @see SSL.server_loop
458
+ #
648
459
  # @since 0.6.0
649
460
  #
650
- def ssl_server_loop(port: nil, host: nil, backlog: 5, **kwargs)
651
- return tcp_server_session(port: port, host: host, backlog: backlog) do |server|
652
- loop do
653
- client = server.accept
654
- ssl_client = ssl_server_socket(client,**kwargs)
655
- ssl_client.accept
656
-
657
- yield ssl_client if block_given?
658
- ssl_client.close
659
- end
660
- end
461
+ def ssl_server_loop(**kwargs,&block)
462
+ SSL.server_loop(**kwargs,&block)
661
463
  end
662
464
 
663
465
  #
664
466
  # Creates a new SSL socket listening on a given host and port,
665
467
  # accepts only one client and then stops listening.
666
468
  #
667
- # @param [Integer] port
668
- # The local port to listen on.
669
- #
670
- # @param [String] host
671
- # The host to bind to.
672
- #
673
469
  # @param [Hash{Symbol => Object}] kwargs
674
- # Additional keyword arguments for {#ssl_server_socket}.
675
- #
676
- # @option kwargs [Symbol, Boolean] :verify
677
- # Specifies whether to verify the SSL certificate.
678
- # May be one of the following:
679
- #
680
- # * `:none`
681
- # * `:peer`
682
- # * `:fail_if_no_peer_cert`
683
- # * `:client_once`
684
- #
685
- # @option kwargs [Crypto::Key::RSA, OpenSSL::PKey::RSA, nil] :key (Network::SSL.key)
686
- # The RSA key to use for the SSL context.
687
- #
688
- # @option kwargs [String] :key_file
689
- # The path to the SSL `.key` file.
690
- #
691
- # @option kwargs [Crypto::Cert, OpenSSL::X509::Certificate, nil] :cert (Network::SSL.cert)
692
- # The X509 certificate to use for the SSL context.
693
- #
694
- # @option kwargs [String] :cert_file
695
- # The path to the SSL `.crt` file.
470
+ # Additional keyword arguments for {#ssl_context}.
696
471
  #
697
- # @option kwargs [String] :ca_bundle
698
- # Path to the CA certificate file or directory.
699
- #
700
- # @example
701
- # ssl_accept(1337) do |client|
702
- # client.puts 'lol'
703
- # end
472
+ # @!macro server_kwargs
704
473
  #
705
474
  # @yield [client]
706
475
  # The given block will be passed the newly connected client.
@@ -713,6 +482,11 @@ module Ronin
713
482
  # @return [nil]
714
483
  #
715
484
  # @example
485
+ # ssl_accept(1337) do |client|
486
+ # client.puts 'lol'
487
+ # end
488
+ #
489
+ # @example Using a self-signed certificate:
716
490
  # # $ openssl genrsa -out ssl.key 1024
717
491
  # # $ openssl req -new -key ssl.key -x509 -days 3653 -out ssl.crt
718
492
  # # $ cat ssl.key ssl.crt > ssl.pem
@@ -723,17 +497,12 @@ module Ronin
723
497
  #
724
498
  # @api public
725
499
  #
500
+ # @see SSL.accept
501
+ #
726
502
  # @since 0.6.0
727
503
  #
728
- def ssl_accept(port: nil, host: nil,**kwargs)
729
- tcp_server_session(port: port, host: host, backlog: 1) do |server|
730
- client = server.accept
731
- ssl_client = ssl_server_socket(client,options)
732
- ssl_client.accept
733
-
734
- yield ssl_client if block_given?
735
- ssl_client.close
736
- end
504
+ def ssl_accept(**kwargs,&block)
505
+ SSL.accept(**kwargs,&block)
737
506
  end
738
507
  end
739
508
  end