Fixed line alignment. New section name is made lowercase to comply with naming standard.

GSoC/Meterpreter_Web_Console
Patrick 2018-10-31 13:21:45 -05:00 committed by 7043mcgeep
parent 484329f6a0
commit 1487ca8923
5 changed files with 17 additions and 17 deletions

View File

@ -32,13 +32,13 @@ module Exe
# Create a new section
s = Metasm::PE::Section.new
if @secname.blank?
s.name = '.' + Rex::Text.rand_text_alpha_lower(4)
if secname.blank?
s.name = '.' + Rex::Text.rand_text_alpha_lower(4)
else
s.name = '.' + @secname
$stderr.puts "Created custom section \".#{secname}\""
end
s.encoded = payload_stub prefix
s.name = '.' + secname.downcase
$stderr.puts "Created custom section \"#{s.name}\""
end
s.encoded = payload_stub prefix
s.characteristics = %w[MEM_READ MEM_WRITE MEM_EXECUTE]
pe.sections << s

View File

@ -10,14 +10,14 @@ module Exe
attr_accessor :template
attr_accessor :arch
attr_accessor :buffer_register
attr_accessor :secname
attr_accessor :secname
def initialize(opts = {})
@payload = opts[:payload]
@template = opts[:template]
@arch = opts[:arch] || :x86
@buffer_register = opts[:buffer_register]
@secname = opts[:secname]
@secname = opts[:secname]
x86_regs = %w{eax ecx edx ebx edi esi}
x64_regs = %w{rax rcx rdx rbx rdi rsi} + (8..15).map{|n| "r#{n}" }

View File

@ -44,7 +44,7 @@ module Msf
# @!attribute encoder
# @return [String] The encoder(s) you want applied to the payload
attr_accessor :encoder
# @!attribute secname
# @!attribute secname
# @return [String] The name of the new section within the generated Windows binary
attr_accessor :secname
# @!attribute format
@ -104,7 +104,7 @@ module Msf
# @option opts [String] :payload (see #payload)
# @option opts [String] :format (see #format)
# @option opts [String] :encoder (see #encoder)
# @option opts [String] :secname (see #secname)
# @option opts [String] :secname (see #secname)
# @option opts [Integer] :iterations (see #iterations)
# @option opts [String] :arch (see #arch)
# @option opts [String] :platform (see #platform)
@ -128,7 +128,7 @@ module Msf
@cli = opts.fetch(:cli, false)
@datastore = opts.fetch(:datastore, {})
@encoder = opts.fetch(:encoder, '')
@secname = opts.fetch(:secname, '')
@secname = opts.fetch(:secname, '')
@format = opts.fetch(:format, 'raw')
@iterations = opts.fetch(:iterations, 1)
@keep = opts.fetch(:keep, false)
@ -291,7 +291,7 @@ module Msf
opts[:template] = File.basename(template)
end
unless secname.blank?
opts[:secname] = @secname
opts[:secname] = secname
end
opts
end

View File

@ -250,7 +250,7 @@ require 'msf/core/exe/segment_appender'
:payload => code,
:template => opts[:template],
:arch => :x86,
:secname => opts[:secname]
:secname => opts[:secname]
})
return injector.generate_pe
end
@ -272,7 +272,7 @@ require 'msf/core/exe/segment_appender'
:payload => code,
:template => opts[:template],
:arch => :x86,
:secname => opts[:secname]
:secname => opts[:secname]
})
return appender.generate_pe
end
@ -606,7 +606,7 @@ require 'msf/core/exe/segment_appender'
:payload => code,
:template => opts[:template],
:arch => :x64,
:secname => opts[:secname]
:secname => opts[:secname]
})
return injector.generate_pe
end
@ -616,7 +616,7 @@ require 'msf/core/exe/segment_appender'
:payload => code,
:template => opts[:template],
:arch => :x64,
:secname => opts[:secname]
:secname => opts[:secname]
})
return appender.generate_pe
end

View File

@ -97,7 +97,7 @@ def parse_args(args)
opts[:encoder] = e
end
opt.on('--sec-name <value>', String, 'The new section name to use when generating Windows binaries. Default: random 4-character alpha string') do |s|
opt.on('--sec-name <value>', String, 'The new section name to use when generating Windows binaries. Default: random 4-character alpha string') do |s|
opts[:secname] = s
end