From 1487ca89237c066dfc07922dbdcc197e64de0680 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 31 Oct 2018 13:21:45 -0500 Subject: [PATCH] Fixed line alignment. New section name is made lowercase to comply with naming standard. --- lib/msf/core/exe/segment_appender.rb | 12 ++++++------ lib/msf/core/exe/segment_injector.rb | 4 ++-- lib/msf/core/payload_generator.rb | 8 ++++---- lib/msf/util/exe.rb | 8 ++++---- msfvenom | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/msf/core/exe/segment_appender.rb b/lib/msf/core/exe/segment_appender.rb index 7a9fdaaebe..8531086bbb 100644 --- a/lib/msf/core/exe/segment_appender.rb +++ b/lib/msf/core/exe/segment_appender.rb @@ -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 diff --git a/lib/msf/core/exe/segment_injector.rb b/lib/msf/core/exe/segment_injector.rb index 6f1bafa080..84b9719149 100644 --- a/lib/msf/core/exe/segment_injector.rb +++ b/lib/msf/core/exe/segment_injector.rb @@ -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}" } diff --git a/lib/msf/core/payload_generator.rb b/lib/msf/core/payload_generator.rb index f704fc7b30..c402583a40 100644 --- a/lib/msf/core/payload_generator.rb +++ b/lib/msf/core/payload_generator.rb @@ -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 diff --git a/lib/msf/util/exe.rb b/lib/msf/util/exe.rb index e561cf3828..87709982b8 100644 --- a/lib/msf/util/exe.rb +++ b/lib/msf/util/exe.rb @@ -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 diff --git a/msfvenom b/msfvenom index 6bab64ffd2..c4bd8161a7 100755 --- a/msfvenom +++ b/msfvenom @@ -97,7 +97,7 @@ def parse_args(args) opts[:encoder] = e end - opt.on('--sec-name ', String, 'The new section name to use when generating Windows binaries. Default: random 4-character alpha string') do |s| + opt.on('--sec-name ', String, 'The new section name to use when generating Windows binaries. Default: random 4-character alpha string') do |s| opts[:secname] = s end