Module: Ronin::CLI::CharSetOptions Private

Included in:
Ronin::CLI::Commands::Bitflip, Ronin::CLI::Commands::Strings
Defined in:
lib/ronin/cli/char_set_options.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds common character set options to a command.

Options

-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

Since:

  • 2.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#char_setChars::CharSet? (readonly)

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.

The set character set.

Returns:

  • (Chars::CharSet, nil)

Since:

  • 2.0.0



179
180
181
# File 'lib/ronin/cli/char_set_options.rb', line 179

def char_set
  @char_set
end

Class Method Details

.define_char_sets(command) ⇒ 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.

Define options for each major character set.

Parameters:

Since:

  • 2.0.0



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/ronin/cli/char_set_options.rb', line 93

def self.define_char_sets(command)
  command.option :numeric, short: '-N',
                           desc: 'Searches for numeric characters (0-9)' do
                             @char_set = Chars::NUMERIC
                           end

  command.option :octal, short: '-O',
                         desc: 'Searches for octal characters (0-7)' do
                           @char_set = Chars::OCTAL
                         end

  command.option :upper_hex, short: '-X',
                             desc: 'Searches for uppercase hexadecimal (0-9, A-F)' do
                               @char_set = Chars::UPPERCASE_HEXADECIMAL
                             end

  command.option :lower_hex, short: '-x',
                             desc: 'Searches for lowercase hexadecimal (0-9, a-f)' do
                               @char_set = Chars::LOWERCASE_HEXADECIMAL
                             end

  command.option :hex, short: '-H',
                       desc: 'Searches for hexadecimal chars (0-9, a-f, A-F)' do
                         @char_set = Chars::HEXADECIMAL
                       end

  command.option :upper_alpha, desc: 'Searches for uppercase alpha chars (A-Z)' do
    @char_set = Chars::UPPERCASE_ALPHA
  end

  command.option :lower_alpha, desc: 'Searches for lowercase alpha chars (a-z)' do
    @char_set = Chars::LOWERCASE_ALPHA
  end

  command.option :alpha, short: '-A',
                         desc: 'Searches for alpha chars (a-z, A-Z)' do
                           @char_set = Chars::ALPHA
                         end

  command.option :alpha_num, desc: 'Searches for alpha-numeric chars (a-z, A-Z, 0-9)' do
    @char_set = Chars::ALPHA_NUMERIC
  end

  command.option :punct, short: '-P',
                         desc: 'Searches for punctuation chars' do
                           @char_set = Chars::PUNCTUATION
                         end

  command.option :symbols, short: '-S',
                           desc: 'Searches for symbolic chars' do
                             @char_set = Chars::SYMBOLS
                           end

  command.option :space, short: '-s',
                         desc: 'Searches for all whitespace chars' do
                           @char_set = Chars::SPACE
                         end

  command.option :visible, short: '-v',
                           desc: 'Searches for all visible chars' do
                             @char_set = Chars::VISIBLE
                           end

  command.option :printable, short: '-p',
                             desc: 'Searches for all printable chars' do
                               @char_set = Chars::PRINTABLE
                             end

  command.option :control, short: '-C',
                           desc: 'Searches for all control chars (\x00-\x1f, \x7f)' do
                             @char_set = Chars::CONTROL
                           end

  command.option :signed_ascii, short: '-a',
                                desc: 'Searches for all signed ASCII chars (\x00-\x7f)' do
                                  @char_set = Chars::SIGNED_ASCII
                                end

  command.option :ascii, desc: 'Searches for all ASCII chars (\x00-\xff)' do
    @char_set = Chars::ASCII
  end
end

.included(command) ⇒ 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.

Adds common character set options to the command.

Parameters:

Since:

  • 2.0.0



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ronin/cli/char_set_options.rb', line 56

def self.included(command)
  define_char_sets(command)

  command.option :chars, short: '-c',
                         value: {
                           type:  String,
                           usage: 'CHARS'
                         },
                         desc: 'Searches for all chars in the custom char-set' do |string|
                           @char_set = Chars::CharSet.new(*string.chars)
                         end

  command.option :include_chars, short: '-i',
                                 value: {
                                   type: String,
                                   usage: 'CHARS'
                                 },
                                 desc: 'Include the additional chars to the char-set' do |string|
                                   @char_set += Chars::CharSet.new(*string.chars)
                                 end

  command.option :exclude_chars, short: '-e',
                                 value: {
                                   type:  String,
                                   usage: 'CHARS'
                                 },
                                 desc: 'Exclude the additional chars from the char-set' do |string|
                                   @char_set -= Chars::CharSet.new(*string.chars)
                                 end
end

Instance Method Details

#initialize(**kwargs) ⇒ 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.

Initializes the command.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.

Since:

  • 2.0.0



187
188
189
190
191
# File 'lib/ronin/cli/char_set_options.rb', line 187

def initialize(**kwargs)
  super(**kwargs)

  @char_set = Chars::VISIBLE
end