CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/msf/core/exploit/remote.rb
Views: 11784
1
module Msf
2
###
3
#
4
# The remote exploit class is a specialization of the exploit module class
5
# that is geared toward exploits that are performed against targets other than
6
# the local machine. This typically implies exploiting other machines via a
7
# network connection, though it is not limited to this scope.
8
#
9
###
10
class Exploit::Remote < Exploit
11
include Msf::Exploit::AutoTarget
12
13
#
14
# Initializes the socket array.
15
#
16
def initialize(info)
17
super
18
19
self.sockets = Array.new
20
end
21
22
#
23
# Returns the fact that this exploit is a remote exploit.
24
#
25
def exploit_type
26
Exploit::Type::Remote
27
end
28
29
#
30
# Adds a socket to the list of sockets opened by this exploit.
31
#
32
def add_socket(sock)
33
self.sockets << sock
34
end
35
36
#
37
# Removes a socket from the list of sockets.
38
#
39
def remove_socket(sock)
40
self.sockets.delete(sock)
41
end
42
43
#
44
# This method is called once a new session has been created on behalf of
45
# this exploit instance and all socket connections created by this
46
# exploit should be closed.
47
#
48
def abort_sockets
49
sockets.delete_if { |sock|
50
51
begin
52
sock.close
53
rescue ::Exception
54
end
55
true
56
}
57
end
58
59
protected
60
61
#
62
# The list of sockets established by this exploit.
63
#
64
attr_accessor :sockets
65
66
end
67
end
68