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