Class: Ronin::CLI::Commands::Unhexdump Private
- Inherits:
-
Ronin::CLI::Command
- Object
- Core::CLI::Command
- Ronin::CLI::Command
- Ronin::CLI::Commands::Unhexdump
- Defined in:
- lib/ronin/cli/commands/unhexdump.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.
Decodes a hexdump back into raw data.
Usage
ronin unhexdump [] [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
Constant Summary collapse
- TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Supported types for the
-t,--type
option. [ :int8, :uint8, :char, :uchar, :byte, # default for --format hexdump :int16, :int16_le, :int16_be, :int16_ne, :uint16, :uint16_le, # default for --format od :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 ]
- BASES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{'2' => 2, '8' => 8, '10' => 10, '16' => 16}
- HEXDUMP_PARSER_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Maps command-line options to
Ronin::Support::Binary::Unhexdump::Parser#initialize
keyword arguments. [ :format, :type, :address_base, :base, :named_chars ]
Instance Method Summary collapse
-
#hexdump_parser_options ⇒ Hash{Symbol => Object}
private
Builds a keyword arguments
Hash
of all commandoptions
that will be directly passed toRonin::Support::Binary::Unhexdump::Parser#initialize
. -
#run(file = nil) ⇒ Object
private
Runs the
unhexdump
command.
Instance Method Details
#hexdump_parser_options ⇒ Hash{Symbol => 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.
Builds a keyword arguments Hash
of all command options
that will
be directly passed to
Ronin::Support::Binary::Unhexdump::Parser#initialize
.
205 206 207 208 209 210 211 212 213 |
# File 'lib/ronin/cli/commands/unhexdump.rb', line 205 def kwargs = {} HEXDUMP_PARSER_OPTIONS.each do |key| kwargs[key] = [key] if .has_key?(key) end return kwargs end |
#run(file = nil) ⇒ 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.
Runs the unhexdump
command.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/ronin/cli/commands/unhexdump.rb', line 162 def run(file=nil) parser = Support::Binary::Unhexdump::Parser.new( ** ) 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 [:output] File.binwrite([:output],data) else stdout.write(data) end end |