Class: Ronin::CLI::Commands::Iprange Private

Inherits:
ValueProcessorCommand show all
Defined in:
lib/ronin/cli/commands/iprange.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.

Enumerates over the IP ranges.

Usage

ronin iprange [options] [IP_RANGE ... | --start IP --stop IP]

Options

-f, --file FILE                  Optional file to read values from
    --start IP                   Starting IP address
    --stop IP                    Stopping IP address
-h, --help                       Print help information

Arguments

[IP_RANGE ...] The IP Range to enumerate

Examples

ronin iprange 1.1.1.0/24 ronin iprange 1.1.1.* ronin iprange 1.1.2-4.10-50 ronin iprange --start 1.1.1.10 --stop 1.1.4.100 ronin iprange --file list.txt

Since:

  • 2.0.0

Instance Attribute Summary

Attributes inherited from ValueProcessorCommand

#files

Instance Method Summary collapse

Methods inherited from ValueProcessorCommand

#process_file

Constructor Details

#initialize(**kwargs) ⇒ Iprange

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.

Initializes the ronin iprange command.

Since:

  • 2.0.0



90
91
92
93
94
95
# File 'lib/ronin/cli/commands/iprange.rb', line 90

def initialize(**kwargs)
  super(**kwargs)

  @start = []
  @stop  = []
end

Instance Method Details

#process_value(ip_range) ⇒ 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.

Processes an IP range.

Parameters:

  • ip_range (String)

Since:

  • 2.0.0



127
128
129
130
131
132
133
# File 'lib/ronin/cli/commands/iprange.rb', line 127

def process_value(ip_range)
  ip_range = Support::Network::IPRange.new(ip_range)

  ip_range.each do |ip|
    puts ip
  end
end

#run(*ip_ranges) ⇒ 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.

Runs the ronin iprange command.

Parameters:

  • ip_ranges (Array<String>)

    Optional list of IP ranges to enumerate.

Since:

  • 2.0.0



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/ronin/cli/commands/iprange.rb', line 103

def run(*ip_ranges)
  if !@start.empty? && !@stop.empty?
    unless @start.length == @stop.length
      print_error "must specify an equal number of --start and --stop options"
      exit(-1)
    end

    @start.zip(@stop).each do |(start,stop)|
      range = Support::Network::IPRange::Range.new(start,stop)

      range.each do |ip|
        puts ip
      end
    end
  else
    super(*ip_ranges)
  end
end