Class: Ronin::CLI::Commands::Strings Private
- Inherits:
-
FileProcessorCommand
- Object
- Core::CLI::Command
- Ronin::CLI::Command
- FileProcessorCommand
- Ronin::CLI::Commands::Strings
- Includes:
- Ronin::CLI::CharSetOptions
- Defined in:
- lib/ronin/cli/commands/strings.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.
Finds all strings within a file/stream with a certain character set.
Usage
ronin strings [] [FILE ...]
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
-n, --min-length LEN Minimum length of strings to print (Default: 4)
Arguments
[FILE ...] The file(s) to read
Examples
ronin strings --hex -n 32 file.bin
Instance Attribute Summary
Attributes included from Ronin::CLI::CharSetOptions
Instance Method Summary collapse
-
#open_file(file) {|file| ... } ⇒ File?
private
Opens the file in binary mode.
-
#print_buffer(buffer) ⇒ Object
private
Prints a buffer to
STDOUT
. -
#process_input(input) ⇒ Object
private
Scans the input stream for printable strings.
Methods included from Ronin::CLI::CharSetOptions
define_char_sets, included, #initialize
Methods inherited from FileProcessorCommand
Instance Method Details
#open_file(file) {|file| ... } ⇒ File?
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 the file in binary mode.
107 108 109 |
# File 'lib/ronin/cli/commands/strings.rb', line 107 def open_file(file,&block) super(file,'rb',&block) end |
#print_buffer(buffer) ⇒ 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 a buffer to STDOUT
.
139 140 141 142 143 144 145 146 |
# File 'lib/ronin/cli/commands/strings.rb', line 139 def print_buffer(buffer) if [:null_byte] stdout.write(buffer) putc("\0") else puts buffer end end |
#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.
Scans the input stream for printable strings.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/ronin/cli/commands/strings.rb', line 117 def process_input(input) buffer = String.new min_length = [:min_length] input.each_char do |char| if @char_set.include_char?(char) buffer << char else print_buffer(buffer) if buffer.length >= min_length buffer.clear end end # print any remaining chars print_buffer(buffer) if buffer.length >= min_length end |