class Ronin::CLI::Commands::Strings
Finds all strings within a file/stream with a certain character set.
## Usage
ronin strings [options] [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
Public Instance Methods
open_file(file,&block)
click to toggle source
Opens the file in binary mode.
@yield [file]
If a block is given, the newly opened file will be yielded. Once the block returns the file will automatically be closed.
@yieldparam [File] file
The newly opened file.
@return [File, nil]
If no block is given, the newly opened file object will be returned. If no block was given, then `nil` will be returned.
Calls superclass method
# File lib/ronin/cli/commands/strings.rb, line 107 def open_file(file,&block) super(file,'rb',&block) end
print_buffer(buffer)
click to toggle source
Prints a buffer to ‘STDOUT`.
@param [String] buffer
# File lib/ronin/cli/commands/strings.rb, line 139 def print_buffer(buffer) if options[:null_byte] stdout.write(buffer) putc("\0") else puts buffer end end
process_input(input)
click to toggle source
Scans the input stream for printable strings.
@param [IO, StringIO] input
The input string.
# File lib/ronin/cli/commands/strings.rb, line 117 def process_input(input) buffer = String.new min_length = options[: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