Path: blob/master/modules/exploits/multi/handler.rb
21596 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ManualRanking78#9# This module does basically nothing10# NOTE: Because of this it's missing a disclosure date that makes msftidy angry.11#1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Generic Payload Handler',18'Description' => %q{19This module is a stub that provides all of the20features of the Metasploit payload system to exploits21that have been launched outside of the framework.22},23'License' => MSF_LICENSE,24'Author' => [ 'hdm', 'bcook-r7' ],25'References' => [ ],26'Payload' => {27'Space' => 10000000,28'BadChars' => '',29'DisableNops' => true30},31'Platform' => %w[android apple_ios bsd java js linux osx nodejs php python ruby solaris unix win mainframe multi],32'Arch' => ARCH_ALL,33'Targets' => [ [ 'Wildcard Target', {} ] ],34'DefaultTarget' => 0,35'DefaultOptions' => { 'PAYLOAD' => 'generic/shell_reverse_tcp' },36'Notes' => {37'Reliability' => UNKNOWN_RELIABILITY,38'Stability' => UNKNOWN_STABILITY,39'SideEffects' => UNKNOWN_SIDE_EFFECTS40}41)42)4344register_advanced_options(45[46OptBool.new(47"ExitOnSession",48[ true, "Return from the exploit after a session has been created", true ]49),50OptInt.new(51"ListenerTimeout",52[ false, "The maximum number of seconds to wait for new sessions", 0 ]53)54]55)56end5758def exploit59if datastore['DisablePayloadHandler']60print_error "DisablePayloadHandler is enabled, so there is nothing to do. Exiting!"61return62end6364stime = Time.now.to_f65timeout = datastore['ListenerTimeout'].to_i66loop do67break if session_created? && datastore['ExitOnSession']68break if timeout > 0 && (stime + timeout < Time.now.to_f)6970Rex::ThreadSafe.sleep(1)71end72end73end747576