Land #8763, exploit/multi/handler improvements

ExitOnSession=false && Passive
bug/bundler_fix
William Vu 2017-07-24 17:55:16 -05:00
commit 2d9e14b208
No known key found for this signature in database
GPG Key ID: 68BD00CE25866743
1 changed files with 40 additions and 36 deletions

View File

@ -12,49 +12,53 @@ class MetasploitModule < Msf::Exploit::Remote
# #
def initialize(info = {}) def initialize(info = {})
super(update_info(info, super(
'Name' => 'Generic Payload Handler', update_info(
'Description' => %q{ info,
This module is a stub that provides all of the 'Name' => 'Generic Payload Handler',
features of the Metasploit payload system to exploits 'Description' => %q(
that have been launched outside of the framework. This module is a stub that provides all of the
}, features of the Metasploit payload system to exploits
'License' => MSF_LICENSE, that have been launched outside of the framework.
'Author' => ['hdm'], ),
'References' => [ ], 'License' => MSF_LICENSE,
'Payload' => 'Author' => [ 'hdm', 'bcook-r7' ],
{ 'References' => [ ],
'Space' => 10000000, 'Payload' =>
'BadChars' => '', {
'DisableNops' => true, 'Space' => 10000000,
}, 'BadChars' => '',
'Platform' => %w{ android bsd java js linux osx nodejs php python ruby solaris unix win mainframe multi }, 'DisableNops' => true
'Arch' => ARCH_ALL, },
'Targets' => [ [ 'Wildcard Target', { } ] ], 'Platform' => %w[android bsd java js linux osx nodejs php python ruby solaris unix win mainframe multi],
'DefaultTarget' => 0 'Arch' => ARCH_ALL,
)) 'Targets' => [ [ 'Wildcard Target', {} ] ],
'DefaultTarget' => 0,
'Stance' => Msf::Exploit::Stance::Passive
)
)
register_advanced_options( register_advanced_options(
[ [
OptBool.new("ExitOnSession", [ false, "Return from the exploit after a session has been created", true ]), OptBool.new(
OptInt.new("ListenerTimeout", [ false, "The maximum number of seconds to wait for new sessions", 0]) "ExitOnSession",
]) [ true, "Return from the exploit after a session has been created", false ]
),
OptInt.new(
"ListenerTimeout",
[ false, "The maximum number of seconds to wait for new sessions", 0 ]
)
]
)
end end
def exploit def exploit
if not datastore['ExitOnSession'] and not job_id
fail_with(Failure::Unknown, "Setting ExitOnSession to false requires running as a job (exploit -j)")
end
stime = Time.now.to_f stime = Time.now.to_f
print_status "Starting the payload handler..." timeout = datastore['ListenerTimeout'].to_i
while(true) loop do
break if session_created? and datastore['ExitOnSession'] break if session_created? && datastore['ExitOnSession']
break if ( datastore['ListenerTimeout'].to_i > 0 and (stime + datastore['ListenerTimeout'].to_i < Time.now.to_f) ) break if timeout.positive? && (stime + timeout < Time.now.to_f)
sleep(1)
select(nil,nil,nil,1)
end end
end end
end end