CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/net/winrm/ctrl_c.rb
Views: 1904
1
# WSMV message to send a Ctrl+C signal to a remote shell
2
require 'winrm/wsmv/base'
3
module Net
4
module MsfWinRM
5
# A WinRM Ctrl+C signal message
6
class CtrlC < WinRM::WSMV::Base
7
def initialize(session_opts, opts)
8
raise 'opts[:shell_id] is required' unless opts[:shell_id]
9
raise 'opts[:command_id] is required' unless opts[:command_id]
10
11
super()
12
13
@session_opts = session_opts
14
@shell_id = opts[:shell_id]
15
@command_id = opts[:command_id]
16
@shell_uri = opts[:shell_uri] || RESOURCE_URI_CMD
17
end
18
19
protected
20
21
def create_header(header)
22
header << Gyoku.xml(ctrl_c_header)
23
end
24
25
def create_body(body)
26
body.tag!("#{NS_WIN_SHELL}:Signal", 'CommandId' => @command_id) do |cl|
27
cl << Gyoku.xml(ctrl_c_body)
28
end
29
end
30
31
private
32
33
def ctrl_c_header
34
merge_headers(shared_headers(@session_opts),
35
resource_uri_shell(@shell_uri),
36
action_signal,
37
selector_shell_id(@shell_id))
38
end
39
40
def ctrl_c_body
41
{
42
"#{NS_WIN_SHELL}:Code" =>
43
'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/signal/ctrl_c'
44
}
45
end
46
end
47
end
48
end
49
50