ronin-support 1.0.6 → 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 +111 -0
  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 +1 -1
  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
@@ -55,6 +55,55 @@ module Ronin
55
55
 
56
56
  include Enumerable
57
57
 
58
+ ipv4_octet = /(?:\d{1,2}|1\d{2}|2[1-4]\d|25[0-5])/
59
+ ipv4_octet_range = /#{ipv4_octet}(?:-#{ipv4_octet})?/
60
+ ipv4_octet_list = /(?:#{ipv4_octet_range}(?:,#{ipv4_octet_range})*|\*)/
61
+ ipv4_addr = /#{ipv4_octet_list}(?:\.#{ipv4_octet_list}){3}/
62
+
63
+ # Regular expression that matches IPv4-glob ranges.
64
+ #
65
+ # @api private
66
+ #
67
+ # @since 1.1.0
68
+ IPV4_REGEX = /\A#{ipv4_addr}\z/
69
+
70
+ ipv6_octet = /[0-9a-fA-F]{1,4}/
71
+ ipv6_octet_range = /#{ipv6_octet}(?:-#{ipv6_octet})?/
72
+ ipv6_octet_list = /(?:#{ipv6_octet_range}(?:,#{ipv6_octet_range})*|\*)/
73
+
74
+ # Regular expression that matches IPv6-glob ranges.
75
+ #
76
+ # @api private
77
+ #
78
+ # @since 1.1.0
79
+ IPV6_REGEX = /\A(?:
80
+ (?:#{ipv6_octet_list}:){6}#{ipv4_addr}|
81
+ (?:#{ipv6_octet_list}:){5}#{ipv6_octet_list}:#{ipv4_addr}|
82
+ (?:#{ipv6_octet_list}:){5}:#{ipv6_octet_list}:#{ipv4_addr}|
83
+ (?:#{ipv6_octet_list}:){1,1}(?::#{ipv6_octet_list}){1,4}:#{ipv4_addr}|
84
+ (?:#{ipv6_octet_list}:){1,2}(?::#{ipv6_octet_list}){1,3}:#{ipv4_addr}|
85
+ (?:#{ipv6_octet_list}:){1,3}(?::#{ipv6_octet_list}){1,2}:#{ipv4_addr}|
86
+ (?:#{ipv6_octet_list}:){1,4}(?::#{ipv6_octet_list}){1,1}:#{ipv4_addr}|
87
+ :(?::#{ipv6_octet_list}){1,5}:#{ipv4_addr}|
88
+ (?:(?:#{ipv6_octet_list}:){1,5}|:):#{ipv4_addr}|
89
+ (?:#{ipv6_octet_list}:){1,1}(?::#{ipv6_octet_list}){1,6}|
90
+ (?:#{ipv6_octet_list}:){1,2}(?::#{ipv6_octet_list}){1,5}|
91
+ (?:#{ipv6_octet_list}:){1,3}(?::#{ipv6_octet_list}){1,4}|
92
+ (?:#{ipv6_octet_list}:){1,4}(?::#{ipv6_octet_list}){1,3}|
93
+ (?:#{ipv6_octet_list}:){1,5}(?::#{ipv6_octet_list}){1,2}|
94
+ (?:#{ipv6_octet_list}:){1,6}(?::#{ipv6_octet_list}){1,1}|
95
+ #{ipv6_octet_list}(?::#{ipv6_octet_list}){7}|
96
+ :(?::#{ipv6_octet_list}){1,7}|
97
+ (?:(?:#{ipv6_octet_list}:){1,7}|:):
98
+ )\z/x
99
+
100
+ # Regular expression to match IP-glob ranges.
101
+ #
102
+ # @api private
103
+ #
104
+ # @since 1.1.0
105
+ REGEX = /#{IPV4_REGEX}|#{IPV6_REGEX}/
106
+
58
107
  # The IP glob string.
59
108
  #
60
109
  # @return [String]
@@ -66,26 +115,32 @@ module Ronin
66
115
  # @param [String] string
67
116
  # The IP-glob string to parse.
68
117
  #
118
+ # @raise [ArgumentError]
119
+ # The IP-glob string was neither a valid IPv4 or IPv6 glob address.
120
+ #
69
121
  def initialize(string)
70
122
  @string = string
71
123
 
72
- if @string.include?(':') # IPv6
73
- @version = 6
74
- @base = 16
75
- @formatter = method(:format_ipv6_address)
76
-
77
- separator = ':'
78
- octet_range = (0..0xffff)
79
- else # IPv4
124
+ case string
125
+ when IPV4_REGEX
80
126
  @version = 4
81
127
  @base = 10
82
128
  @formatter = method(:format_ipv4_address)
83
129
 
84
130
  separator = '.'
85
131
  octet_range = (0..255)
132
+ when IPV6_REGEX
133
+ @version = 6
134
+ @base = 16
135
+ @formatter = method(:format_ipv6_address)
136
+
137
+ separator = ':'
138
+ octet_range = (0..0xffff)
139
+ else
140
+ raise(ArgumentError,"invalid IP-glob range: #{string.inspect}")
86
141
  end
87
142
 
88
- @ranges = @string.split(separator).map do |segment|
143
+ @ranges = string.split(separator).map do |segment|
89
144
  if segment == '*' then octet_range
90
145
  elsif segment.include?(',') then parse_list(segment)
91
146
  elsif segment.include?('-') then parse_range(segment)
@@ -169,6 +224,54 @@ module Ronin
169
224
  @version == 6
170
225
  end
171
226
 
227
+ #
228
+ # Determines whether the IP address exists within the IP range.
229
+ #
230
+ # @param [IP, IPAddr, String] ip
231
+ # The IP address to check.
232
+ #
233
+ # @return [Boolean]
234
+ # Indicates whether the IP address exists within the IP range.
235
+ #
236
+ # @since 1.1.0
237
+ #
238
+ def include?(ip)
239
+ super(ip.to_s)
240
+ end
241
+
242
+ #
243
+ # Compares the IP glob range to another IP range.
244
+ #
245
+ # @param [Object] other
246
+ # The other IP range.
247
+ #
248
+ # @return [Boolean]
249
+ #
250
+ # @since 1.1.0
251
+ #
252
+ def ==(other)
253
+ other.kind_of?(self.class) && @string == other.string
254
+ end
255
+
256
+ #
257
+ # Determines if the given IP range is a sub-set of the IP CIDR range.
258
+ #
259
+ # @param [Glob, CIDR, Enumerable<String>] other
260
+ # The other IP range.
261
+ #
262
+ # @return [Boolean]
263
+ #
264
+ # @since 1.1.0
265
+ #
266
+ def ===(other)
267
+ case other
268
+ when Enumerable
269
+ other.all? { |ip| include?(ip) }
270
+ else
271
+ false
272
+ end
273
+ end
274
+
172
275
  #
173
276
  # Enumerates over the IP-glob range.
174
277
  #
@@ -217,6 +320,43 @@ module Ronin
217
320
  return self
218
321
  end
219
322
 
323
+ #
324
+ # The first address in the IP glob range.
325
+ #
326
+ # @return [String]
327
+ # The first IP address in the IP glob range.
328
+ #
329
+ # @since 1.1.0
330
+ #
331
+ def first
332
+ @formatter.call(@ranges.map(&:first))
333
+ end
334
+
335
+ #
336
+ # The last address in the IP glob range.
337
+ #
338
+ # @return [String]
339
+ # The last IP address in the IP glob range.
340
+ #
341
+ # @since 1.1.0
342
+ #
343
+ def last
344
+ @formatter.call(@ranges.map(&:last))
345
+ end
346
+
347
+ #
348
+ # Calculates the size of the IP glob range.
349
+ #
350
+ # @return [Integer]
351
+ #
352
+ # @since 1.1.0
353
+ #
354
+ def size
355
+ @ranges.reduce(1) do |total,parts|
356
+ total * parts.size
357
+ end
358
+ end
359
+
220
360
  #
221
361
  # Converts the IP-glob range back into a String.
222
362
  #
@@ -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
@@ -145,7 +145,7 @@ module Ronin
145
145
  #
146
146
  # Determines if the given IP belongs to the ASN IP range.
147
147
  #
148
- # @param [IPAddr, String] ip
148
+ # @param [IP, IPAddr, String] ip
149
149
  # The IP to test.
150
150
  #
151
151
  # @return [Boolean]
@@ -207,6 +207,38 @@ module Ronin
207
207
  self.end == other.end
208
208
  end
209
209
 
210
+ #
211
+ # Determines if the given IP range is a sub-set of the IP range.
212
+ #
213
+ # @param [IPRange::Range, CIDR, Glob, Enumerable<String>] other
214
+ # The other IP range.
215
+ #
216
+ # @return [Boolean]
217
+ #
218
+ # @since 1.1.0
219
+ #
220
+ def ===(other)
221
+ case other
222
+ when IPRange::Range
223
+ self.begin <= other.begin && self.end >= other.end
224
+ when Enumerable
225
+ other.all? { |ip| include?(ip) }
226
+ else
227
+ false
228
+ end
229
+ end
230
+
231
+ #
232
+ # Calculates the size of the IP range.
233
+ #
234
+ # @return [Integer]
235
+ #
236
+ # @since 1.1.0
237
+ #
238
+ def size
239
+ (@end_uint - @begin_uint) + 1
240
+ end
241
+
210
242
  #
211
243
  # Converts the IP range to a String.
212
244
  #
@@ -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
@@ -65,6 +65,22 @@ module Ronin
65
65
  #
66
66
  class IPRange
67
67
 
68
+ # Regular expression to match CIDR ranges or IP-glob ranges.
69
+ #
70
+ # @api private
71
+ #
72
+ # @since 1.1.0
73
+ REGEX = /#{CIDR::REGEX}|#{Glob::REGEX}/
74
+
75
+ # The parsed IP range.
76
+ #
77
+ # @return [CIDR, Glob]
78
+ #
79
+ # @api private
80
+ #
81
+ # @since 1.1.0
82
+ attr_reader :range
83
+
68
84
  #
69
85
  # Initializes the IP range.
70
86
  #
@@ -77,9 +93,15 @@ module Ronin
77
93
  # @example Initializing an IP-glob range:
78
94
  # ip_range = IPRange.new('10.0.1-3.*')
79
95
  #
96
+ # @raise [ArgumentError]
97
+ # The IP range was neither a CIDR range or a IP-glob range.
98
+ #
80
99
  def initialize(string)
81
- @range = if self.class.glob?(string) then Glob.new(string)
82
- else CIDR.new(string)
100
+ @range = case string
101
+ when CIDR::REGEX then CIDR.new(string)
102
+ when Glob::REGEX then Glob.new(string)
103
+ else
104
+ raise(ArgumentError,"invalid IP range: #{string.inspect}")
83
105
  end
84
106
  end
85
107
 
@@ -160,7 +182,7 @@ module Ronin
160
182
  # Indicates that the IP range is a CIDR range.
161
183
  #
162
184
  def self.cidr?(string)
163
- !glob?(string)
185
+ string =~ CIDR::REGEX
164
186
  end
165
187
 
166
188
  #
@@ -173,7 +195,7 @@ module Ronin
173
195
  # Indicates that the IP range is a IP-glob range.
174
196
  #
175
197
  def self.glob?(string)
176
- string.include?('*') || string.include?(',') || string.include?('-')
198
+ string =~ Glob::REGEX
177
199
  end
178
200
 
179
201
  #
@@ -212,6 +234,57 @@ module Ronin
212
234
  @range.ipv6?
213
235
  end
214
236
 
237
+ #
238
+ # Determines whether the IP address exists within the IP range.
239
+ #
240
+ # @param [IP, IPAddr, String] ip
241
+ # The IP address to check.
242
+ #
243
+ # @return [Boolean]
244
+ # Indicates whether the IP address exists within the IP range.
245
+ #
246
+ # @since 1.1.0
247
+ #
248
+ def include?(ip)
249
+ @range.include?(ip)
250
+ end
251
+
252
+ #
253
+ # Compares the IP range to another IP range.
254
+ #
255
+ # @param [Object] other
256
+ # The other IP range.
257
+ #
258
+ # @return [Boolean]
259
+ #
260
+ # @since 1.1.0
261
+ #
262
+ def ==(other)
263
+ other.kind_of?(self.class) && @range == other.range
264
+ end
265
+
266
+ #
267
+ # Determines if the given IP range is a sub-set of the IP range.
268
+ #
269
+ # @param [IPRange, Enumerable<String>] other
270
+ # The other IP range.
271
+ #
272
+ # @return [Boolean]
273
+ #
274
+ # @see CIDR#===
275
+ # @see Glob#===
276
+ #
277
+ # @since 1.1.0
278
+ #
279
+ def ===(other)
280
+ case other
281
+ when IPRange
282
+ @range === other.range
283
+ else
284
+ @range === other
285
+ end
286
+ end
287
+
215
288
  #
216
289
  # Enumerates over each IP address that is included in the addresses
217
290
  # netmask. Supports both IPv4 and IPv6 addresses.
@@ -264,6 +337,48 @@ module Ronin
264
337
  @range.each(&block)
265
338
  end
266
339
 
340
+ #
341
+ # The first IP address in the IP range.
342
+ #
343
+ # @return [String]
344
+ #
345
+ # @see CIDR#first
346
+ # @see Glob#last
347
+ #
348
+ # @since 1.1.0
349
+ #
350
+ def first
351
+ @range.first
352
+ end
353
+
354
+ #
355
+ # The last IP address in the IP range.
356
+ #
357
+ # @return [String]
358
+ #
359
+ # @see CIDR#first
360
+ # @see Glob#last
361
+ #
362
+ # @since 1.1.0
363
+ #
364
+ def last
365
+ @range.last
366
+ end
367
+
368
+ #
369
+ # Calculates the size of the IP range.
370
+ #
371
+ # @return [Integer]
372
+ #
373
+ # @see CIDR#size
374
+ # @see Glob#size
375
+ #
376
+ # @since 1.1.0
377
+ #
378
+ def size
379
+ @range.size
380
+ end
381
+
267
382
  #
268
383
  # Converts the IP range back to a String.
269
384
  #
@@ -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
@@ -23,11 +23,6 @@ require 'ronin/support/network/udp/mixin'
23
23
  require 'ronin/support/network/ssl/mixin'
24
24
  require 'ronin/support/network/unix/mixin'
25
25
  require 'ronin/support/network/http/mixin'
26
- require 'ronin/support/network/ftp/mixin'
27
- require 'ronin/support/network/smtp/mixin'
28
- require 'ronin/support/network/esmtp/mixin'
29
- require 'ronin/support/network/pop3/mixin'
30
- require 'ronin/support/network/imap/mixin'
31
26
 
32
27
  module Ronin
33
28
  module Support
@@ -47,11 +42,6 @@ module Ronin
47
42
  include SSL::Mixin
48
43
  include UNIX::Mixin
49
44
  include HTTP::Mixin
50
- include FTP::Mixin
51
- include SMTP::Mixin
52
- include ESMTP::Mixin
53
- include POP3::Mixin
54
- include IMAP::Mixin
55
45
  end
56
46
  end
57
47
  end
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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