Class: Ronin::Recon::OutputFormats::Dir

Inherits:
Core::OutputFormats::OutputDir
  • Object
show all
Defined in:
lib/ronin/recon/output_formats/dir.rb

Overview

Represents an output directory.

Constant Summary collapse

VALUE_FILE_NAMES =

Mapping of value classes to file names.

{
  Values::Domain       => 'domains.txt',
  Values::Mailserver   => 'mailservers.txt',
  Values::Nameserver   => 'nameservers.txt',
  Values::Host         => 'hosts.txt',
  Values::Wildcard     => 'wildcards.txt',
  Values::IP           => 'ips.txt',
  Values::IPRange      => 'ip_ranges.txt',
  Values::OpenPort     => 'open_ports.txt',
  Values::Cert         => 'certs.txt',
  Values::EmailAddress => 'email_addresses.txt',
  Values::URL          => 'urls.txt',
  Values::Website      => 'websites.txt'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Dir

Initializes the list output format.

Parameters:

  • path (String)

    The output file path.



61
62
63
64
65
66
67
# File 'lib/ronin/recon/output_formats/dir.rb', line 61

def initialize(path)
  super(path)

  @files = VALUE_FILE_NAMES.transform_values do |file_name|
    File.open(File.join(@path,file_name),'w')
  end
end

Instance Attribute Details

#filesHash{Class<Value> => File} (readonly)

The opened filenames and files within the output directory.

Returns:

  • (Hash{Class<Value> => File})


37
38
39
# File 'lib/ronin/recon/output_formats/dir.rb', line 37

def files
  @files
end

Instance Method Details

#<<(value) ⇒ Object

Writes a new value to it's specific file.

Parameters:

  • value (Value)

    The value to write.



75
76
77
78
79
80
81
82
# File 'lib/ronin/recon/output_formats/dir.rb', line 75

def <<(value)
  file = @files.fetch(value.class) do
    raise(NotImplementedError,"unsupported value class: #{value.inspect}")
  end

  file.puts(value)
  file.flush
end

#closeObject

Closes the output files.



87
88
89
# File 'lib/ronin/recon/output_formats/dir.rb', line 87

def close
  @files.each_value(&:close)
end