Class: Ronin::CLI::Commands::Xor Private

Inherits:
StringProcessorCommand show all
Includes:
KeyOptions
Defined in:
lib/ronin/cli/commands/xor.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.

XORs each character of data with a key.

Usage

ronin xor [options] [FILE ...]

Options

-f, --file FILE                  Optional file to process
    --string STRING              Optional string to process
-M, --multiline                  Process each line separately
-n, --keep-newlines              Preserves newlines at the end of each line
-k, --key STRING                 The key String
-K, --key-file FILE              The key file
-h, --help                       Print help information

Arguments

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

Since:

  • 2.0.0

Instance Attribute Summary

Attributes included from KeyOptions

#key

Attributes inherited from StringProcessorCommand

#input_values

Instance Method Summary collapse

Methods included from KeyOptions

included

Methods inherited from StringProcessorCommand

#initialize, #print_string, #process_input

Methods inherited from FileProcessorCommand

#open_file, #process_file, #process_input

Constructor Details

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

Instance Method Details

#process_string(string) ⇒ String

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.

XORs the string.

Parameters:

  • string (String)

    The input string.

Returns:

  • (String)

    The XORed string.

Since:

  • 2.0.0



80
81
82
83
84
85
86
# File 'lib/ronin/cli/commands/xor.rb', line 80

def process_string(string)
  xored_string = Support::Crypto.xor(string,@key)

  # escapes the String if outputing to a TTY
  xored_string = xored_string.dump if stdout.tty?
  return xored_string
end

#run(*files) ⇒ 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 xor command.

Parameters:

  • files (Array<String>)

    Additional files to process.

Since:

  • 2.0.0



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

def run(*files)
  unless @key
    print_error "must specify --key or --key-file"
    exit(-1)
  end

  super(*files)
end