Module: OneGadget

Defined in:
lib/one_gadget.rb,
lib/one_gadget/abi.rb,
lib/one_gadget/error.rb,
lib/one_gadget/gadget.rb,
lib/one_gadget/helper.rb,
lib/one_gadget/logger.rb,
lib/one_gadget/update.rb,
lib/one_gadget/fetcher.rb,
lib/one_gadget/version.rb,
lib/one_gadget/one_gadget.rb,
lib/one_gadget/fetchers/x86.rb,
lib/one_gadget/emulators/x86.rb,
lib/one_gadget/fetchers/base.rb,
lib/one_gadget/fetchers/i386.rb,
lib/one_gadget/emulators/i386.rb,
lib/one_gadget/fetchers/amd64.rb,
lib/one_gadget/emulators/amd64.rb,
lib/one_gadget/emulators/lambda.rb,
lib/one_gadget/fetchers/aarch64.rb,
lib/one_gadget/emulators/aarch64.rb,
lib/one_gadget/emulators/processor.rb,
lib/one_gadget/emulators/instruction.rb

Overview

Main module.

Defined Under Namespace

Modules: ABI, Emulators, Error, Fetcher, Gadget, Helper, Logger, Update

Constant Summary collapse

VERSION =

Current gem version.

'1.7.1'.freeze

Class Method Summary collapse

Class Method Details

.gadgets(file: nil, build_id: nil, details: false, force_file: false, level: 0) ⇒ Array<OneGadget::Gadget::Gadget>, Array<Integer>

The man entry of gem one_gadget. If want to find gadgets from file, it will search gadgets by its build id first.

Examples:

OneGadget.gadgets(file: './libc.so.6')
OneGadget.gadgets(build_id: '60131540dadc6796cab33388349e6e4e68692053')

30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/one_gadget/one_gadget.rb', line 30

def gadgets(file: nil, build_id: nil, details: false, force_file: false, level: 0)
  ret = if build_id
          OneGadget::Fetcher.from_build_id(build_id) || OneGadget::Logger.not_found(build_id)
        else
          from_file(OneGadget::Helper.abspath(file), force: force_file)
        end
  ret = refine_gadgets(ret, level)
  ret = ret.map(&:offset) unless details
  ret
rescue OneGadget::Error::Error => e
  OneGadget::Logger.error("#{e.class.name.split('::').last}: #{e.message}")
  []
end