class OneGadget::Fetcher::Objdump
Utilities for fetching instructions from libc using objdump.
Public Class Methods
new(file, arch)
click to toggle source
Instantiate an {Objdump} object. @param [String] file Absolute path of target libc. @param [Symbol] arch
The architecture that objdump should support, usually same as the architecture of the target file.
# File lib/one_gadget/fetchers/objdump.rb, line 16 def initialize(file, arch) @file = file @arch = arch @options = [] end
Public Instance Methods
command(start: nil, stop: nil)
click to toggle source
@param [Integer] start The start address to be dumpped from. @param [Integer] stop The end address. @return [String] The CLI
command to be executed.
# File lib/one_gadget/fetchers/objdump.rb, line 33 def command(start: nil, stop: nil) cmd = [bin, '--no-show-raw-insn', '-w', '-d', *@options, @file] cmd.push('--start-address', start) if start cmd.push('--stop-address', stop) if stop ::Shellwords.join(cmd) end
extra_options=(options)
click to toggle source
Set the extra options to be passed to objdump. @param [Array<String>] options The options. @example
objdump.extra_options = %w[-M intel]
# File lib/one_gadget/fetchers/objdump.rb, line 26 def extra_options=(options) @options = options end
Private Instance Methods
bin()
click to toggle source
# File lib/one_gadget/fetchers/objdump.rb, line 42 def bin OneGadget::Helper.find_objdump(@arch).tap do |bin| install_objdump_guide! if bin.nil? end end
install_objdump_guide!()
click to toggle source
# File lib/one_gadget/fetchers/objdump.rb, line 48 def install_objdump_guide! raise Error::UnsupportedArchitectureError, <<-EOS Objdump that supports architecture #{@arch.to_s.inspect} is not found! Please install the package 'binutils-multiarch' and try one_gadget again! For Ubuntu users: $ [sudo] apt install binutils-multiarch EOS end