Skip to content

Commit 2a9dbb2

Browse files
author
Alexandre Maloteaux
committed
msfvenom and exe-small fmt bug fix
1 parent 42d8173 commit 2a9dbb2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/msf/util/exe.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ def self.to_win32pe_only(framework, code, opts={})
402402

403403
def self.to_win32pe_old(framework, code, opts={})
404404

405+
payload = code.dup
405406
# Allow the user to specify their own EXE template
406407
set_template_default(opts, "template_x86_windows_old.exe")
407408

@@ -410,17 +411,17 @@ def self.to_win32pe_old(framework, code, opts={})
410411
pe = fd.read(fd.stat.size)
411412
}
412413

413-
if(code.length < 2048)
414-
code << Rex::Text.rand_text(2048-code.length)
414+
if(payload.length < 2048)
415+
payload << Rex::Text.rand_text(2048-payload.length)
415416
end
416417

417-
if(code.length > 2048)
418+
if(payload.length > 2048)
418419
raise RuntimeError, "The EXE generator now has a max size of 2048 bytes, please fix the calling module"
419420
end
420421

421422
bo = pe.index('PAYLOAD:')
422423
raise RuntimeError, "Invalid Win32 PE OLD EXE template: missing \"PAYLOAD:\" tag" if not bo
423-
pe[bo, code.length] = code
424+
pe[bo, payload.length] = payload
424425

425426
pe[136, 4] = [rand(0x100000000)].pack('V')
426427

msfvenom

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ if opts[:encode]
376376
if not opts[:iterations]
377377
opts[:iterations] = 1
378378
end
379-
#puts opts[:badchars].inspect
380379

381380
1.upto(opts[:iterations].to_i) do |iteration|
382381
begin
@@ -400,7 +399,7 @@ if opts[:encode]
400399
end
401400
end
402401
next if skip
403-
exe = Msf::Util::EXE.to_executable_fmt($framework, opts[:arch], opts[:platform], payload_raw, opts[:format], exeopts)
402+
404403
rescue ::Errno::ENOENT, ::Errno::EINVAL
405404
print_error("#{enc.refname} failed: #{$!}")
406405
break

0 commit comments

Comments
 (0)