Fix circular require
This commit is contained in:
parent
b06d893d21
commit
707aeb73db
|
@ -46,8 +46,8 @@ module OneGadget
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Support instruction set.
|
# Supported instruction set.
|
||||||
# @return [Array<Instruction>] The support instructions.
|
# @return [Array<Instruction>] The supported instructions.
|
||||||
def instructions
|
def instructions
|
||||||
[
|
[
|
||||||
Instruction.new('add', 2),
|
Instruction.new('add', 2),
|
||||||
|
|
|
@ -19,7 +19,7 @@ module OneGadget
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
cands + jmp_case_candidates # + sigaction_case_candidates
|
cands + jmp_case_candidates
|
||||||
end
|
end
|
||||||
|
|
||||||
# find gadgets in form:
|
# find gadgets in form:
|
||||||
|
@ -30,7 +30,6 @@ module OneGadget
|
||||||
# ...
|
# ...
|
||||||
# call execve
|
# call execve
|
||||||
def jmp_case_candidates
|
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|
|
`#{objdump_cmd}|egrep 'rdi.*# #{bin_sh_hex}' -A 3`.split('--').map do |cand|
|
||||||
cand = cand.lines.map(&:strip).reject(&:empty?)
|
cand = cand.lines.map(&:strip).reject(&:empty?)
|
||||||
jmp_at = cand.index { |c| c.include?('jmp') }
|
jmp_at = cand.index { |c| c.include?('jmp') }
|
||||||
|
|
|
@ -60,7 +60,7 @@ module OneGadget
|
||||||
return build_not_found if table.nil? # remote doesn't have this one either.
|
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.
|
# 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)
|
tmp_file = OneGadget::Helper.download_build(table)
|
||||||
require tmp_file.path
|
require tmp_file.path
|
||||||
tmp_file.unlink
|
tmp_file.unlink
|
||||||
|
|
|
@ -6,7 +6,6 @@ require 'tempfile'
|
||||||
require 'elftools'
|
require 'elftools'
|
||||||
|
|
||||||
require 'one_gadget/error'
|
require 'one_gadget/error'
|
||||||
require 'one_gadget/logger'
|
|
||||||
|
|
||||||
module OneGadget
|
module OneGadget
|
||||||
# Define some helpful methods here.
|
# Define some helpful methods here.
|
||||||
|
@ -184,14 +183,6 @@ module OneGadget
|
||||||
nil
|
nil
|
||||||
end
|
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+.
|
# Fetch the file archiecture of +file+.
|
||||||
# @param [String] file The target ELF filename.
|
# @param [String] file The target ELF filename.
|
||||||
# @return [Symbol]
|
# @return [Symbol]
|
||||||
|
|
|
@ -31,6 +31,14 @@ module OneGadget
|
||||||
[]
|
[]
|
||||||
end
|
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|
|
%i[info warn error].each do |sym|
|
||||||
define_method(sym) do |msg|
|
define_method(sym) do |msg|
|
||||||
@logger.__send__(sym, msg)
|
@logger.__send__(sym, msg)
|
||||||
|
|
|
@ -29,7 +29,7 @@ module OneGadget
|
||||||
|
|
||||||
# show update message
|
# show update message
|
||||||
msg = format('A newer version of OneGadget is available (%s --> %s).', OneGadget::VERSION, latest)
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in New Issue