Class: Ronin::CLI::Commands::Entropy Private

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

Filters lines by their entropy.

Usage

ronin entropy [options] [FILE ...]

Options

-e, --entropy DEC                Minimum required entropy (Default: 4.0)
-h, --help                       Print help information

Arguments

[FILE ...]                       Optional file(s) to process

Since:

  • 2.0.0

Instance Method Summary collapse

Methods inherited from FileProcessorCommand

#open_file, #process_file, #run

Instance Method Details

#process_input(input) ⇒ 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.

Filters the input stream for high-entropy strings.

Parameters:

  • input (IO, StringIO)

    The input stream to grep.

Since:

  • 2.0.0



62
63
64
65
66
67
68
69
70
# File 'lib/ronin/cli/commands/entropy.rb', line 62

def process_input(input)
  entropy = options[:entropy]

  input.each_line(chomp: true) do |line|
    if Support::Text::Entropy.calculate(line) > entropy
      puts line
    end
  end
end