class Ronin::CLI::Commands::Unhexdump
Decodes a hexdump back into raw data.
## Usage
ronin unhexdump [options] [FILE]
## Options
-o, --output FILE Optional output file -f, --format hexdump|od Format of the hexdump input (Default: hexdump) -t int8|uint8|char|uchar|byte|int16|int16_le|int16_be|int16_ne|uint16|uint16_le|uint16_be|uint16_ne|short|short_le|short_be|short_ne|ushort|ushort_le|ushort_be|ushort_ne|int32|int32_le|int32_be|int32_ne|uint32|uint32_le|uint32_be|uint32_ne|int|long|long_le|long_be|long_ne|uint|ulong|ulong_le|ulong_be|ulong_ne|int64|int64_le|int64_be|int64_ne|uint64|uint64_le|uint64_be|uint64_ne|long_long|long_long_le|long_long_be|long_long_ne|ulong_long|ulong_long_le|ulong_long_be|ulong_long_ne|float|float_le|float_be|float_ne|double|double_le|double_be|double_ne, --type The binary data type to decode the data as -b, --base 2|8|10|16 Numerical base of the hexdumped numbers -A, --address-base 2|8|10|16 Numerical base of the address column --[no-]named-chars Enables parsing of od-style named charactters -h, --help Print help information
## Arguments
[FILE] Optional file to unhexdump
Constants
- BASES
- HEXDUMP_PARSER_OPTIONS
Maps command-line options to ‘Ronin::Support::Binary::Unhexdump::Parser#initialize` keyword arguments.
- TYPES
Supported types for the ‘-t,–type` option.
Public Instance Methods
hexdump_parser_options()
click to toggle source
Builds a keyword arguments ‘Hash` of all command `options` that will be directly passed to `Ronin::Support::Binary::Unhexdump::Parser#initialize`.
@return [Hash{Symbol => Object}]
# File lib/ronin/cli/commands/unhexdump.rb, line 205 def hexdump_parser_options kwargs = {} HEXDUMP_PARSER_OPTIONS.each do |key| kwargs[key] = options[key] if options.has_key?(key) end return kwargs end
run(file=nil)
click to toggle source
Runs the ‘unhexdump` command.
@param [String, nil] file
Optional input file.
# File lib/ronin/cli/commands/unhexdump.rb, line 162 def run(file=nil) parser = Support::Binary::Unhexdump::Parser.new( **hexdump_parser_options ) input = if file begin File.open(file) rescue Errno::ENOENT print_error "no such file or directory: #{file}" exit(1) end else stdin end data = parser.unhexdump(input) if options[:output] File.binwrite(options[:output],data) else stdout.write(data) end end