Class: Ronin::CLI::Commands::Bitflip Private

Inherits:
ValueProcessorCommand show all
Includes:
Ronin::CLI::CharSetOptions
Defined in:
lib/ronin/cli/commands/bitflip.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.

Prints every bit-flip of the given string(s).

Usage

ronin bitflip [options] [STRING ...]

Options

-f, --file FILE                  Optional file to read values from
-N, --numeric                    Searches for numeric characters (0-9)
-O, --octal                      Searches for octal characters (0-7)
-X, --upper-hex                  Searches for uppercase hexadecimal (0-9, A-F)
-x, --lower-hex                  Searches for lowercase hexadecimal (0-9, a-f)
-H, --hex                        Searches for hexadecimal chars (0-9, a-f, A-F)
    --upper-alpha                Searches for uppercase alpha chars (A-Z)
    --lower-alpha                Searches for lowercase alpha chars (a-z)
-A, --alpha                      Searches for alpha chars (a-z, A-Z)
    --alpha-num                  Searches for alpha-numeric chars (a-z, A-Z, 0-9)
-P, --punct                      Searches for punctuation chars
-S, --symbols                    Searches for symbolic chars
-s, --space                      Searches for all whitespace chars
-v, --visible                    Searches for all visible chars
-p, --printable                  Searches for all printable chars
-C, --control                    Searches for all control chars (\x00-\x1f, \x7f)
-a, --signed-ascii               Searches for all signed ASCII chars (\x00-\x7f)
    --ascii                      Searches for all ASCII chars (\x00-\xff)
-c, --chars CHARS                Searches for all chars in the custom char-set
-i, --include-chars CHARS        Include the additional chars to the char-set
-e, --exclude-chars CHARS        Exclude the additional chars from the char-set
    --prepend STRING             Prepends the given string to each output
    --append STRING              Appends the given string to each output
-h, --help                       Print help information

Arguments

[STRING ...]                     The string(s) to bit-flip.

Examples

ronin bitflip --prepend www --append .com microsoft

Since:

  • 2.0.0

Instance Attribute Summary

Attributes included from Ronin::CLI::CharSetOptions

#char_set

Attributes inherited from ValueProcessorCommand

#files

Instance Method Summary collapse

Methods included from Ronin::CLI::CharSetOptions

define_char_sets, included, #initialize

Methods inherited from ValueProcessorCommand

#initialize, #process_file, #run

Instance Method Details

#format_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.

Formats a bit-flipped string.

Parameters:

  • string (String)

    The bit-flipped String.

Returns:

  • (String)

    The formatted bit-flipped String.

Since:

  • 2.0.0



119
120
121
122
123
124
125
126
127
128
# File 'lib/ronin/cli/commands/bitflip.rb', line 119

def format_string(string)
  string.prepend(options[:prepend]) if options[:prepend]
  string.concat(options[:append])   if options[:append]

  if string =~ /\A[[:print:]]+\z/
    string
  else
    Support::Encoding::Hex.escape(string)
  end
end

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

Prints every bit-flip of a given String.

Parameters:

  • string (String)

Since:

  • 2.0.0



102
103
104
105
106
107
108
# File 'lib/ronin/cli/commands/bitflip.rb', line 102

def process_value(string)
  string.each_bit_flip do |bit_flipped|
    if @char_set =~ bit_flipped
      puts format_string(bit_flipped)
    end
  end
end