Fix circular require

This commit is contained in:
david942j 2018-10-25 06:48:35 -07:00
parent b06d893d21
commit 707aeb73db
6 changed files with 13 additions and 15 deletions

View File

@ -46,8 +46,8 @@ module OneGadget
false
end
# Support instruction set.
# @return [Array<Instruction>] The support instructions.
# Supported instruction set.
# @return [Array<Instruction>] The supported instructions.
def instructions
[
Instruction.new('add', 2),

View File

@ -19,7 +19,7 @@ module OneGadget
true
end
cands + jmp_case_candidates # + sigaction_case_candidates
cands + jmp_case_candidates
end
# find gadgets in form:
@ -30,7 +30,6 @@ module OneGadget
# ...
# call execve
def jmp_case_candidates
bin_sh_hex = str_offset('/bin/sh').to_s(16)
`#{objdump_cmd}|egrep 'rdi.*# #{bin_sh_hex}' -A 3`.split('--').map do |cand|
cand = cand.lines.map(&:strip).reject(&:empty?)
jmp_at = cand.index { |c| c.include?('jmp') }

View File

@ -60,7 +60,7 @@ module OneGadget
return build_not_found if table.nil? # remote doesn't have this one either.
# builds found in remote! Ask update gem and download remote gadgets.
OneGadget::Helper.ask_update(msg: 'The desired one-gadget can be found in lastest version!')
OneGadget::Logger.ask_update(msg: 'The desired one-gadget can be found in lastest version!')
tmp_file = OneGadget::Helper.download_build(table)
require tmp_file.path
tmp_file.unlink

View File

@ -6,7 +6,6 @@ require 'tempfile'
require 'elftools'
require 'one_gadget/error'
require 'one_gadget/logger'
module OneGadget
# Define some helpful methods here.
@ -184,14 +183,6 @@ module OneGadget
nil
end
# Show the message of ask user to update gem.
# @return [void]
def ask_update(msg: '')
name = 'one_gadget'
cmd = colorize("gem update #{name} && gem cleanup #{name}")
OneGadget::Logger.info(msg + "\n" + "Update with: $ #{cmd}" + "\n")
end
# Fetch the file archiecture of +file+.
# @param [String] file The target ELF filename.
# @return [Symbol]

View File

@ -31,6 +31,14 @@ module OneGadget
[]
end
# Show the message of ask user to update gem.
# @return [void]
def ask_update(msg: '')
name = 'one_gadget'
cmd = OneGadget::Helper.colorize("gem update #{name} && gem cleanup #{name}")
OneGadget::Logger.info(msg + "\n" + "Update with: $ #{cmd}" + "\n")
end
%i[info warn error].each do |sym|
define_method(sym) do |msg|
@logger.__send__(sym, msg)

View File

@ -29,7 +29,7 @@ module OneGadget
# show update message
msg = format('A newer version of OneGadget is available (%s --> %s).', OneGadget::VERSION, latest)
OneGadget::Helper.ask_update(msg: msg)
OneGadget::Logger.ask_update(msg: msg)
end
private