See #667. This adds InitialAutoRunScript support, to be defaulted by browser modules (and others)

git-svn-id: file:///home/svn/framework3/trunk@7904 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2009-12-17 06:00:14 +00:00
parent 5ef4545a1b
commit bcdb44b835
3 changed files with 42 additions and 35 deletions

View File

@ -32,16 +32,11 @@ module Metasploit3
'License' => MSF_LICENSE,
'Session' => Msf::Sessions::Meterpreter_x86_Win))
# Set advanced options
register_advanced_options(
[
OptBool.new('AutoLoadStdapi',
[
true,
"Automatically load the Stdapi extension",
true
]),
OptString.new('AutoRunScript', [false, "Script to autorun on meterpreter session creation", ''])
OptBool.new('AutoLoadStdapi', [true, "Automatically load the Stdapi extension", true]),
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session created (before AutoRunScript)", '']),
OptString.new('AutoRunScript', [false, "A script to automatically on session creation.", ''])
], self.class)
# Don't let people set the library name option
@ -65,12 +60,19 @@ module Metasploit3
session.load_priv
end
end
if (datastore['InitialAutoRunScript'].empty? == false)
client = session
args = datastore['InitialAutoRunScript'].split
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing InitialAutoRunScript '#{datastore['InitialAutoRunScript']}'")
session.execute_script(args.shift, binding)
end
if (datastore['AutoRunScript'].empty? == false)
client = session
args = datastore['AutoRunScript'].split
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing AutoRunScript '#{datastore['AutoRunScript']}'")
session.execute_script(args.shift, binding)
end
end
end
end

View File

@ -33,16 +33,11 @@ module Metasploit3
'License' => MSF_LICENSE,
'Session' => Msf::Sessions::Meterpreter_x86_Win))
# Set advanced options
register_advanced_options(
[
OptBool.new('AutoLoadStdapi',
[
true,
"Automatically load the Stdapi extension",
true
]),
OptString.new('AutoRunScript', [false, "Script to autorun on meterpreter session creation", ''])
OptBool.new('AutoLoadStdapi', [true, "Automatically load the Stdapi extension", true]),
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session created (before AutoRunScript)", '']),
OptString.new('AutoRunScript', [false, "A script to automatically on session creation.", ''])
], self.class)
# Don't let people set the library name option
@ -69,14 +64,21 @@ module Metasploit3
def on_session(session)
super
if (datastore['AutoLoadStdapi'] == true)
session.load_stdapi
session.load_stdapi
if (framework.exploits.create(session.via_exploit).privileged?)
session.load_priv
session.load_priv
end
end
if (datastore['InitialAutoRunScript'].empty? == false)
client = session
args = datastore['InitialAutoRunScript'].split
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing InitialAutoRunScript '#{datastore['InitialAutoRunScript']}'")
session.execute_script(args.shift, binding)
end
if (datastore['AutoRunScript'].empty? == false)
client = session
args = datastore['AutoRunScript'].split
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing AutoRunScript '#{datastore['AutoRunScript']}'")
session.execute_script(args.shift, binding)
end
end

View File

@ -36,14 +36,10 @@ module Metasploit3
register_advanced_options(
[
OptBool.new( 'AutoLoadStdapi',
[
true,
"Automatically load the Stdapi extension",
true
] ),
OptString.new( 'AutoRunScript', [ false, "Script to autorun on meterpreter session creation", '' ] )
], self.class )
OptBool.new('AutoLoadStdapi', [true, "Automatically load the Stdapi extension", true]),
OptString.new('InitialAutoRunScript', [false, "An initial script to run on session created (before AutoRunScript)", '']),
OptString.new('AutoRunScript', [false, "A script to automatically on session creation.", ''])
], self.class)
options.remove_option( 'LibraryName' )
options.remove_option( 'DLL' )
@ -53,18 +49,25 @@ module Metasploit3
File.join( Msf::Config.install_root, "data", "meterpreter", "metsrv.x64.dll" )
end
def on_session( session )
def on_session(session)
super
if( datastore['AutoLoadStdapi'] == true )
session.load_stdapi
if( framework.exploits.create( session.via_exploit ).privileged? )
session.load_priv
if (datastore['AutoLoadStdapi'] == true)
session.load_stdapi
if (framework.exploits.create(session.via_exploit).privileged?)
session.load_priv
end
end
if( datastore['AutoRunScript'].empty? == false )
if (datastore['InitialAutoRunScript'].empty? == false)
client = session
args = datastore['InitialAutoRunScript'].split
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing InitialAutoRunScript '#{datastore['InitialAutoRunScript']}'")
session.execute_script(args.shift, binding)
end
if (datastore['AutoRunScript'].empty? == false)
client = session
args = datastore['AutoRunScript'].split
session.execute_script( args.shift, binding )
print_status("Session ID #{session.sid} (#{session.tunnel_to_s}) processing AutoRunScript '#{datastore['AutoRunScript']}'")
session.execute_script(args.shift, binding)
end
end