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-b9f4589650daunstable
parent
5ef4545a1b
commit
bcdb44b835
|
@ -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,9 +60,16 @@ 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
|
||||
|
|
|
@ -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
|
||||
|
@ -74,9 +69,16 @@ 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
|
||||
|
|
|
@ -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 )
|
||||
if (datastore['AutoLoadStdapi'] == true)
|
||||
session.load_stdapi
|
||||
if( framework.exploits.create( session.via_exploit ).privileged? )
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue