Class: Ronin::Masscan::CLI::Commands::Convert Private
- Inherits:
-
Ronin::Masscan::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Masscan::CLI::Command
- Ronin::Masscan::CLI::Commands::Convert
- Defined in:
- lib/ronin/masscan/cli/commands/convert.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.
Converts an masscan scan file to JSON or CSV.
Usage
ronin-masscan convert [options] INPUT_FILE [OUTPUT_FILE]
Option
-I binary|list|json|ndjson, The input format
--input-format
-F, --format json|csv The desired output format
-h, --help Print help information
Arguments
INPUT_FILE The input masscan scan file to parse
OUTPUT_FILE The output file
Instance Method Summary collapse
-
#open_masscan_file(path) ⇒ ::Masscan::OutputFile
private
Opens a masscan scan file.
-
#run(input_file, output_file = nil) ⇒ Object
private
Runs the
ronin-masscan convert
command.
Instance Method Details
#open_masscan_file(path) ⇒ ::Masscan::OutputFile
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.
Opens a masscan scan file.
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ronin/masscan/cli/commands/convert.rb', line 118 def open_masscan_file(path) if [:input_format] ::Masscan::OutputFile.new(path, format: [:input_format]) else ::Masscan::OutputFile.new(path) end rescue ArgumentError => error print_error(error.) exit(1) end |
#run(input_file, output_file = nil) ⇒ 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-masscan convert
command.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ronin/masscan/cli/commands/convert.rb', line 83 def run(input_file,output_file=nil) unless File.file?(input_file) print_error "no such file or directory: #{input_file}" exit(-1) end masscan_file = open_masscan_file(input_file) if output_file format = .fetch(:format) do Converter.infer_format_for(output_file) end File.open(output_file,'w') do |output| Converter.convert(masscan_file,output, format: format) end else unless (format = [:format]) print_error "must specify a --format if no output file is given" exit(-1) end Converter.convert(masscan_file,stdout, format: format) end end |