ronin-support 0.5.2 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -6
- data/.gitignore +7 -6
- data/.mailmap +1 -0
- data/.ruby-version +1 -1
- data/.yardopts +0 -1
- data/ChangeLog.md +518 -148
- data/Gemfile +17 -16
- data/README.md +107 -52
- data/Rakefile +28 -8
- data/data/text/homoglyphs/ascii.txt +8 -0
- data/data/text/homoglyphs/cyrillic.txt +33 -0
- data/data/text/homoglyphs/full_width.txt +81 -0
- data/data/text/homoglyphs/greek.txt +21 -0
- data/data/text/homoglyphs/latin_numbers.txt +14 -0
- data/data/text/homoglyphs/punctuation.txt +7 -0
- data/data/text/patterns/network/public_suffix.rb.erb +44 -0
- data/examples/ssl_proxy.rb +38 -0
- data/examples/tcp_proxy.rb +41 -0
- data/gemspec.yml +16 -15
- data/lib/ronin/support/archive/core_ext/file.rb +118 -0
- data/lib/ronin/{formatting/sql.rb → support/archive/core_ext.rb} +3 -4
- data/lib/ronin/support/archive/mixin.rb +213 -0
- data/lib/ronin/support/archive/tar/reader.rb +135 -0
- data/lib/ronin/support/archive/tar/writer.rb +197 -0
- data/lib/ronin/support/archive/tar.rb +155 -0
- data/lib/ronin/support/archive/zip/reader/entry.rb +134 -0
- data/lib/ronin/support/archive/zip/reader/statistics.rb +76 -0
- data/lib/ronin/support/archive/zip/reader.rb +273 -0
- data/lib/ronin/support/archive/zip/writer.rb +175 -0
- data/lib/ronin/support/archive/zip.rb +105 -0
- data/lib/ronin/support/archive.rb +211 -0
- data/lib/ronin/support/binary/array.rb +255 -0
- data/lib/ronin/support/binary/bit_flip.rb +147 -0
- data/lib/ronin/support/binary/buffer.rb +2027 -0
- data/lib/ronin/support/binary/byte_slice.rb +324 -0
- data/lib/ronin/{formatting/extensions/binary → support/binary/core_ext}/array.rb +25 -11
- data/lib/ronin/support/binary/core_ext/float.rb +80 -0
- data/lib/ronin/support/binary/core_ext/integer.rb +305 -0
- data/lib/ronin/support/binary/core_ext/io.rb +38 -0
- data/lib/ronin/support/binary/core_ext/string.rb +162 -0
- data/lib/ronin/{formatting/extensions/text.rb → support/binary/core_ext.rb} +6 -6
- data/lib/ronin/support/binary/cstring.rb +259 -0
- data/lib/ronin/support/binary/ctypes/aggregate_type.rb +98 -0
- data/lib/ronin/support/binary/ctypes/arch/arm/big_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/arm.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64/big_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/arm64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/mips/little_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/mips.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64/little_endian.rb +77 -0
- data/lib/ronin/support/binary/ctypes/arch/mips64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/ppc64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/x86.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch/x86_64.rb +75 -0
- data/lib/ronin/support/binary/ctypes/arch.rb +30 -0
- data/lib/ronin/support/binary/ctypes/array_object_type.rb +164 -0
- data/lib/ronin/support/binary/ctypes/array_type.rb +232 -0
- data/lib/ronin/support/binary/ctypes/big_endian.rb +195 -0
- data/lib/ronin/support/binary/ctypes/char_type.rb +59 -0
- data/lib/ronin/support/binary/ctypes/char_types.rb +39 -0
- data/lib/ronin/support/binary/ctypes/enum_type.rb +181 -0
- data/lib/ronin/support/binary/ctypes/float32_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/float64_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/float_type.rb +62 -0
- data/lib/ronin/support/binary/ctypes/int16_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/int32_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/int64_type.rb +50 -0
- data/lib/ronin/support/{support.rb → binary/ctypes/int8_type.rb} +20 -21
- data/lib/ronin/support/binary/ctypes/int_type.rb +62 -0
- data/lib/ronin/support/binary/ctypes/little_endian.rb +195 -0
- data/lib/ronin/support/binary/ctypes/mixin.rb +135 -0
- data/lib/ronin/support/binary/ctypes/native.rb +205 -0
- data/lib/ronin/support/binary/ctypes/network.rb +29 -0
- data/lib/ronin/support/binary/ctypes/object_type.rb +55 -0
- data/lib/ronin/support/binary/ctypes/os/bsd.rb +65 -0
- data/lib/ronin/support/binary/ctypes/os/freebsd.rb +215 -0
- data/lib/ronin/support/binary/ctypes/os/linux.rb +193 -0
- data/lib/ronin/support/binary/ctypes/os/macos.rb +151 -0
- data/lib/ronin/support/binary/ctypes/os/netbsd.rb +147 -0
- data/lib/ronin/support/binary/ctypes/os/openbsd.rb +168 -0
- data/lib/ronin/support/binary/ctypes/os/unix.rb +78 -0
- data/lib/ronin/support/binary/ctypes/os/windows.rb +125 -0
- data/lib/ronin/support/binary/ctypes/os.rb +125 -0
- data/lib/ronin/support/binary/ctypes/scalar_type.rb +200 -0
- data/lib/ronin/support/binary/ctypes/string_type.rb +143 -0
- data/lib/ronin/support/binary/ctypes/struct_object_type.rb +173 -0
- data/lib/ronin/support/binary/ctypes/struct_type.rb +359 -0
- data/lib/ronin/support/binary/ctypes/type.rb +193 -0
- data/lib/ronin/support/binary/ctypes/type_resolver.rb +206 -0
- data/lib/ronin/support/binary/ctypes/uint16_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/uint32_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/uint64_type.rb +50 -0
- data/lib/ronin/support/binary/ctypes/uint8_type.rb +41 -0
- data/lib/ronin/support/binary/ctypes/uint_type.rb +59 -0
- data/lib/ronin/support/binary/ctypes/unbounded_array_type.rb +258 -0
- data/lib/ronin/support/binary/ctypes/union_object_type.rb +173 -0
- data/lib/ronin/support/binary/ctypes/union_type.rb +261 -0
- data/lib/ronin/support/binary/ctypes.rb +462 -0
- data/lib/ronin/support/binary/hexdump/core_ext/file.rb +118 -0
- data/lib/ronin/support/binary/hexdump/core_ext/string.rb +115 -0
- data/lib/ronin/support/binary/hexdump/core_ext.rb +20 -0
- data/lib/ronin/support/binary/hexdump/parser.rb +492 -0
- data/lib/ronin/support/binary/hexdump.rb +20 -0
- data/lib/ronin/support/binary/memory.rb +268 -0
- data/lib/ronin/support/binary/packet.rb +33 -0
- data/lib/ronin/support/binary/stack.rb +256 -0
- data/lib/ronin/support/binary/stream/methods.rb +1755 -0
- data/lib/ronin/support/binary/stream.rb +151 -0
- data/lib/ronin/support/binary/struct/member.rb +86 -0
- data/lib/ronin/support/binary/struct.rb +830 -0
- data/lib/ronin/support/binary/template.rb +284 -0
- data/lib/ronin/support/binary/union.rb +162 -0
- data/lib/ronin/{formatting/extensions → support}/binary.rb +10 -10
- data/lib/ronin/support/cli/ansi.rb +330 -0
- data/lib/ronin/support/cli/io_shell/core_ext/io.rb +67 -0
- data/lib/ronin/{extensions/meta.rb → support/cli/io_shell/core_ext.rb} +3 -4
- data/lib/ronin/support/cli/io_shell.rb +161 -0
- data/lib/ronin/support/cli/printing.rb +216 -0
- data/lib/ronin/support/cli.rb +20 -0
- data/lib/ronin/support/compression/core_ext/file.rb +70 -0
- data/lib/ronin/support/compression/core_ext/string.rb +101 -0
- data/lib/ronin/{fuzzing/extensions.rb → support/compression/core_ext.rb} +3 -4
- data/lib/ronin/support/compression/gzip/reader.rb +70 -0
- data/lib/ronin/support/compression/gzip/writer.rb +74 -0
- data/lib/ronin/support/compression/gzip.rb +105 -0
- data/lib/ronin/support/compression/mixin.rb +180 -0
- data/lib/ronin/{network/extensions/esmtp/net.rb → support/compression/zlib.rb} +6 -7
- data/lib/ronin/support/compression.rb +174 -0
- data/lib/ronin/{extensions → support/core_ext}/enumerable.rb +2 -3
- data/lib/ronin/{extensions → support/core_ext}/file.rb +2 -31
- data/lib/ronin/support/core_ext/integer.rb +37 -0
- data/lib/ronin/support/core_ext/ipaddr.rb +65 -0
- data/lib/ronin/{extensions → support/core_ext}/kernel.rb +7 -6
- data/lib/ronin/{extensions → support/core_ext}/resolv.rb +2 -25
- data/lib/ronin/{extensions → support/core_ext}/string.rb +114 -54
- data/lib/ronin/support/core_ext.rb +34 -0
- data/lib/ronin/support/crypto/cert.rb +522 -0
- data/lib/ronin/support/crypto/cert_chain.rb +204 -0
- data/lib/ronin/support/crypto/cipher/aes.rb +71 -0
- data/lib/ronin/support/crypto/cipher/aes128.rb +54 -0
- data/lib/ronin/support/crypto/cipher/aes256.rb +54 -0
- data/lib/ronin/support/crypto/cipher.rb +194 -0
- data/lib/ronin/support/crypto/core_ext/file.rb +660 -0
- data/lib/ronin/support/crypto/core_ext/string.rb +548 -0
- data/lib/ronin/{binary.rb → support/crypto/core_ext.rb} +4 -5
- data/lib/ronin/{network/mixins/mixin.rb → support/crypto/hmac.rb} +18 -28
- data/lib/ronin/support/crypto/key/dh.rb +122 -0
- data/lib/ronin/support/crypto/key/dsa.rb +103 -0
- data/lib/ronin/support/crypto/key/ec.rb +99 -0
- data/lib/ronin/support/crypto/key/methods.rb +163 -0
- data/lib/ronin/support/crypto/key/rsa.rb +169 -0
- data/lib/ronin/support/crypto/key.rb +105 -0
- data/lib/ronin/support/crypto/mixin.rb +620 -0
- data/lib/ronin/{network/extensions/http/net.rb → support/crypto/openssl.rb} +6 -7
- data/lib/ronin/support/crypto.rb +779 -0
- data/lib/ronin/support/encoding/base16/core_ext/string.rb +63 -0
- data/lib/ronin/{formatting/binary.rb → support/encoding/base16/core_ext.rb} +3 -4
- data/lib/ronin/support/encoding/base16.rb +82 -0
- data/lib/ronin/support/encoding/base32/core_ext/string.rb +63 -0
- data/lib/ronin/support/encoding/base32/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/base32.rb +164 -0
- data/lib/ronin/support/encoding/base64/core_ext/string.rb +76 -0
- data/lib/ronin/support/encoding/base64/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/base64.rb +78 -0
- data/lib/ronin/support/encoding/c/core_ext/integer.rb +82 -0
- data/lib/ronin/support/encoding/c/core_ext/string.rb +125 -0
- data/lib/ronin/support/encoding/c/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/c.rb +277 -0
- data/lib/ronin/support/encoding/core_ext/string.rb +107 -0
- data/lib/ronin/support/encoding/core_ext.rb +33 -0
- data/lib/ronin/support/encoding/hex/core_ext/integer.rb +82 -0
- data/lib/ronin/support/encoding/hex/core_ext/string.rb +133 -0
- data/lib/ronin/support/encoding/hex/core_ext.rb +22 -0
- data/lib/ronin/support/encoding/hex.rb +248 -0
- data/lib/ronin/support/encoding/html/core_ext/integer.rb +106 -0
- data/lib/ronin/support/encoding/html/core_ext/string.rb +130 -0
- data/lib/ronin/support/encoding/html/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/html.rb +233 -0
- data/lib/ronin/support/encoding/http/core_ext/integer.rb +95 -0
- data/lib/ronin/support/encoding/http/core_ext/string.rb +129 -0
- data/lib/ronin/support/encoding/http/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/http.rb +241 -0
- data/lib/ronin/support/encoding/js/core_ext/integer.rb +67 -0
- data/lib/ronin/support/encoding/js/core_ext/string.rb +125 -0
- data/lib/ronin/support/encoding/js/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/js.rb +279 -0
- data/lib/ronin/support/encoding/powershell/core_ext/integer.rb +87 -0
- data/lib/ronin/support/encoding/powershell/core_ext/string.rb +145 -0
- data/lib/ronin/support/encoding/powershell/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/powershell.rb +297 -0
- data/lib/ronin/{formatting/extensions/http/integer.rb → support/encoding/punycode/core_ext/string.rb} +23 -29
- data/lib/ronin/support/encoding/punycode/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/punycode.rb +76 -0
- data/lib/ronin/support/encoding/quoted_printable/core_ext/string.rb +75 -0
- data/lib/ronin/support/encoding/quoted_printable/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/quoted_printable.rb +102 -0
- data/lib/ronin/support/encoding/ruby/core_ext/string.rb +129 -0
- data/lib/ronin/support/encoding/ruby/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/ruby.rb +235 -0
- data/lib/ronin/support/encoding/shell/core_ext/integer.rb +89 -0
- data/lib/ronin/support/encoding/shell/core_ext/string.rb +134 -0
- data/lib/ronin/support/encoding/shell/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/shell.rb +293 -0
- data/lib/ronin/{network/extensions → support/encoding}/smtp.rb +4 -4
- data/lib/ronin/support/encoding/sql/core_ext/string.rb +114 -0
- data/lib/ronin/{formatting/html.rb → support/encoding/sql/core_ext.rb} +3 -4
- data/lib/ronin/support/encoding/sql.rb +124 -0
- data/lib/ronin/support/encoding/uri/core_ext/integer.rb +149 -0
- data/lib/ronin/support/encoding/uri/core_ext/string.rb +195 -0
- data/lib/ronin/support/encoding/uri/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/uri.rb +424 -0
- data/lib/ronin/support/encoding/uuencoding/core_ext/string.rb +73 -0
- data/lib/ronin/support/encoding/uuencoding/core_ext.rb +19 -0
- data/lib/ronin/support/encoding/uuencoding.rb +70 -0
- data/lib/ronin/support/encoding/xml/core_ext/integer.rb +100 -0
- data/lib/ronin/support/encoding/xml/core_ext/string.rb +124 -0
- data/lib/ronin/support/encoding/xml/core_ext.rb +20 -0
- data/lib/ronin/support/encoding/xml.rb +328 -0
- data/lib/ronin/support/encoding.rb +46 -0
- data/lib/ronin/support/home.rb +88 -0
- data/lib/ronin/{network/network.rb → support/mixin.rb} +17 -20
- data/lib/ronin/support/network/asn/dns_record.rb +112 -0
- data/lib/ronin/support/network/asn/list.rb +269 -0
- data/lib/ronin/support/network/asn/record.rb +164 -0
- data/lib/ronin/support/network/asn/record_set.rb +226 -0
- data/lib/ronin/support/network/asn.rb +88 -0
- data/lib/ronin/{binary/hexdump.rb → support/network/core_ext.rb} +3 -4
- data/lib/ronin/support/network/dns/idn.rb +38 -0
- data/lib/ronin/support/network/dns/mixin.rb +941 -0
- data/lib/ronin/support/network/dns/resolver.rb +707 -0
- data/lib/ronin/support/network/dns.rb +1109 -0
- data/lib/ronin/support/network/domain.rb +70 -0
- data/lib/ronin/support/network/email_address.rb +574 -0
- data/lib/ronin/support/network/esmtp/mixin.rb +115 -0
- data/lib/ronin/support/network/exceptions.rb +43 -0
- data/lib/ronin/support/network/ftp/mixin.rb +106 -0
- data/lib/ronin/support/network/host.rb +1473 -0
- data/lib/ronin/support/network/http/cookie.rb +245 -0
- data/lib/ronin/support/network/http/core_ext/uri/http.rb +63 -0
- data/lib/ronin/support/network/http/core_ext.rb +19 -0
- data/lib/ronin/support/network/http/mixin.rb +890 -0
- data/lib/ronin/support/network/http/request.rb +215 -0
- data/lib/ronin/support/network/http/set_cookie.rb +210 -0
- data/lib/ronin/support/network/http/user_agents.rb +115 -0
- data/lib/ronin/support/network/http.rb +2582 -0
- data/lib/ronin/support/network/imap/mixin.rb +133 -0
- data/lib/ronin/support/network/ip/mixin.rb +114 -0
- data/lib/ronin/support/network/ip.rb +540 -0
- data/lib/ronin/support/network/ip_range/cidr.rb +252 -0
- data/lib/ronin/support/network/ip_range/glob.rb +309 -0
- data/lib/ronin/support/network/ip_range/range.rb +249 -0
- data/lib/ronin/support/network/ip_range.rb +284 -0
- data/lib/ronin/support/network/mixin.rb +58 -0
- data/lib/ronin/support/network/packet.rb +27 -0
- data/lib/ronin/support/network/pop3/mixin.rb +113 -0
- data/lib/ronin/support/network/proxy.rb +602 -0
- data/lib/ronin/support/network/public_suffix/list.rb +339 -0
- data/lib/ronin/support/network/public_suffix/suffix.rb +118 -0
- data/lib/ronin/support/network/public_suffix/suffix_set.rb +150 -0
- data/lib/ronin/support/network/public_suffix.rb +41 -0
- data/lib/ronin/support/network/smtp/email.rb +190 -0
- data/lib/ronin/support/network/smtp/mixin.rb +290 -0
- data/lib/ronin/support/network/smtp.rb +19 -0
- data/lib/ronin/support/network/ssl/local_cert.rb +114 -0
- data/lib/ronin/support/network/ssl/local_key.rb +84 -0
- data/lib/ronin/support/network/ssl/mixin.rb +740 -0
- data/lib/ronin/{network/extensions/imap/net.rb → support/network/ssl/openssl.rb} +6 -7
- data/lib/ronin/support/network/ssl/proxy.rb +296 -0
- data/lib/ronin/support/network/ssl.rb +173 -0
- data/lib/ronin/support/network/tcp/mixin.rb +400 -0
- data/lib/ronin/support/network/tcp/proxy.rb +435 -0
- data/lib/ronin/support/network/tcp.rb +443 -0
- data/lib/ronin/support/network/telnet/mixin.rb +150 -0
- data/lib/ronin/support/network/telnet.rb +90 -0
- data/lib/ronin/support/network/tld/list.rb +266 -0
- data/lib/ronin/support/network/tld.rb +41 -0
- data/lib/ronin/support/network/tls/mixin.rb +670 -0
- data/lib/ronin/support/network/tls/proxy.rb +135 -0
- data/lib/ronin/{network/mixins/dns.rb → support/network/tls.rb} +23 -25
- data/lib/ronin/support/network/udp/mixin.rb +389 -0
- data/lib/ronin/support/network/udp/proxy.rb +192 -0
- data/lib/ronin/support/network/udp.rb +435 -0
- data/lib/ronin/support/network/unix/mixin.rb +273 -0
- data/lib/ronin/support/network.rb +37 -0
- data/lib/ronin/support/path.rb +136 -0
- data/lib/ronin/{network/extensions/dns/net.rb → support/text/core_ext/regexp.rb} +5 -6
- data/lib/ronin/support/text/core_ext/string.rb +46 -0
- data/lib/ronin/{formatting.rb → support/text/core_ext.rb} +7 -9
- data/lib/ronin/support/text/entropy/core_ext/string.rb +45 -0
- data/lib/ronin/{formatting/http.rb → support/text/entropy/core_ext.rb} +3 -4
- data/lib/ronin/support/text/entropy.rb +66 -0
- data/lib/ronin/support/text/erb/mixin.rb +44 -0
- data/lib/ronin/support/text/erb.rb +19 -0
- data/lib/ronin/support/text/homoglyph/core_ext/string.rb +108 -0
- data/lib/ronin/{formatting/digest.rb → support/text/homoglyph/core_ext.rb} +3 -4
- data/lib/ronin/{network/http/exceptions/unknown_request.rb → support/text/homoglyph/exceptions.rb} +7 -6
- data/lib/ronin/support/text/homoglyph/table.rb +228 -0
- data/lib/ronin/support/text/homoglyph.rb +142 -0
- data/lib/ronin/support/text/mixin.rb +31 -0
- data/lib/ronin/support/text/patterns/credentials.rb +75 -0
- data/lib/ronin/support/text/patterns/crypto.rb +67 -0
- data/lib/ronin/support/text/patterns/file_system.rb +93 -0
- data/lib/ronin/support/text/patterns/language.rb +37 -0
- data/lib/ronin/support/text/patterns/network/public_suffix.rb +44 -0
- data/lib/ronin/support/text/patterns/network.rb +140 -0
- data/lib/ronin/support/text/patterns/numeric.rb +52 -0
- data/lib/ronin/support/text/patterns/pii.rb +105 -0
- data/lib/ronin/support/text/patterns/source_code.rb +148 -0
- data/lib/ronin/{extensions.rb → support/text/patterns.rb} +10 -13
- data/lib/ronin/support/text/random/mixin.rb +437 -0
- data/lib/ronin/support/text/random.rb +419 -0
- data/lib/ronin/support/text/typo/core_ext/string.rb +123 -0
- data/lib/ronin/support/text/typo/core_ext.rb +19 -0
- data/lib/ronin/support/text/typo/exceptions.rb +28 -0
- data/lib/ronin/support/text/typo/generator.rb +161 -0
- data/lib/ronin/support/text/typo.rb +260 -0
- data/lib/ronin/{formatting → support}/text.rb +10 -4
- data/lib/ronin/support/version.rb +3 -4
- data/lib/ronin/support.rb +17 -12
- data/ronin-support.gemspec +2 -1
- metadata +342 -291
- data/lib/ronin/binary/hexdump/parser.rb +0 -403
- data/lib/ronin/binary/struct.rb +0 -567
- data/lib/ronin/binary/template.rb +0 -454
- data/lib/ronin/extensions/ip_addr.rb +0 -216
- data/lib/ronin/extensions/meta/object.rb +0 -24
- data/lib/ronin/extensions/regexp.rb +0 -157
- data/lib/ronin/formatting/extensions/binary/base64.rb +0 -106
- data/lib/ronin/formatting/extensions/binary/file.rb +0 -77
- data/lib/ronin/formatting/extensions/binary/float.rb +0 -65
- data/lib/ronin/formatting/extensions/binary/integer.rb +0 -180
- data/lib/ronin/formatting/extensions/binary/string.rb +0 -345
- data/lib/ronin/formatting/extensions/digest/file.rb +0 -129
- data/lib/ronin/formatting/extensions/digest/string.rb +0 -86
- data/lib/ronin/formatting/extensions/digest.rb +0 -21
- data/lib/ronin/formatting/extensions/html/integer.rb +0 -142
- data/lib/ronin/formatting/extensions/html/string.rb +0 -194
- data/lib/ronin/formatting/extensions/html.rb +0 -21
- data/lib/ronin/formatting/extensions/http/string.rb +0 -110
- data/lib/ronin/formatting/extensions/http.rb +0 -21
- data/lib/ronin/formatting/extensions/sql/string.rb +0 -130
- data/lib/ronin/formatting/extensions/sql.rb +0 -20
- data/lib/ronin/formatting/extensions/text/array.rb +0 -137
- data/lib/ronin/formatting/extensions/text/string.rb +0 -297
- data/lib/ronin/formatting/extensions.rb +0 -24
- data/lib/ronin/fuzzing/extensions/string.rb +0 -209
- data/lib/ronin/fuzzing/fuzzer.rb +0 -110
- data/lib/ronin/fuzzing/fuzzing.rb +0 -360
- data/lib/ronin/fuzzing/mutator.rb +0 -161
- data/lib/ronin/fuzzing/repeater.rb +0 -81
- data/lib/ronin/fuzzing/template.rb +0 -133
- data/lib/ronin/fuzzing.rb +0 -21
- data/lib/ronin/mixin.rb +0 -89
- data/lib/ronin/network/dns.rb +0 -201
- data/lib/ronin/network/esmtp.rb +0 -113
- data/lib/ronin/network/extensions/dns.rb +0 -20
- data/lib/ronin/network/extensions/esmtp.rb +0 -20
- data/lib/ronin/network/extensions/http/uri/http.rb +0 -228
- data/lib/ronin/network/extensions/http.rb +0 -21
- data/lib/ronin/network/extensions/imap.rb +0 -20
- data/lib/ronin/network/extensions/pop3/net.rb +0 -24
- data/lib/ronin/network/extensions/pop3.rb +0 -20
- data/lib/ronin/network/extensions/smtp/net.rb +0 -24
- data/lib/ronin/network/extensions/ssl/net.rb +0 -24
- data/lib/ronin/network/extensions/ssl.rb +0 -20
- data/lib/ronin/network/extensions/tcp/net.rb +0 -24
- data/lib/ronin/network/extensions/tcp.rb +0 -20
- data/lib/ronin/network/extensions/telnet/net.rb +0 -24
- data/lib/ronin/network/extensions/telnet.rb +0 -20
- data/lib/ronin/network/extensions/udp/net.rb +0 -24
- data/lib/ronin/network/extensions/udp.rb +0 -20
- data/lib/ronin/network/extensions.rb +0 -29
- data/lib/ronin/network/ftp.rb +0 -149
- data/lib/ronin/network/http/exceptions.rb +0 -20
- data/lib/ronin/network/http/http.rb +0 -1122
- data/lib/ronin/network/http/proxy.rb +0 -330
- data/lib/ronin/network/http.rb +0 -22
- data/lib/ronin/network/imap.rb +0 -158
- data/lib/ronin/network/mixins/esmtp.rb +0 -164
- data/lib/ronin/network/mixins/ftp.rb +0 -155
- data/lib/ronin/network/mixins/http.rb +0 -227
- data/lib/ronin/network/mixins/imap.rb +0 -156
- data/lib/ronin/network/mixins/pop3.rb +0 -149
- data/lib/ronin/network/mixins/smtp.rb +0 -159
- data/lib/ronin/network/mixins/ssl.rb +0 -148
- data/lib/ronin/network/mixins/tcp.rb +0 -368
- data/lib/ronin/network/mixins/telnet.rb +0 -208
- data/lib/ronin/network/mixins/udp.rb +0 -381
- data/lib/ronin/network/mixins/unix.rb +0 -279
- data/lib/ronin/network/mixins.rb +0 -29
- data/lib/ronin/network/pop3.rb +0 -124
- data/lib/ronin/network/proxy.rb +0 -578
- data/lib/ronin/network/smtp/email.rb +0 -174
- data/lib/ronin/network/smtp/smtp.rb +0 -230
- data/lib/ronin/network/smtp.rb +0 -22
- data/lib/ronin/network/ssl.rb +0 -186
- data/lib/ronin/network/tcp/proxy.rb +0 -417
- data/lib/ronin/network/tcp/tcp.rb +0 -452
- data/lib/ronin/network/tcp.rb +0 -21
- data/lib/ronin/network/telnet.rb +0 -266
- data/lib/ronin/network/udp/proxy.rb +0 -191
- data/lib/ronin/network/udp/udp.rb +0 -452
- data/lib/ronin/network/udp.rb +0 -21
- data/lib/ronin/network/unix.rb +0 -286
- data/lib/ronin/network.rb +0 -31
- data/lib/ronin/path.rb +0 -133
- data/lib/ronin/spec/ui/output.rb +0 -22
- data/lib/ronin/support/inflector.rb +0 -92
- data/lib/ronin/templates/erb.rb +0 -78
- data/lib/ronin/templates/template.rb +0 -169
- data/lib/ronin/templates.rb +0 -21
- data/lib/ronin/ui/output/helpers.rb +0 -296
- data/lib/ronin/ui/output/output.rb +0 -142
- data/lib/ronin/ui/output/terminal/color.rb +0 -124
- data/lib/ronin/ui/output/terminal/raw.rb +0 -103
- data/lib/ronin/ui/output/terminal.rb +0 -21
- data/lib/ronin/ui/output.rb +0 -21
- data/lib/ronin/ui/shell.rb +0 -286
- data/lib/ronin/wordlist.rb +0 -287
- data/spec/binary/hexdump/helpers/hexdumps/ascii.bin +0 -0
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_decimal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_hex_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_hex_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_octal_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_octal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/hexdump_repeated.txt +0 -6
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_ints.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_quads.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_decimal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_doubles.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_floats.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_ints.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_quads.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_hex_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_named_chars.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_bytes.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_ints.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_quads.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_octal_shorts.txt +0 -17
- data/spec/binary/hexdump/helpers/hexdumps/od_repeated.txt +0 -6
- data/spec/binary/hexdump/helpers/hexdumps/repeated.bin +0 -1
- data/spec/binary/hexdump/helpers/hexdumps.rb +0 -13
- data/spec/binary/hexdump/parser_spec.rb +0 -302
- data/spec/binary/struct_spec.rb +0 -496
- data/spec/binary/template_spec.rb +0 -416
- data/spec/extensions/enumerable_spec.rb +0 -24
- data/spec/extensions/file_spec.rb +0 -61
- data/spec/extensions/ip_addr_spec.rb +0 -203
- data/spec/extensions/kernel_spec.rb +0 -30
- data/spec/extensions/regexp_spec.rb +0 -482
- data/spec/extensions/resolv_spec.rb +0 -18
- data/spec/extensions/string_spec.rb +0 -180
- data/spec/formatting/binary/array_spec.rb +0 -26
- data/spec/formatting/binary/base64_spec.rb +0 -50
- data/spec/formatting/binary/float_spec.rb +0 -36
- data/spec/formatting/binary/integer_spec.rb +0 -166
- data/spec/formatting/binary/string_spec.rb +0 -199
- data/spec/formatting/digest/string_spec.rb +0 -82
- data/spec/formatting/html/integer_spec.rb +0 -66
- data/spec/formatting/html/string_spec.rb +0 -103
- data/spec/formatting/http/integer_spec.rb +0 -42
- data/spec/formatting/http/string_spec.rb +0 -76
- data/spec/formatting/sql/string_spec.rb +0 -77
- data/spec/formatting/text/array_spec.rb +0 -105
- data/spec/formatting/text/string_spec.rb +0 -162
- data/spec/fuzzing/extensions/string_spec.rb +0 -87
- data/spec/fuzzing/fuzzer_spec.rb +0 -109
- data/spec/fuzzing/fuzzing_spec.rb +0 -24
- data/spec/fuzzing/mutator_spec.rb +0 -112
- data/spec/fuzzing/repeater_spec.rb +0 -57
- data/spec/fuzzing/template_spec.rb +0 -54
- data/spec/mixin_spec.rb +0 -51
- data/spec/network/dns_spec.rb +0 -203
- data/spec/network/ftp_spec.rb +0 -81
- data/spec/network/http/http_spec.rb +0 -559
- data/spec/network/http/proxy_spec.rb +0 -148
- data/spec/network/network_spec.rb +0 -8
- data/spec/network/proxy_spec.rb +0 -121
- data/spec/network/shared/unix_server.rb +0 -31
- data/spec/network/smtp/email_spec.rb +0 -100
- data/spec/network/ssl_spec.rb +0 -70
- data/spec/network/tcp/proxy_spec.rb +0 -118
- data/spec/network/tcp/tcp_spec.rb +0 -316
- data/spec/network/telnet_spec.rb +0 -67
- data/spec/network/udp/udp_spec.rb +0 -298
- data/spec/network/unix_spec.rb +0 -182
- data/spec/path_spec.rb +0 -111
- data/spec/spec_helper.rb +0 -8
- data/spec/support/inflector_spec.rb +0 -22
- data/spec/support_spec.rb +0 -8
- data/spec/templates/classes/example_erb.rb +0 -11
- data/spec/templates/classes/example_template.rb +0 -35
- data/spec/templates/erb_spec.rb +0 -21
- data/spec/templates/helpers/data/includes/_relative.erb +0 -1
- data/spec/templates/helpers/data/templates/example.erb +0 -1
- data/spec/templates/helpers/data.rb +0 -9
- data/spec/templates/template_spec.rb +0 -54
- data/spec/ui/classes/test_shell.rb +0 -22
- data/spec/ui/output_spec.rb +0 -32
- data/spec/ui/shell_spec.rb +0 -83
- data/spec/wordlist_spec.rb +0 -151
@@ -0,0 +1,1473 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
|
+
#
|
5
|
+
# ronin-support is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published
|
7
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# ronin-support is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with ronin-support. If not, see <https://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'ronin/support/network/dns'
|
20
|
+
require 'ronin/support/network/dns/idn'
|
21
|
+
require 'ronin/support/network/ip'
|
22
|
+
require 'ronin/support/network/tld'
|
23
|
+
require 'ronin/support/network/public_suffix'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module Support
|
27
|
+
module Network
|
28
|
+
#
|
29
|
+
# Represents a host or host name.
|
30
|
+
#
|
31
|
+
# ## Examples
|
32
|
+
#
|
33
|
+
# host = Host.new('www.example.com')
|
34
|
+
#
|
35
|
+
# Resolve parent domain:
|
36
|
+
#
|
37
|
+
# host.domain
|
38
|
+
# # => #<Ronin::Support::Network::Domain: example.co.uk>
|
39
|
+
#
|
40
|
+
# Resolve IP addresses:
|
41
|
+
#
|
42
|
+
# host.get_address
|
43
|
+
# # => "172.67.128.149"
|
44
|
+
# host.get_addresses
|
45
|
+
# # => ["104.21.2.18", "172.67.128.149"]
|
46
|
+
# host.get_ip
|
47
|
+
# # => #<Ronin::Support::Network::IP: 172.67.128.149>
|
48
|
+
# host.get_ips
|
49
|
+
# # => [#<Ronin::Support::Network::IP: 104.21.2.18>, #<Ronin::Support::Network::IP: 172.67.128.149>]
|
50
|
+
# host.ip
|
51
|
+
# # => #<Ronin::Support::Network::IP: 172.67.128.149>
|
52
|
+
# host.ips
|
53
|
+
# # => [#<Ronin::Support::Network::IP: 104.21.2.18>, #<Ronin::Support::Network::IP: 172.67.128.149>]
|
54
|
+
#
|
55
|
+
# Other DNS queries:
|
56
|
+
#
|
57
|
+
# host = Host.new('www.github.com')
|
58
|
+
# host.get_record(:txt)
|
59
|
+
# # => #<Resolv::DNS::Resource::IN::TXT:0x00007f7e500777d8 @strings=["MS=ms58704441"], @ttl=3575>
|
60
|
+
# host.get_records(:txt)
|
61
|
+
# # => [#<Resolv::DNS::Resource::IN::TXT:0x00007f7e500777d8 @strings=["MS=ms58704441"], @ttl=3575>, ...]
|
62
|
+
# host.get_cname_record
|
63
|
+
# # => #<Resolv::DNS::Resource::IN::CNAME:0x00007f7e50063da0 @name=#<Resolv::DNS::Name: github.com.>, @ttl=3500>
|
64
|
+
# host.get_cname
|
65
|
+
# # => "github.com"
|
66
|
+
# host.cname
|
67
|
+
# # => "github.com"
|
68
|
+
# host.get_mx_records
|
69
|
+
# # => [#<Resolv::DNS::Resource::IN::MX:0x00007f7e50035658 @exchange=#<Resolv::DNS::Name: aspmx.l.google.com.>, @preference=1, @ttl=3600>, ...]
|
70
|
+
# host.get_mailservers
|
71
|
+
# # => ["alt1.aspmx.l.google.com",
|
72
|
+
# "alt4.aspmx.l.google.com",
|
73
|
+
# "alt3.aspmx.l.google.com",
|
74
|
+
# "alt2.aspmx.l.google.com",
|
75
|
+
# "aspmx.l.google.com"]
|
76
|
+
# host.mailservers
|
77
|
+
# # => ["alt1.aspmx.l.google.com",
|
78
|
+
# "alt4.aspmx.l.google.com",
|
79
|
+
# "alt3.aspmx.l.google.com",
|
80
|
+
# "alt2.aspmx.l.google.com",
|
81
|
+
# "aspmx.l.google.com"]
|
82
|
+
# host.get_ns_records
|
83
|
+
# # => [#<Resolv::DNS::Resource::IN::NS:0x00007f7e4f972258 @name=#<Resolv::DNS::Name: dns1.p08.nsone.net.>, @ttl=900>, ...]
|
84
|
+
# host.get_nameservers
|
85
|
+
# # => ["dns3.p08.nsone.net",
|
86
|
+
# "ns-1707.awsdns-21.co.uk",
|
87
|
+
# "dns2.p08.nsone.net",
|
88
|
+
# "ns-1283.awsdns-32.org",
|
89
|
+
# "dns4.p08.nsone.net",
|
90
|
+
# "ns-421.awsdns-52.com",
|
91
|
+
# "dns1.p08.nsone.net",
|
92
|
+
# "ns-520.awsdns-01.net"]
|
93
|
+
# host.nameservers
|
94
|
+
# # => ["dns3.p08.nsone.net",
|
95
|
+
# "ns-1707.awsdns-21.co.uk",
|
96
|
+
# "dns2.p08.nsone.net",
|
97
|
+
# "ns-1283.awsdns-32.org",
|
98
|
+
# "dns4.p08.nsone.net",
|
99
|
+
# "ns-421.awsdns-52.com",
|
100
|
+
# "dns1.p08.nsone.net",
|
101
|
+
# "ns-520.awsdns-01.net"]
|
102
|
+
# host.get_soa_record
|
103
|
+
# # => #<Resolv::DNS::Resource::IN::SOA:0x00007f7e4f63d0b0 @mname=#<Resolv::DNS::Name: ns-1707.awsdns-21.co.uk.>, @rname=#<Resolv::DNS::Name: awsdns-hostmaster.amazon.com.>, @serial=1, @refresh=7200, @retry=900, @expire=1209600, @minimum=86400, @ttl=880>
|
104
|
+
# host.soa_record
|
105
|
+
# # => #<Resolv::DNS::Resource::IN::SOA:0x00007f7e4f63d0b0 @mname=#<Resolv::DNS::Name: ns-1707.awsdns-21.co.uk.>, @rname=#<Resolv::DNS::Name: awsdns-hostmaster.amazon.com.>, @serial=1, @refresh=7200, @retry=900, @expire=1209600, @minimum=86400, @ttl=880>
|
106
|
+
# host.get_txt_record
|
107
|
+
# # => #<Resolv::DNS::Resource::IN::TXT:0x00007f7e4f8cbbb0 @strings=[\"adobe-idp-site-verification=b92c9e999aef825edc36e0a3d847d2dbad5b2fc0e05c79ddd7a16139b48ecf4b\"], @ttl=2887>
|
108
|
+
# host.get_txt_string
|
109
|
+
# # => "stripe-verification=f88ef17321660a01bab1660454192e014defa29ba7b8de9633c69d6b4912217f"
|
110
|
+
# host.get_txt_records
|
111
|
+
# # => [#<Resolv::DNS::Resource::IN::TXT:0x00007f7e4f67c648 @strings=[\"apple-domain-verification=RyQhdzTl6Z6x8ZP4\"], @ttl=2852>, ...]
|
112
|
+
# host.get_txt_strings
|
113
|
+
# # => ["apple-domain-verification=RyQhdzTl6Z6x8ZP4",
|
114
|
+
# "MS=ms58704441",
|
115
|
+
# "atlassian-domain-verification=jjgw98AKv2aeoYFxiL/VFaoyPkn3undEssTRuMg6C/3Fp/iqhkV4HVV7WjYlVeF8",
|
116
|
+
# "MS=6BF03E6AF5CB689E315FB6199603BABF2C88D805",
|
117
|
+
# "v=spf1 ip4:192.30.252.0/22 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com include:spf.protection.outlook.com include:mail.zendesk.com include:_spf.salesforce.com include:servers.mcsv.net ip4:166.78.69.169 ip4:1",
|
118
|
+
# "66.78.69.170 ip4:166.78.71.131 ip4:167.89.101.2 ip4:167.89.101.192/28 ip4:192.254.112.60 ip4:192.254.112.98/31 ip4:192.254.113.10 ip4:192.254.113.101 ip4:192.254.114.176 ip4:62.253.227.114 ~all",
|
119
|
+
# "docusign=087098e3-3d46-47b7-9b4e-8a23028154cd",
|
120
|
+
# "google-site-verification=UTM-3akMgubp6tQtgEuAkYNYLyYAvpTnnSrDMWoDR3o",
|
121
|
+
# "stripe-verification=f88ef17321660a01bab1660454192e014defa29ba7b8de9633c69d6b4912217f",
|
122
|
+
# "adobe-idp-site-verification=b92c9e999aef825edc36e0a3d847d2dbad5b2fc0e05c79ddd7a16139b48ecf4b",
|
123
|
+
# "MS=ms44452932"]
|
124
|
+
# host.txt_strings
|
125
|
+
# # => ["apple-domain-verification=RyQhdzTl6Z6x8ZP4",
|
126
|
+
# "MS=ms58704441",
|
127
|
+
# "atlassian-domain-verification=jjgw98AKv2aeoYFxiL/VFaoyPkn3undEssTRuMg6C/3Fp/iqhkV4HVV7WjYlVeF8",
|
128
|
+
# "MS=6BF03E6AF5CB689E315FB6199603BABF2C88D805",
|
129
|
+
# "v=spf1 ip4:192.30.252.0/22 include:_netblocks.google.com include:_netblocks2.google.com include:_netblocks3.google.com include:spf.protection.outlook.com include:mail.zendesk.com include:_spf.salesforce.com include:servers.mcsv.net ip4:166.78.69.169 ip4:1",
|
130
|
+
# "66.78.69.170 ip4:166.78.71.131 ip4:167.89.101.2 ip4:167.89.101.192/28 ip4:192.254.112.60 ip4:192.254.112.98/31 ip4:192.254.113.10 ip4:192.254.113.101 ip4:192.254.114.176 ip4:62.253.227.114 ~all",
|
131
|
+
# "docusign=087098e3-3d46-47b7-9b4e-8a23028154cd",
|
132
|
+
# "google-site-verification=UTM-3akMgubp6tQtgEuAkYNYLyYAvpTnnSrDMWoDR3o",
|
133
|
+
# "stripe-verification=f88ef17321660a01bab1660454192e014defa29ba7b8de9633c69d6b4912217f",
|
134
|
+
# "adobe-idp-site-verification=b92c9e999aef825edc36e0a3d847d2dbad5b2fc0e05c79ddd7a16139b48ecf4b",
|
135
|
+
# "MS=ms44452932"]
|
136
|
+
#
|
137
|
+
# @api public
|
138
|
+
#
|
139
|
+
# @since 1.0.0
|
140
|
+
#
|
141
|
+
class Host
|
142
|
+
|
143
|
+
# The host name.
|
144
|
+
#
|
145
|
+
# @return [String]
|
146
|
+
attr_reader :name
|
147
|
+
|
148
|
+
#
|
149
|
+
# Initializes the host.
|
150
|
+
#
|
151
|
+
# @param [String] name
|
152
|
+
# The host's hostname.
|
153
|
+
#
|
154
|
+
# @example
|
155
|
+
# host = Host.new('www.example.com')
|
156
|
+
#
|
157
|
+
def initialize(name)
|
158
|
+
@name = name
|
159
|
+
end
|
160
|
+
|
161
|
+
#
|
162
|
+
# Determines if the hostname is an [IDN] hostname.
|
163
|
+
#
|
164
|
+
# [IDN]: https://en.wikipedia.org/wiki/Internationalized_domain_name
|
165
|
+
#
|
166
|
+
# @return [Boolean]
|
167
|
+
#
|
168
|
+
def idn?
|
169
|
+
@name !~ /\A[A-Za-z0-9._-]+\z/
|
170
|
+
end
|
171
|
+
|
172
|
+
alias unicode? idn?
|
173
|
+
|
174
|
+
#
|
175
|
+
# Determines if the hostname is a [punycode] hostnmae.
|
176
|
+
#
|
177
|
+
# [punycode]: https://en.wikipedia.org/wiki/Punycode
|
178
|
+
#
|
179
|
+
# @return [Boolean]
|
180
|
+
#
|
181
|
+
def punycode?
|
182
|
+
@name.include?('xn--')
|
183
|
+
end
|
184
|
+
|
185
|
+
#
|
186
|
+
# Converts the hostname to it's [punycode] version.
|
187
|
+
#
|
188
|
+
# [punycode]: https://en.wikipedia.org/wiki/Punycode
|
189
|
+
#
|
190
|
+
# @return [Host]
|
191
|
+
# The new host containing the punycode version of the hostname.
|
192
|
+
#
|
193
|
+
def punycode
|
194
|
+
self.class.new(DNS::IDN.to_ascii(@name))
|
195
|
+
end
|
196
|
+
|
197
|
+
#
|
198
|
+
# The Top-Level Domain of the hostnmae.
|
199
|
+
#
|
200
|
+
# @return [String]
|
201
|
+
# The last component of the hostname.
|
202
|
+
#
|
203
|
+
# @raise [InvalidHostname]
|
204
|
+
# The hostname does not end with a valid TLD.
|
205
|
+
#
|
206
|
+
# @example
|
207
|
+
# host = Host.new('foo.bar.example.co.uk')
|
208
|
+
# host.tld
|
209
|
+
# # => "uk"
|
210
|
+
#
|
211
|
+
def tld
|
212
|
+
@tld ||= TLD.list.split(@name).last
|
213
|
+
end
|
214
|
+
|
215
|
+
#
|
216
|
+
# The public suffix of the hostname.
|
217
|
+
#
|
218
|
+
# @return [String]
|
219
|
+
# The suffix of the hostname (ex: `.co.uk`).
|
220
|
+
#
|
221
|
+
# @raise [InvalidHostname]
|
222
|
+
# The hostname does not end with a valid suffix.
|
223
|
+
#
|
224
|
+
# @example
|
225
|
+
# host = Host.new('foo.bar.example.co.uk')
|
226
|
+
# host.suffix
|
227
|
+
# # => "co.uk"
|
228
|
+
#
|
229
|
+
def suffix
|
230
|
+
@suffix ||= PublicSuffix.list.split(@name).last
|
231
|
+
end
|
232
|
+
|
233
|
+
#
|
234
|
+
# Returns the associated domain for the hostname.
|
235
|
+
#
|
236
|
+
# @return [Domain]
|
237
|
+
# The domain object derived from the hostname, without any sub-domain
|
238
|
+
# components (ex: `www`).
|
239
|
+
#
|
240
|
+
# @raise [InvalidHostname]
|
241
|
+
# The hostname does not end with a valid suffix.
|
242
|
+
#
|
243
|
+
# @example
|
244
|
+
# host = Host.new('foo.bar.example.co.uk')
|
245
|
+
# host.domain
|
246
|
+
# # => #<Ronin::Support::Network::Domain: example.co.uk>
|
247
|
+
#
|
248
|
+
# @note This method returns memoized data.
|
249
|
+
#
|
250
|
+
def domain
|
251
|
+
@domain ||= begin
|
252
|
+
domain, suffix = PublicSuffix.list.split(@name)
|
253
|
+
|
254
|
+
if (last_dot = domain.rindex('.'))
|
255
|
+
domain = domain[(last_dot+1)..]
|
256
|
+
end
|
257
|
+
|
258
|
+
Domain.new("#{domain}.#{suffix}")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
#
|
263
|
+
# Creates a sub-domain under the hostname.
|
264
|
+
#
|
265
|
+
# @param [String] subname
|
266
|
+
# The sub-name to add under the hostname.
|
267
|
+
#
|
268
|
+
# @return [Host]
|
269
|
+
# The new sub-domain.
|
270
|
+
#
|
271
|
+
def subdomain(subname)
|
272
|
+
Host.new("#{subname}.#{@name}")
|
273
|
+
end
|
274
|
+
|
275
|
+
#
|
276
|
+
# Changes the suffix of the hostname.
|
277
|
+
#
|
278
|
+
# @param [String] new_suffix
|
279
|
+
# The new suffix for the hostname.
|
280
|
+
#
|
281
|
+
# @return [Host]
|
282
|
+
# The new host object with the new suffix.
|
283
|
+
#
|
284
|
+
# @raise [PublicSuffix::InvalidHostname]
|
285
|
+
# The hostname does not end with a valid suffix.
|
286
|
+
#
|
287
|
+
# @example
|
288
|
+
# host = Host.new('www.example.co.uk')
|
289
|
+
# host.change_suffix('.com')
|
290
|
+
# # => #<Ronin::Support::Network::Host: www.example.com>
|
291
|
+
#
|
292
|
+
def change_suffix(new_suffix)
|
293
|
+
name, suffix = PublicSuffix.list.split(@name)
|
294
|
+
new_suffix = new_suffix.to_s
|
295
|
+
|
296
|
+
if new_suffix.start_with?('.')
|
297
|
+
return self.class.new("#{name}#{new_suffix}")
|
298
|
+
else
|
299
|
+
return self.class.new("#{name}.#{new_suffix}")
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
alias change_tld change_suffix
|
304
|
+
|
305
|
+
#
|
306
|
+
# Enumerates over every hostname with a different TLD.
|
307
|
+
#
|
308
|
+
# @yield [host]
|
309
|
+
# The given block will be passed each hostname with a different TLD.
|
310
|
+
#
|
311
|
+
# @yieldparam [Host] host
|
312
|
+
# The new host object with a different TLD.
|
313
|
+
#
|
314
|
+
# @return [Enumerator]
|
315
|
+
# If no block is given, an enumerator will be returned.
|
316
|
+
#
|
317
|
+
def each_tld
|
318
|
+
return enum_for(__method__) unless block_given?
|
319
|
+
|
320
|
+
TLD.list.each do |tld|
|
321
|
+
yield change_suffix(tld)
|
322
|
+
end
|
323
|
+
|
324
|
+
return nil
|
325
|
+
end
|
326
|
+
|
327
|
+
#
|
328
|
+
# Enumerates over every hostname with a different public suffix.
|
329
|
+
#
|
330
|
+
# @param [:icann, :private, nil] type
|
331
|
+
# The optional specific type of suffixes to enumerate.
|
332
|
+
#
|
333
|
+
# @yield [host]
|
334
|
+
# The given block will be passed each hostname with a different
|
335
|
+
# public suffix.
|
336
|
+
#
|
337
|
+
# @yieldparam [Host] host
|
338
|
+
# The new host object with a different public suffix.
|
339
|
+
#
|
340
|
+
# @return [Enumerator]
|
341
|
+
# If no block is given, an enumerator will be returned.
|
342
|
+
#
|
343
|
+
def each_suffix(type: nil)
|
344
|
+
return enum_for(__method__, type: type) unless block_given?
|
345
|
+
|
346
|
+
PublicSuffix.list.each do |suffix|
|
347
|
+
unless suffix.wildcard?
|
348
|
+
if (type == nil) || (suffix.type == type)
|
349
|
+
yield change_suffix(suffix)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
return nil
|
355
|
+
end
|
356
|
+
|
357
|
+
#
|
358
|
+
# Looks up the address of a hostname.
|
359
|
+
#
|
360
|
+
# @param [Hash{Symbol => Object}] kwargs
|
361
|
+
# Additional keyword arguments.
|
362
|
+
#
|
363
|
+
# @option [Array<String>, String, nil] :nameservers
|
364
|
+
# Optional DNS nameserver(s) to query.
|
365
|
+
#
|
366
|
+
# @option [String, nil] :nameserver
|
367
|
+
# Optional DNS nameserver to query.
|
368
|
+
#
|
369
|
+
# @return [String, nil]
|
370
|
+
# The address of the hostname.
|
371
|
+
#
|
372
|
+
# @example
|
373
|
+
# host = Host.new('www.example.com')
|
374
|
+
# host.get_address
|
375
|
+
# # => "172.67.128.149"
|
376
|
+
#
|
377
|
+
def get_address(**kwargs)
|
378
|
+
DNS.resolver(**kwargs).get_address(@name)
|
379
|
+
end
|
380
|
+
|
381
|
+
alias lookup get_address
|
382
|
+
|
383
|
+
#
|
384
|
+
# Looks up all addresses of a hostname.
|
385
|
+
#
|
386
|
+
# @param [Hash{Symbol => Object}] kwargs
|
387
|
+
# Additional keyword arguments.
|
388
|
+
#
|
389
|
+
# @option [Array<String>, String, nil] :nameservers
|
390
|
+
# Optional DNS nameserver(s) to query.
|
391
|
+
#
|
392
|
+
# @option [String, nil] :nameserver
|
393
|
+
# Optional DNS nameserver to query.
|
394
|
+
#
|
395
|
+
# @return [Array<String>]
|
396
|
+
# The addresses of the hostname.
|
397
|
+
#
|
398
|
+
# @example
|
399
|
+
# host = Host.new('www.example.com')
|
400
|
+
# host.get_addresses
|
401
|
+
# # => ["104.21.2.18", "172.67.128.149"]
|
402
|
+
#
|
403
|
+
def get_addresses(**kwargs)
|
404
|
+
DNS.resolver(**kwargs).get_addresses(@name)
|
405
|
+
end
|
406
|
+
|
407
|
+
#
|
408
|
+
# The addreses of the hostname.
|
409
|
+
#
|
410
|
+
# @return [Array<String>]
|
411
|
+
# The addresses associated with the hostname.
|
412
|
+
#
|
413
|
+
# @example
|
414
|
+
# host = Host.new('www.example.com')
|
415
|
+
# host.addresses
|
416
|
+
# # => ["104.21.2.18", "172.67.128.149"]
|
417
|
+
#
|
418
|
+
# @note This method returns memoized data.
|
419
|
+
#
|
420
|
+
def addresses
|
421
|
+
@addresses ||= get_addresses
|
422
|
+
end
|
423
|
+
|
424
|
+
#
|
425
|
+
# Determines if the hostname has any addresses.
|
426
|
+
#
|
427
|
+
# @return [Boolean]
|
428
|
+
#
|
429
|
+
# @example
|
430
|
+
# host = Host.new('www.example.com')
|
431
|
+
# host.has_addresses?
|
432
|
+
# # => trun
|
433
|
+
# host = Host.new('www.does-not-exist.com')
|
434
|
+
# host.has_addresses?
|
435
|
+
# # => false
|
436
|
+
#
|
437
|
+
def has_addresses?
|
438
|
+
!addresses.empty?
|
439
|
+
end
|
440
|
+
|
441
|
+
#
|
442
|
+
# Looks up the IPs of the host.
|
443
|
+
#
|
444
|
+
# @param [Hash{Symbol => Object}] kwargs
|
445
|
+
# Additional keyword arguments.
|
446
|
+
#
|
447
|
+
# @option [Array<String>, String, nil] :nameservers
|
448
|
+
# Optional DNS nameserver(s) to query.
|
449
|
+
#
|
450
|
+
# @option [String, nil] :nameserver
|
451
|
+
# Optional DNS nameserver to query.
|
452
|
+
#
|
453
|
+
# @return [String, nil]
|
454
|
+
# The IP for the host.
|
455
|
+
#
|
456
|
+
# @example
|
457
|
+
# host = Host.new('www.example.com')
|
458
|
+
# host.get_ip
|
459
|
+
# # => #<Ronin::Support::Network::IP: 172.67.128.149>
|
460
|
+
#
|
461
|
+
def get_ip(**kwargs)
|
462
|
+
if (address = get_address(**kwargs))
|
463
|
+
IP.new(address)
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
#
|
468
|
+
# Looks up all IPs for the host.
|
469
|
+
#
|
470
|
+
# @param [Hash{Symbol => Object}] kwargs
|
471
|
+
# Additional keyword arguments.
|
472
|
+
#
|
473
|
+
# @option [Array<String>, String, nil] :nameservers
|
474
|
+
# Optional DNS nameserver(s) to query.
|
475
|
+
#
|
476
|
+
# @option [String, nil] :nameserver
|
477
|
+
# Optional DNS nameserver to query.
|
478
|
+
#
|
479
|
+
# @return [Array<IP>]
|
480
|
+
# The IPs for the host.
|
481
|
+
#
|
482
|
+
# @example
|
483
|
+
# host = Host.new('www.example.com')
|
484
|
+
# host.get_ips
|
485
|
+
# # => [#<Ronin::Support::Network::IP: 104.21.2.18>, #<Ronin::Support::Network::IP: 172.67.128.149>]
|
486
|
+
#
|
487
|
+
def get_ips(**kwargs)
|
488
|
+
get_addresses(**kwargs).map { |address| IP.new(address) }
|
489
|
+
end
|
490
|
+
|
491
|
+
#
|
492
|
+
# The IPs for the host.
|
493
|
+
#
|
494
|
+
# @return [Array<IP>]
|
495
|
+
# The IPs of the host or an empty Array if the host has no IP
|
496
|
+
# addresses.
|
497
|
+
#
|
498
|
+
# @example
|
499
|
+
# host = Host.new('www.example.com')
|
500
|
+
# host.ips
|
501
|
+
# # => [#<Ronin::Support::Network::IP: 104.21.2.18>, #<Ronin::Support::Network::IP: 172.67.128.149>]
|
502
|
+
#
|
503
|
+
# @note This method returns memoized data.
|
504
|
+
#
|
505
|
+
def ips
|
506
|
+
@ips ||= get_ips
|
507
|
+
end
|
508
|
+
|
509
|
+
#
|
510
|
+
# The IP for the host.
|
511
|
+
#
|
512
|
+
# @return [IP, nil]
|
513
|
+
# The IP for the host or `nil` if the host has no IP addresses.
|
514
|
+
#
|
515
|
+
# @example
|
516
|
+
# host = Host.new('www.example.com')
|
517
|
+
# host.ip
|
518
|
+
# # => #<Ronin::Support::Network::IP: 104.21.2.18>
|
519
|
+
#
|
520
|
+
def ip
|
521
|
+
ips.first
|
522
|
+
end
|
523
|
+
|
524
|
+
#
|
525
|
+
# Queries a single matching DNS record for the host name.
|
526
|
+
#
|
527
|
+
# @param [String, nil] name
|
528
|
+
# The optional record name to query.
|
529
|
+
#
|
530
|
+
# @param [:a, :aaaa, :any, :cname, :hinfo, :loc, :minfo, :mx, :ns, :ptr, :soa, :srv, :txt, :wks] record_type
|
531
|
+
# The record type to query for.
|
532
|
+
#
|
533
|
+
# @param [Hash{Symbol => Object}] kwargs
|
534
|
+
# Additional keyword arguments.
|
535
|
+
#
|
536
|
+
# @option [Array<String>, String, nil] :nameservers
|
537
|
+
# Optional DNS nameserver(s) to query.
|
538
|
+
#
|
539
|
+
# @option [String, nil] :nameserver
|
540
|
+
# Optional DNS nameserver to query.
|
541
|
+
#
|
542
|
+
# @return [Resolv::DNS::Resource, nil]
|
543
|
+
# The matching DNS records or `nil` if no matching DNS records
|
544
|
+
# could be found.
|
545
|
+
#
|
546
|
+
# @example
|
547
|
+
# host = Host.new('www.example.com')
|
548
|
+
#
|
549
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource
|
550
|
+
# @see DNS::Resolver#get_record
|
551
|
+
#
|
552
|
+
def get_record(name=nil,record_type,**kwargs)
|
553
|
+
name = if name then "#{name}.#{@name}"
|
554
|
+
else @name
|
555
|
+
end
|
556
|
+
|
557
|
+
DNS.resolver(**kwargs).get_record(name,record_type)
|
558
|
+
end
|
559
|
+
|
560
|
+
#
|
561
|
+
# Queries all matching DNS records for the host name.
|
562
|
+
#
|
563
|
+
# @param [String, nil] name
|
564
|
+
# The optional record name to query.
|
565
|
+
#
|
566
|
+
# @param [:a, :aaaa, :any, :cname, :hinfo, :loc, :minfo, :mx, :ns, :ptr, :soa, :srv, :txt, :wks] record_type
|
567
|
+
# The record type to query for.
|
568
|
+
#
|
569
|
+
# @param [Hash{Symbol => Object}] kwargs
|
570
|
+
# Additional keyword arguments.
|
571
|
+
#
|
572
|
+
# @option [Array<String>, String, nil] :nameservers
|
573
|
+
# Optional DNS nameserver(s) to query.
|
574
|
+
#
|
575
|
+
# @option [String, nil] :nameserver
|
576
|
+
# Optional DNS nameserver to query.
|
577
|
+
#
|
578
|
+
# @return [Array<Resolv::DNS::Resource>]
|
579
|
+
# All matching DNS records.
|
580
|
+
#
|
581
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource
|
582
|
+
# @see DNS::Resolver#get_records
|
583
|
+
#
|
584
|
+
def get_records(name=nil,record_type,**kwargs)
|
585
|
+
name = if name then "#{name}.#{@name}"
|
586
|
+
else @name
|
587
|
+
end
|
588
|
+
|
589
|
+
DNS.resolver(**kwargs).get_records(name,record_type)
|
590
|
+
end
|
591
|
+
|
592
|
+
#
|
593
|
+
# Queries all records of the host name using the `ANY` DNS query.
|
594
|
+
#
|
595
|
+
# @param [String, nil] name
|
596
|
+
# The optional record name to query.
|
597
|
+
#
|
598
|
+
# @param [Hash{Symbol => Object}] kwargs
|
599
|
+
# Additional keyword arguments.
|
600
|
+
#
|
601
|
+
# @option [Array<String>, String, nil] :nameservers
|
602
|
+
# Optional DNS nameserver(s) to query.
|
603
|
+
#
|
604
|
+
# @option [String, nil] :nameserver
|
605
|
+
# Optional DNS nameserver to query.
|
606
|
+
#
|
607
|
+
# @return [Array<Resolv::DNS::Resource>]
|
608
|
+
# All of the DNS records belonging to the host name.
|
609
|
+
#
|
610
|
+
# @see DNS::Resolver#get_any_records
|
611
|
+
#
|
612
|
+
def get_any_records(name=nil,**kwargs)
|
613
|
+
name = if name then "#{name}.#{@name}"
|
614
|
+
else @name
|
615
|
+
end
|
616
|
+
|
617
|
+
DNS.resolver(**kwargs).get_any_records(name)
|
618
|
+
end
|
619
|
+
|
620
|
+
#
|
621
|
+
# Queries the `CNAME` record for the host name.
|
622
|
+
#
|
623
|
+
# @param [String, nil] name
|
624
|
+
# The optional record name to query.
|
625
|
+
#
|
626
|
+
# @param [Hash{Symbol => Object}] kwargs
|
627
|
+
# Additional keyword arguments.
|
628
|
+
#
|
629
|
+
# @option [Array<String>, String, nil] :nameservers
|
630
|
+
# Optional DNS nameserver(s) to query.
|
631
|
+
#
|
632
|
+
# @option [String, nil] :nameserver
|
633
|
+
# Optional DNS nameserver to query.
|
634
|
+
#
|
635
|
+
# @return [Resolv::DNS::Resource::IN::CNAME, nil]
|
636
|
+
# The `CNAME` record or `nil` if the host name has no `CNAME`
|
637
|
+
# record.
|
638
|
+
#
|
639
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/CNAME
|
640
|
+
# @see DNS::Resolver#get_cname_record
|
641
|
+
#
|
642
|
+
def get_cname_record(name=nil,**kwargs)
|
643
|
+
name = if name then "#{name}.#{@name}"
|
644
|
+
else @name
|
645
|
+
end
|
646
|
+
|
647
|
+
DNS.resolver(**kwargs).get_cname_record(name)
|
648
|
+
end
|
649
|
+
|
650
|
+
#
|
651
|
+
# Queries the canonical name for the host name.
|
652
|
+
#
|
653
|
+
# @param [String, nil] name
|
654
|
+
# The optional record name to query.
|
655
|
+
#
|
656
|
+
# @param [Hash{Symbol => Object}] kwargs
|
657
|
+
# Additional keyword arguments.
|
658
|
+
#
|
659
|
+
# @option [Array<String>, String, nil] :nameservers
|
660
|
+
# Optional DNS nameserver(s) to query.
|
661
|
+
#
|
662
|
+
# @option [String, nil] :nameserver
|
663
|
+
# Optional DNS nameserver to query.
|
664
|
+
#
|
665
|
+
# @return [String, nil]
|
666
|
+
# The canonical name for the host or `nil` if the host has no
|
667
|
+
# `CNAME` record.
|
668
|
+
#
|
669
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/CNAME
|
670
|
+
# @see DNS::Resolver#get_cname
|
671
|
+
#
|
672
|
+
def get_cname(name=nil,**kwargs)
|
673
|
+
name = if name then "#{name}.#{@name}"
|
674
|
+
else @name
|
675
|
+
end
|
676
|
+
|
677
|
+
DNS.resolver(**kwargs).get_cname(name)
|
678
|
+
end
|
679
|
+
|
680
|
+
#
|
681
|
+
# The `CNAME` record for the host.
|
682
|
+
#
|
683
|
+
# @return [String, nil]
|
684
|
+
# The `CNAME` host name.
|
685
|
+
#
|
686
|
+
# @note This method returns memoized data.
|
687
|
+
#
|
688
|
+
# @see #get_cname
|
689
|
+
#
|
690
|
+
def cname
|
691
|
+
@cname ||= get_cname
|
692
|
+
end
|
693
|
+
|
694
|
+
#
|
695
|
+
# Queries the `HINFO` record for the host name.
|
696
|
+
#
|
697
|
+
# @param [String, nil] name
|
698
|
+
# The optional record name to query.
|
699
|
+
#
|
700
|
+
# @param [Hash{Symbol => Object}] kwargs
|
701
|
+
# Additional keyword arguments.
|
702
|
+
#
|
703
|
+
# @option [Array<String>, String, nil] :nameservers
|
704
|
+
# Optional DNS nameserver(s) to query.
|
705
|
+
#
|
706
|
+
# @option [String, nil] :nameserver
|
707
|
+
# Optional DNS nameserver to query.
|
708
|
+
#
|
709
|
+
# @return [Resolv::DNS::Resource::IN::HINFO, nil]
|
710
|
+
# The `HINFO` DNS record or `nil` if the host name has no `HINFO`
|
711
|
+
# record.
|
712
|
+
#
|
713
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/HINFO
|
714
|
+
# @see DNS::Resolver#get_hinfo_record
|
715
|
+
#
|
716
|
+
def get_hinfo_record(name=nil,**kwargs)
|
717
|
+
name = if name then "#{name}.#{@name}"
|
718
|
+
else @name
|
719
|
+
end
|
720
|
+
|
721
|
+
DNS.resolver(**kwargs).get_hinfo_record(name)
|
722
|
+
end
|
723
|
+
|
724
|
+
#
|
725
|
+
# The `HINFO` record for the host.
|
726
|
+
#
|
727
|
+
# @return [Resolv::DNS::Resource::IN::HINFO, nil]
|
728
|
+
# The `HINFO` DNS record or `nil` if the host name has no `HINFO`
|
729
|
+
# record.
|
730
|
+
#
|
731
|
+
# @note This method returns memoized data.
|
732
|
+
#
|
733
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/HINFO
|
734
|
+
# @see #get_hinfo_record
|
735
|
+
#
|
736
|
+
def hinfo_record
|
737
|
+
@hinfo_record ||= get_hinfo_record
|
738
|
+
end
|
739
|
+
|
740
|
+
#
|
741
|
+
# Queries the first `A` record belonging to the host name.
|
742
|
+
#
|
743
|
+
# @param [String, nil] name
|
744
|
+
# The optional record name to query.
|
745
|
+
#
|
746
|
+
# @param [Hash{Symbol => Object}] kwargs
|
747
|
+
# Additional keyword arguments.
|
748
|
+
#
|
749
|
+
# @option [Array<String>, String, nil] :nameservers
|
750
|
+
# Optional DNS nameserver(s) to query.
|
751
|
+
#
|
752
|
+
# @option [String, nil] :nameserver
|
753
|
+
# Optional DNS nameserver to query.
|
754
|
+
#
|
755
|
+
# @return [Resolv::DNS::Resource::IN::A, nil]
|
756
|
+
# The first `A` DNS record or `nil` if the host name has no `A`
|
757
|
+
# records.
|
758
|
+
#
|
759
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/IN/A
|
760
|
+
# @see DNS::Resolver#get_a_record
|
761
|
+
#
|
762
|
+
def get_a_record(name=nil,**kwargs)
|
763
|
+
name = if name then "#{name}.#{@name}"
|
764
|
+
else @name
|
765
|
+
end
|
766
|
+
|
767
|
+
DNS.resolver(**kwargs).get_a_record(name)
|
768
|
+
end
|
769
|
+
|
770
|
+
#
|
771
|
+
# Queries the first IPv4 address belonging to the host name.
|
772
|
+
#
|
773
|
+
# @param [String, nil] name
|
774
|
+
# The optional record name to query.
|
775
|
+
#
|
776
|
+
# @param [Hash{Symbol => Object}] kwargs
|
777
|
+
# Additional keyword arguments.
|
778
|
+
#
|
779
|
+
# @option [Array<String>, String, nil] :nameservers
|
780
|
+
# Optional DNS nameserver(s) to query.
|
781
|
+
#
|
782
|
+
# @option [String, nil] :nameserver
|
783
|
+
# Optional DNS nameserver to query.
|
784
|
+
#
|
785
|
+
# @return [String, nil]
|
786
|
+
# The first IPv4 address belonging to the host name.
|
787
|
+
#
|
788
|
+
# @see DNS::Resolver#get_a_address
|
789
|
+
#
|
790
|
+
def get_a_address(name=nil,**kwargs)
|
791
|
+
name = if name then "#{name}.#{@name}"
|
792
|
+
else @name
|
793
|
+
end
|
794
|
+
|
795
|
+
DNS.resolver(**kwargs).get_a_address(name)
|
796
|
+
end
|
797
|
+
|
798
|
+
#
|
799
|
+
# Queries all `A` records belonging to the host name.
|
800
|
+
#
|
801
|
+
# @param [String, nil] name
|
802
|
+
# The optional record name to query.
|
803
|
+
#
|
804
|
+
# @param [Hash{Symbol => Object}] kwargs
|
805
|
+
# Additional keyword arguments.
|
806
|
+
#
|
807
|
+
# @option [Array<String>, String, nil] :nameservers
|
808
|
+
# Optional DNS nameserver(s) to query.
|
809
|
+
#
|
810
|
+
# @option [String, nil] :nameserver
|
811
|
+
# Optional DNS nameserver to query.
|
812
|
+
#
|
813
|
+
# @return [Array<Resolv::DNS::Resource::IN::A>]
|
814
|
+
# All of the `A` DNS records belonging to the host name.
|
815
|
+
#
|
816
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/IN/A
|
817
|
+
# @see DNS::Resolver#get_a_records
|
818
|
+
#
|
819
|
+
def get_a_records(name=nil,**kwargs)
|
820
|
+
name = if name then "#{name}.#{@name}"
|
821
|
+
else @name
|
822
|
+
end
|
823
|
+
|
824
|
+
DNS.resolver(**kwargs).get_a_records(name)
|
825
|
+
end
|
826
|
+
|
827
|
+
#
|
828
|
+
# Queries all IPv4 addresses belonging to the host name.
|
829
|
+
#
|
830
|
+
# @param [String, nil] name
|
831
|
+
# The optional record name to query.
|
832
|
+
#
|
833
|
+
# @param [Hash{Symbol => Object}] kwargs
|
834
|
+
# Additional keyword arguments.
|
835
|
+
#
|
836
|
+
# @option [Array<String>, String, nil] :nameservers
|
837
|
+
# Optional DNS nameserver(s) to query.
|
838
|
+
#
|
839
|
+
# @option [String, nil] :nameserver
|
840
|
+
# Optional DNS nameserver to query.
|
841
|
+
#
|
842
|
+
# @return [Array<String>]
|
843
|
+
# All of the IPv4 addresses belonging to the host name.
|
844
|
+
#
|
845
|
+
# @see DNS::Resolver#get_a_addresses
|
846
|
+
#
|
847
|
+
def get_a_addresses(name=nil,**kwargs)
|
848
|
+
name = if name then "#{name}.#{@name}"
|
849
|
+
else @name
|
850
|
+
end
|
851
|
+
|
852
|
+
DNS.resolver(**kwargs).get_a_addresses(name)
|
853
|
+
end
|
854
|
+
|
855
|
+
#
|
856
|
+
# Queries the first `AAAA` DNS records belonging to the host name.
|
857
|
+
#
|
858
|
+
# @param [String, nil] name
|
859
|
+
# The optional record name to query.
|
860
|
+
#
|
861
|
+
# @param [Hash{Symbol => Object}] kwargs
|
862
|
+
# Additional keyword arguments.
|
863
|
+
#
|
864
|
+
# @option [Array<String>, String, nil] :nameservers
|
865
|
+
# Optional DNS nameserver(s) to query.
|
866
|
+
#
|
867
|
+
# @option [String, nil] :nameserver
|
868
|
+
# Optional DNS nameserver to query.
|
869
|
+
#
|
870
|
+
# @return [Resolv::DNS::Resource::IN::AAAA, nil]
|
871
|
+
# The first `AAAA` DNS record or `nil` if the host name has no
|
872
|
+
# `AAAA` records.
|
873
|
+
#
|
874
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/IN/AAAA
|
875
|
+
# @see DNS::Resolver#get_aaaa_record
|
876
|
+
#
|
877
|
+
def get_aaaa_record(name=nil,**kwargs)
|
878
|
+
name = if name then "#{name}.#{@name}"
|
879
|
+
else @name
|
880
|
+
end
|
881
|
+
|
882
|
+
DNS.resolver(**kwargs).get_aaaa_record(name)
|
883
|
+
end
|
884
|
+
|
885
|
+
#
|
886
|
+
# Queries the first IPv6 address belonging to the host name.
|
887
|
+
#
|
888
|
+
# @param [String, nil] name
|
889
|
+
# The optional record name to query.
|
890
|
+
#
|
891
|
+
# @param [Hash{Symbol => Object}] kwargs
|
892
|
+
# Additional keyword arguments.
|
893
|
+
#
|
894
|
+
# @option [Array<String>, String, nil] :nameservers
|
895
|
+
# Optional DNS nameserver(s) to query.
|
896
|
+
#
|
897
|
+
# @option [String, nil] :nameserver
|
898
|
+
# Optional DNS nameserver to query.
|
899
|
+
#
|
900
|
+
# @return [String, nil]
|
901
|
+
# The first IPv6 address or `nil` if the host name has no IPv6
|
902
|
+
# addresses.
|
903
|
+
#
|
904
|
+
# @see DNS::Resolver#get_aaaa_address
|
905
|
+
#
|
906
|
+
def get_aaaa_address(name=nil,**kwargs)
|
907
|
+
name = if name then "#{name}.#{@name}"
|
908
|
+
else @name
|
909
|
+
end
|
910
|
+
|
911
|
+
DNS.resolver(**kwargs).get_aaaa_address(name)
|
912
|
+
end
|
913
|
+
|
914
|
+
#
|
915
|
+
# Queries all `AAAA` DNS records belonging to the host name.
|
916
|
+
#
|
917
|
+
# @param [String, nil] name
|
918
|
+
# The optional record name to query.
|
919
|
+
#
|
920
|
+
# @param [Hash{Symbol => Object}] kwargs
|
921
|
+
# Additional keyword arguments.
|
922
|
+
#
|
923
|
+
# @option [Array<String>, String, nil] :nameservers
|
924
|
+
# Optional DNS nameserver(s) to query.
|
925
|
+
#
|
926
|
+
# @option [String, nil] :nameserver
|
927
|
+
# Optional DNS nameserver to query.
|
928
|
+
#
|
929
|
+
# @return [Array<Resolv::DNS::Resource::IN::AAAA>]
|
930
|
+
# All of the `AAAA` DNS records belonging to the host name.
|
931
|
+
#
|
932
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/IN/AAAA
|
933
|
+
# @see DNS::Resolver#get_aaaa_records
|
934
|
+
#
|
935
|
+
def get_aaaa_records(name=nil,**kwargs)
|
936
|
+
name = if name then "#{name}.#{@name}"
|
937
|
+
else @name
|
938
|
+
end
|
939
|
+
|
940
|
+
DNS.resolver(**kwargs).get_aaaa_records(name)
|
941
|
+
end
|
942
|
+
|
943
|
+
#
|
944
|
+
# Queries all IPv6 addresses belonging to the host name.
|
945
|
+
#
|
946
|
+
# @param [String, nil] name
|
947
|
+
# The optional record name to query.
|
948
|
+
#
|
949
|
+
# @param [Hash{Symbol => Object}] kwargs
|
950
|
+
# Additional keyword arguments.
|
951
|
+
#
|
952
|
+
# @option [Array<String>, String, nil] :nameservers
|
953
|
+
# Optional DNS nameserver(s) to query.
|
954
|
+
#
|
955
|
+
# @option [String, nil] :nameserver
|
956
|
+
# Optional DNS nameserver to query.
|
957
|
+
#
|
958
|
+
# @return [Array<String>]
|
959
|
+
# All IPv6 addresses belonging to the host name.
|
960
|
+
#
|
961
|
+
# @see DNS::Resolver#get_aaaa_addresses
|
962
|
+
#
|
963
|
+
def get_aaaa_addresses(name=nil,**kwargs)
|
964
|
+
name = if name then "#{name}.#{@name}"
|
965
|
+
else @name
|
966
|
+
end
|
967
|
+
|
968
|
+
DNS.resolver(**kwargs).get_aaaa_addresses(name)
|
969
|
+
end
|
970
|
+
|
971
|
+
#
|
972
|
+
# Queries all `SRV` DNS records belonging to the host name.
|
973
|
+
#
|
974
|
+
# @param [String, nil] name
|
975
|
+
# The optional record name to query.
|
976
|
+
#
|
977
|
+
# @param [Hash{Symbol => Object}] kwargs
|
978
|
+
# Additional keyword arguments.
|
979
|
+
#
|
980
|
+
# @option [Array<String>, String, nil] :nameservers
|
981
|
+
# Optional DNS nameserver(s) to query.
|
982
|
+
#
|
983
|
+
# @option [String, nil] :nameserver
|
984
|
+
# Optional DNS nameserver to query.
|
985
|
+
#
|
986
|
+
# @return [Array<Resolv::DNS::Resource::IN::SRV>]
|
987
|
+
# All `SRV` DNS records belonging to the host name.
|
988
|
+
#
|
989
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/IN/SRV
|
990
|
+
# @see DNS::Resolver#get_srv_records
|
991
|
+
#
|
992
|
+
def get_srv_records(name=nil,**kwargs)
|
993
|
+
name = if name then "#{name}.#{@name}"
|
994
|
+
else @name
|
995
|
+
end
|
996
|
+
|
997
|
+
DNS.resolver(**kwargs).get_srv_records(name)
|
998
|
+
end
|
999
|
+
|
1000
|
+
#
|
1001
|
+
# Queries all `WKS` (Well-Known-Service) DNS records belonging to the
|
1002
|
+
# host name.
|
1003
|
+
#
|
1004
|
+
# @param [String, nil] name
|
1005
|
+
# The optional record name to query.
|
1006
|
+
#
|
1007
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1008
|
+
# Additional keyword arguments.
|
1009
|
+
#
|
1010
|
+
# @option [Array<String>, String, nil] :nameservers
|
1011
|
+
# Optional DNS nameserver(s) to query.
|
1012
|
+
#
|
1013
|
+
# @option [String, nil] :nameserver
|
1014
|
+
# Optional DNS nameserver to query.
|
1015
|
+
#
|
1016
|
+
# @return [Array<Resolv::DNS::Resource::IN::WKS>]
|
1017
|
+
# All `WKS` DNS records belonging to the host name.
|
1018
|
+
#
|
1019
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/IN/WKS
|
1020
|
+
# @see DNS::Resolver#get_wks_records
|
1021
|
+
#
|
1022
|
+
def get_wks_records(name=nil,**kwargs)
|
1023
|
+
name = if name then "#{name}.#{@name}"
|
1024
|
+
else @name
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
DNS.resolver(**kwargs).get_wks_records(name)
|
1028
|
+
end
|
1029
|
+
|
1030
|
+
#
|
1031
|
+
# Queries the `LOC` (Location) DNS record of the host name.
|
1032
|
+
#
|
1033
|
+
# @param [String, nil] name
|
1034
|
+
# The optional record name to query.
|
1035
|
+
#
|
1036
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1037
|
+
# Additional keyword arguments.
|
1038
|
+
#
|
1039
|
+
# @option [Array<String>, String, nil] :nameservers
|
1040
|
+
# Optional DNS nameserver(s) to query.
|
1041
|
+
#
|
1042
|
+
# @option [String, nil] :nameserver
|
1043
|
+
# Optional DNS nameserver to query.
|
1044
|
+
#
|
1045
|
+
# @return [Resolv::DNS::Resource::LOC, nil]
|
1046
|
+
# The `LOC` DNS record of the host name or `nil` if the host name
|
1047
|
+
# has no `LOC` record.
|
1048
|
+
#
|
1049
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/LOC
|
1050
|
+
# @see DNS::Resolver#get_loc_record
|
1051
|
+
#
|
1052
|
+
def get_loc_record(name=nil,**kwargs)
|
1053
|
+
name = if name then "#{name}.#{@name}"
|
1054
|
+
else @name
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
DNS.resolver(**kwargs).get_loc_record(name)
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
#
|
1061
|
+
# Queries the `MINFO` (Machine-Info) DNS record of the host name.
|
1062
|
+
#
|
1063
|
+
# @param [String, nil] name
|
1064
|
+
# The optional record name to query.
|
1065
|
+
#
|
1066
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1067
|
+
# Additional keyword arguments.
|
1068
|
+
#
|
1069
|
+
# @option [Array<String>, String, nil] :nameservers
|
1070
|
+
# Optional DNS nameserver(s) to query.
|
1071
|
+
#
|
1072
|
+
# @option [String, nil] :nameserver
|
1073
|
+
# Optional DNS nameserver to query.
|
1074
|
+
#
|
1075
|
+
# @return [Resolv::DNS::Resource::MINFO, nil]
|
1076
|
+
# The `MINFO` DNS record of the host name or `nil` if the host name
|
1077
|
+
# has no `MINFO` record.
|
1078
|
+
#
|
1079
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/MINFO
|
1080
|
+
# @see DNS::Resolver#get_minfo_record
|
1081
|
+
#
|
1082
|
+
def get_minfo_record(name=nil,**kwargs)
|
1083
|
+
name = if name then "#{name}.#{@name}"
|
1084
|
+
else @name
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
DNS.resolver(**kwargs).get_minfo_record(name)
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
#
|
1091
|
+
# Queries all `MX` DNS records belonging to the host name.
|
1092
|
+
#
|
1093
|
+
# @param [String, nil] name
|
1094
|
+
# The optional record name to query.
|
1095
|
+
#
|
1096
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1097
|
+
# Additional keyword arguments.
|
1098
|
+
#
|
1099
|
+
# @option [Array<String>, String, nil] :nameservers
|
1100
|
+
# Optional DNS nameserver(s) to query.
|
1101
|
+
#
|
1102
|
+
# @option [String, nil] :nameserver
|
1103
|
+
# Optional DNS nameserver to query.
|
1104
|
+
#
|
1105
|
+
# @return [Array<Resolv::DNS::Resource::MX>]
|
1106
|
+
# All `MX` DNS records belonging to the host name.
|
1107
|
+
#
|
1108
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/MX
|
1109
|
+
# @see DNS::Resolver#get_mx_records
|
1110
|
+
#
|
1111
|
+
def get_mx_records(name=nil,**kwargs)
|
1112
|
+
name = if name then "#{name}.#{@name}"
|
1113
|
+
else @name
|
1114
|
+
end
|
1115
|
+
|
1116
|
+
DNS.resolver(**kwargs).get_mx_records(name)
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
#
|
1120
|
+
# Queries the mailservers for the host name.
|
1121
|
+
#
|
1122
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1123
|
+
# Additional keyword arguments.
|
1124
|
+
#
|
1125
|
+
# @option [Array<String>, String, nil] :nameservers
|
1126
|
+
# Optional DNS nameserver(s) to query.
|
1127
|
+
#
|
1128
|
+
# @option [String, nil] :nameserver
|
1129
|
+
# Optional DNS nameserver to query.
|
1130
|
+
#
|
1131
|
+
# @return [Array<String>]
|
1132
|
+
# The host names of the mailservers serving the given host name.
|
1133
|
+
#
|
1134
|
+
# @see DNS::Resolver#get_mailservers
|
1135
|
+
#
|
1136
|
+
def get_mailservers(**kwargs)
|
1137
|
+
DNS.resolver(**kwargs).get_mailservers(@name)
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
#
|
1141
|
+
# The mailservers for the host.
|
1142
|
+
#
|
1143
|
+
# @return [Array<String>]
|
1144
|
+
# The mailserver host names for the host.
|
1145
|
+
#
|
1146
|
+
# @note This method returns memoized data.
|
1147
|
+
#
|
1148
|
+
# @see #get_mailservers
|
1149
|
+
#
|
1150
|
+
def mailservers
|
1151
|
+
@mailservers ||= get_mailservers
|
1152
|
+
end
|
1153
|
+
|
1154
|
+
#
|
1155
|
+
# Determines if the hostname has any associated mailservers?
|
1156
|
+
#
|
1157
|
+
# @return [Boolean]
|
1158
|
+
#
|
1159
|
+
def has_mailservers?
|
1160
|
+
!mailservers.empty?
|
1161
|
+
end
|
1162
|
+
|
1163
|
+
#
|
1164
|
+
# Queries all `NS` DNS records belonging to the host name.
|
1165
|
+
#
|
1166
|
+
# @param [String, nil] name
|
1167
|
+
# The optional record name to query.
|
1168
|
+
#
|
1169
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1170
|
+
# Additional keyword arguments.
|
1171
|
+
#
|
1172
|
+
# @option [Array<String>, String, nil] :nameservers
|
1173
|
+
# Optional DNS nameserver(s) to query.
|
1174
|
+
#
|
1175
|
+
# @option [String, nil] :nameserver
|
1176
|
+
# Optional DNS nameserver to query.
|
1177
|
+
#
|
1178
|
+
# @return [Array<Resolv::DNS::Resource::NS>]
|
1179
|
+
# All `NS` DNS records belonging to the host name.
|
1180
|
+
#
|
1181
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/NS
|
1182
|
+
# @see DNS::Resolver#get_ns_records
|
1183
|
+
#
|
1184
|
+
def get_ns_records(name=nil,**kwargs)
|
1185
|
+
name = if name then "#{name}.#{@name}"
|
1186
|
+
else @name
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
DNS.resolver(**kwargs).get_ns_records(name)
|
1190
|
+
end
|
1191
|
+
|
1192
|
+
#
|
1193
|
+
# Queries the nameservers for the host name.
|
1194
|
+
#
|
1195
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1196
|
+
# Additional keyword arguments.
|
1197
|
+
#
|
1198
|
+
# @option [Array<String>, String, nil] :nameservers
|
1199
|
+
# Optional DNS nameserver(s) to query.
|
1200
|
+
#
|
1201
|
+
# @option [String, nil] :nameserver
|
1202
|
+
# Optional DNS nameserver to query.
|
1203
|
+
#
|
1204
|
+
# @return [Array<String>]
|
1205
|
+
# The host names of the nameservers serving the given host name.
|
1206
|
+
#
|
1207
|
+
# @see DNS::Resolver#get_nameservers
|
1208
|
+
#
|
1209
|
+
def get_nameservers(**kwargs)
|
1210
|
+
DNS.resolver(**kwargs).get_nameservers(@name)
|
1211
|
+
end
|
1212
|
+
|
1213
|
+
#
|
1214
|
+
# The nameservers for the host.
|
1215
|
+
#
|
1216
|
+
# @return [Array<String>]
|
1217
|
+
# The nameserver IP addresses for the host.
|
1218
|
+
#
|
1219
|
+
# @note This method returns memoized data.
|
1220
|
+
#
|
1221
|
+
# @see #get_nameservers
|
1222
|
+
#
|
1223
|
+
def nameservers
|
1224
|
+
@nameservers ||= get_nameservers
|
1225
|
+
end
|
1226
|
+
|
1227
|
+
#
|
1228
|
+
# Determines if the hostname has any associated nameservers?
|
1229
|
+
#
|
1230
|
+
# @return [Boolean]
|
1231
|
+
#
|
1232
|
+
def has_nameservers?
|
1233
|
+
!nameservers.empty?
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
#
|
1237
|
+
# Queries the first `SOA` DNS record belonging to the host name.
|
1238
|
+
#
|
1239
|
+
# @param [String, nil] name
|
1240
|
+
# The optional record name to query.
|
1241
|
+
#
|
1242
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1243
|
+
# Additional keyword arguments.
|
1244
|
+
#
|
1245
|
+
# @option [Array<String>, String, nil] :nameservers
|
1246
|
+
# Optional DNS nameserver(s) to query.
|
1247
|
+
#
|
1248
|
+
# @option [String, nil] :nameserver
|
1249
|
+
# Optional DNS nameserver to query.
|
1250
|
+
#
|
1251
|
+
# @return [Resolv::DNS::Resource::SOA, nil]
|
1252
|
+
# The first `SOA` DNS record for the host name or `nil` if the host
|
1253
|
+
# name has no `SOA` records.
|
1254
|
+
#
|
1255
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/SOA
|
1256
|
+
# @see DNS::Resolver#get_soa_record
|
1257
|
+
#
|
1258
|
+
def get_soa_record(name=nil,**kwargs)
|
1259
|
+
name = if name then "#{name}.#{@name}"
|
1260
|
+
else @name
|
1261
|
+
end
|
1262
|
+
|
1263
|
+
DNS.resolver(**kwargs).get_soa_record(name)
|
1264
|
+
end
|
1265
|
+
|
1266
|
+
#
|
1267
|
+
# The `SOA` record for the host.
|
1268
|
+
#
|
1269
|
+
# @return [Resolv::DNS::Resource::SOA, nil]
|
1270
|
+
# The first `SOA` DNS record for the host name or `nil` if the host
|
1271
|
+
# name has no `SOA` records.
|
1272
|
+
#
|
1273
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/SOA
|
1274
|
+
# @see #get_soa_record
|
1275
|
+
#
|
1276
|
+
# @note This method returns memoized data.
|
1277
|
+
#
|
1278
|
+
def soa_record
|
1279
|
+
@soa_record ||= get_soa_record
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
#
|
1283
|
+
# Queiries the first `TXT` DNS record belonging to the host name.
|
1284
|
+
#
|
1285
|
+
# @param [String, nil] name
|
1286
|
+
# The optional record name to query.
|
1287
|
+
#
|
1288
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1289
|
+
# Additional keyword arguments.
|
1290
|
+
#
|
1291
|
+
# @option [Array<String>, String, nil] :nameservers
|
1292
|
+
# Optional DNS nameserver(s) to query.
|
1293
|
+
#
|
1294
|
+
# @option [String, nil] :nameserver
|
1295
|
+
# Optional DNS nameserver to query.
|
1296
|
+
#
|
1297
|
+
# @return [Resolv::DNS::Resource::TXT, nil]
|
1298
|
+
# The first `TXT` DNS record for the host name or `nil` if the host
|
1299
|
+
# name has no `TXT` records.
|
1300
|
+
#
|
1301
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/TXT
|
1302
|
+
# @see DNS::Resolver#get_txt_record
|
1303
|
+
#
|
1304
|
+
def get_txt_record(name=nil,**kwargs)
|
1305
|
+
name = if name then "#{name}.#{@name}"
|
1306
|
+
else @name
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
DNS.resolver(**kwargs).get_txt_record(name)
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
#
|
1313
|
+
# Queries the first `TXT` string belonging to the host name.
|
1314
|
+
#
|
1315
|
+
# @param [String, nil] name
|
1316
|
+
# The optional record name to query.
|
1317
|
+
#
|
1318
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1319
|
+
# Additional keyword arguments.
|
1320
|
+
#
|
1321
|
+
# @option [Array<String>, String, nil] :nameservers
|
1322
|
+
# Optional DNS nameserver(s) to query.
|
1323
|
+
#
|
1324
|
+
# @option [String, nil] :nameserver
|
1325
|
+
# Optional DNS nameserver to query.
|
1326
|
+
#
|
1327
|
+
# @return [String, nil]
|
1328
|
+
# The first `TXT` string belonging to the host name or `nil` if the
|
1329
|
+
# host name has no `TXT` records.
|
1330
|
+
#
|
1331
|
+
# @see DNS::Resolver#get_txt_string
|
1332
|
+
#
|
1333
|
+
def get_txt_string(name=nil,**kwargs)
|
1334
|
+
name = if name then "#{name}.#{@name}"
|
1335
|
+
else @name
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
DNS.resolver(**kwargs).get_txt_string(name)
|
1339
|
+
end
|
1340
|
+
|
1341
|
+
#
|
1342
|
+
# Queries all `TXT` DNS records belonging to the host name.
|
1343
|
+
#
|
1344
|
+
# @param [String, nil] name
|
1345
|
+
# The optional record name to query.
|
1346
|
+
#
|
1347
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1348
|
+
# Additional keyword arguments.
|
1349
|
+
#
|
1350
|
+
# @option [Array<String>, String, nil] :nameservers
|
1351
|
+
# Optional DNS nameserver(s) to query.
|
1352
|
+
#
|
1353
|
+
# @option [String, nil] :nameserver
|
1354
|
+
# Optional DNS nameserver to query.
|
1355
|
+
#
|
1356
|
+
# @return [Array<Resolv::DNS::Resource::TXT>]
|
1357
|
+
# All of the `TXT` DNS records belonging to the host name.
|
1358
|
+
#
|
1359
|
+
# @see https://rubydoc.info/stdlib/resolv/Resolv/DNS/Resource/TXT
|
1360
|
+
# @see DNS::Resolver#get_txt_records
|
1361
|
+
#
|
1362
|
+
def get_txt_records(name=nil,**kwargs)
|
1363
|
+
name = if name then "#{name}.#{@name}"
|
1364
|
+
else @name
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
DNS.resolver(**kwargs).get_txt_records(name)
|
1368
|
+
end
|
1369
|
+
|
1370
|
+
#
|
1371
|
+
# Queries all of the `TXT` string values of the host name.
|
1372
|
+
#
|
1373
|
+
# @param [String, nil] name
|
1374
|
+
# The optional record name to query.
|
1375
|
+
#
|
1376
|
+
# @param [Hash{Symbol => Object}] kwargs
|
1377
|
+
# Additional keyword arguments.
|
1378
|
+
#
|
1379
|
+
# @option [Array<String>, String, nil] :nameservers
|
1380
|
+
# Optional DNS nameserver(s) to query.
|
1381
|
+
#
|
1382
|
+
# @option [String, nil] :nameserver
|
1383
|
+
# Optional DNS nameserver to query.
|
1384
|
+
#
|
1385
|
+
# @return [Array<String>]
|
1386
|
+
# All `TXT` string values belonging of the host name.
|
1387
|
+
#
|
1388
|
+
# @see DNS::Resolver#get_txt_strings
|
1389
|
+
#
|
1390
|
+
def get_txt_strings(name=nil,**kwargs)
|
1391
|
+
name = if name then "#{name}.#{@name}"
|
1392
|
+
else @name
|
1393
|
+
end
|
1394
|
+
|
1395
|
+
DNS.resolver(**kwargs).get_txt_strings(name)
|
1396
|
+
end
|
1397
|
+
|
1398
|
+
#
|
1399
|
+
# The `TXT` strings for the host.
|
1400
|
+
#
|
1401
|
+
# @return [Array<String>]
|
1402
|
+
# All `TXT` string values belonging of the host name.
|
1403
|
+
#
|
1404
|
+
# @note This method returns memoized data.
|
1405
|
+
#
|
1406
|
+
# @see #get_txt_strings
|
1407
|
+
#
|
1408
|
+
def txt_strings
|
1409
|
+
@txt_strings ||= get_txt_strings
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
#
|
1413
|
+
# Determines if the host name is registered.
|
1414
|
+
#
|
1415
|
+
# @return [Boolean]
|
1416
|
+
#
|
1417
|
+
# @note This method will query `8.8.8.8` which supports `ANY` queries.
|
1418
|
+
#
|
1419
|
+
def registered?
|
1420
|
+
!get_any_records(nameserver: '8.8.8.8').empty?
|
1421
|
+
end
|
1422
|
+
|
1423
|
+
#
|
1424
|
+
# Determines if the host name is not registered.
|
1425
|
+
#
|
1426
|
+
# @return [Boolean]
|
1427
|
+
#
|
1428
|
+
# @see #registered?
|
1429
|
+
#
|
1430
|
+
def unregistered?
|
1431
|
+
!registered?
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
#
|
1435
|
+
# Converts the host to a String.
|
1436
|
+
#
|
1437
|
+
# @return [String]
|
1438
|
+
# The host's hostname.
|
1439
|
+
#
|
1440
|
+
# @example
|
1441
|
+
# host = Host.new('www.example.com')
|
1442
|
+
# host.to_s
|
1443
|
+
# # => "www.example.com"
|
1444
|
+
#
|
1445
|
+
def to_s
|
1446
|
+
@name.to_s
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
#
|
1450
|
+
# Converts the host to a String.
|
1451
|
+
#
|
1452
|
+
# @return [String]
|
1453
|
+
#
|
1454
|
+
def to_str
|
1455
|
+
@name.to_str
|
1456
|
+
end
|
1457
|
+
|
1458
|
+
#
|
1459
|
+
# Inspects the host.
|
1460
|
+
#
|
1461
|
+
# @return [String]
|
1462
|
+
# The inspected host object.
|
1463
|
+
#
|
1464
|
+
def inspect
|
1465
|
+
"#<#{self.class}: #{@name}>"
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
end
|
1469
|
+
end
|
1470
|
+
end
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
require 'ronin/support/network/domain'
|