Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/multi/handler.rb
21596 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = ManualRanking
8
9
#
10
# This module does basically nothing
11
# NOTE: Because of this it's missing a disclosure date that makes msftidy angry.
12
#
13
14
def initialize(info = {})
15
super(
16
update_info(
17
info,
18
'Name' => 'Generic Payload Handler',
19
'Description' => %q{
20
This module is a stub that provides all of the
21
features of the Metasploit payload system to exploits
22
that have been launched outside of the framework.
23
},
24
'License' => MSF_LICENSE,
25
'Author' => [ 'hdm', 'bcook-r7' ],
26
'References' => [ ],
27
'Payload' => {
28
'Space' => 10000000,
29
'BadChars' => '',
30
'DisableNops' => true
31
},
32
'Platform' => %w[android apple_ios bsd java js linux osx nodejs php python ruby solaris unix win mainframe multi],
33
'Arch' => ARCH_ALL,
34
'Targets' => [ [ 'Wildcard Target', {} ] ],
35
'DefaultTarget' => 0,
36
'DefaultOptions' => { 'PAYLOAD' => 'generic/shell_reverse_tcp' },
37
'Notes' => {
38
'Reliability' => UNKNOWN_RELIABILITY,
39
'Stability' => UNKNOWN_STABILITY,
40
'SideEffects' => UNKNOWN_SIDE_EFFECTS
41
}
42
)
43
)
44
45
register_advanced_options(
46
[
47
OptBool.new(
48
"ExitOnSession",
49
[ true, "Return from the exploit after a session has been created", true ]
50
),
51
OptInt.new(
52
"ListenerTimeout",
53
[ false, "The maximum number of seconds to wait for new sessions", 0 ]
54
)
55
]
56
)
57
end
58
59
def exploit
60
if datastore['DisablePayloadHandler']
61
print_error "DisablePayloadHandler is enabled, so there is nothing to do. Exiting!"
62
return
63
end
64
65
stime = Time.now.to_f
66
timeout = datastore['ListenerTimeout'].to_i
67
loop do
68
break if session_created? && datastore['ExitOnSession']
69
break if timeout > 0 && (stime + timeout < Time.now.to_f)
70
71
Rex::ThreadSafe.sleep(1)
72
end
73
end
74
end
75
76