Class: Ronin::CLI::Commands::Bitsquat Private

Inherits:
ValueProcessorCommand show all
Defined in:
lib/ronin/cli/commands/bitsquat.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Finds bit-flips of a domain.

Usage

ronin bitsquat [options] [DOMAIN ...]

Options

-f, --file FILE                  Optional file to read values from
    --has-addresses              Print bitsquat domains with addresses
    --registered                 Print bitsquat domains that are already registered
    --unregistered               Print bitsquat domains that can be registered
-h, --help                       Print help information

Arguments

[DOMAIN ...]                     The domain to bit-flip

Since:

  • 2.0.0

Constant Summary collapse

VALID_HOST_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Regular expression for a valid host name.

Since:

  • 2.0.0

/\A#{Support::Text::Patterns::HOST_NAME}\z/

Instance Attribute Summary

Attributes inherited from ValueProcessorCommand

#files

Instance Method Summary collapse

Methods inherited from ValueProcessorCommand

#initialize, #process_file, #run

Constructor Details

This class inherits a constructor from Ronin::CLI::ValueProcessorCommand

Instance Method Details

#each_bit_squat(domain) {|bitsquat_host| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enumerates over each bitsquat of the domain.

Parameters:

  • domain (String)

    The domain to check for bitsquats.

Yields:

  • (bitsquat_host)

    The given block will be passed each bitsquatted domain variant.

Yield Parameters:

  • bitsquat_host (Ronin::Support::Network::Host)

    A host object for the bitsquatted domain variant.

Since:

  • 2.0.0



106
107
108
109
110
111
112
113
114
# File 'lib/ronin/cli/commands/bitsquat.rb', line 106

def each_bit_squat(domain)
  domain.each_bit_flip do |bit_flipped|
    bit_flipped.force_encoding(Encoding::UTF_8)

    if bit_flipped.valid_encoding? && bit_flipped =~ VALID_HOST_NAME
      yield Support::Network::Host.new(bit_flipped)
    end
  end
end

#process_value(domain) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Queries the bit-flips of a domain.

Parameters:

  • domain (String)

    The string to bit-flip and query.

Since:

  • 2.0.0



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ronin/cli/commands/bitsquat.rb', line 74

def process_value(domain)
  if options[:has_addresses]
    each_bit_squat(domain) do |host|
      puts host if host.has_addresses?
    end
  elsif options[:registered]
    each_bit_squat(domain) do |host|
      puts host if host.registered?
    end
  elsif options[:unregistered]
    each_bit_squat(domain) do |host|
      puts host if host.unregistered?
    end
  else
    each_bit_squat(domain) do |host|
      puts host
    end
  end
end