Class: OneGadget::Fetchers::Objdump
- Inherits:
-
Object
- Object
- OneGadget::Fetchers::Objdump
- Defined in:
- lib/one_gadget/fetchers/objdump.rb
Overview
Utilities for fetching instructions from libc using objdump.
Instance Method Summary collapse
-
#command(start: nil, stop: nil, extra: []) ⇒ String
The CLI command to be executed.
-
#extra_options=(options) ⇒ void
Set the extra options to be passed to objdump.
-
#initialize(file, arch) ⇒ Objdump
constructor
Instantiate an Objdump object.
-
#read_raw(machine:, endian:, vma:) ⇒ void
Read the file as a raw blob at
vmainstead of as an ELF, for one whose section headers are gone: objdump disassembles sections, and a file with none disassembles to nothing at all.
Constructor Details
#initialize(file, arch) ⇒ Objdump
Instantiate an OneGadget::Fetchers::Objdump object.
16 17 18 19 20 |
# File 'lib/one_gadget/fetchers/objdump.rb', line 16 def initialize(file, arch) @file = file @arch = arch @options = [] end |
Instance Method Details
#command(start: nil, stop: nil, extra: []) ⇒ String
Returns The CLI command to be executed.
46 47 48 49 50 51 52 53 54 |
# File 'lib/one_gadget/fetchers/objdump.rb', line 46 def command(start: nil, stop: nil, extra: []) # --dwarf-start=0 is to make sure `suppress_bfd_header` is true to eliminate the file path in the output, see # issue #204 for more details. # Note: We might need to update this when the objdump act differently in the future. cmd = [bin, '--dwarf-start=0', '--no-show-raw-insn', '-w', *, *@options, *extra, @file] cmd.push('--start-address', start) if start cmd.push('--stop-address', stop) if stop ::Shellwords.join(cmd) end |
#extra_options=(options) ⇒ void
This method returns an undefined value.
Set the extra options to be passed to objdump.
38 39 40 |
# File 'lib/one_gadget/fetchers/objdump.rb', line 38 def () @options = end |
#read_raw(machine:, endian:, vma:) ⇒ void
This method returns an undefined value.
Read the file as a raw blob at vma instead of as an ELF, for one whose
section headers are gone: objdump disassembles sections, and a file with
none disassembles to nothing at all.
29 30 31 |
# File 'lib/one_gadget/fetchers/objdump.rb', line 29 def read_raw(machine:, endian:, vma:) @raw = { machine:, endian:, vma: } end |