Skip to content

Commit

Permalink
Make winrm protocol options configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
willemm committed Jun 11, 2022
1 parent 4d91010 commit 689d380
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Parameters struct {
Timeout string
Locale string
EnvelopeSize int
RequestOptions map[string]string
TransportDecorator func() Transporter
Dial func(network, addr string) (net.Conn, error)
}
Expand All @@ -23,5 +24,11 @@ func NewParameters(timeout, locale string, envelopeSize int) *Parameters {
Timeout: timeout,
Locale: locale,
EnvelopeSize: envelopeSize,
RequestOptions: map[string]string{
"WINRS_NOPROFILE": "FALSE",
"WINRS_CODEPAGE": "65001",
"WINRS_CONSOLEMODE_STDIN": "TRUE",
"WINRS_SKIP_CMD_SHELL": "FALSE",
},
}
}
8 changes: 4 additions & 4 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func NewOpenShellRequest(uri string, params *Parameters) *soap.SoapMessage {
defaultHeaders(message, uri, params).
Action("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create").
ResourceURI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd").
AddOption(soap.NewHeaderOption("WINRS_NOPROFILE", "TRUE")).
AddOption(soap.NewHeaderOption("WINRS_CODEPAGE", "65001")).
AddOption(soap.NewHeaderOption("WINRS_NOPROFILE", params.RequestOptions["WINRS_NOPROFILE"])).
AddOption(soap.NewHeaderOption("WINRS_CODEPAGE", params.RequestOptions["WINRS_CODEPAGE"])).
Build()

body := message.CreateBodyElement("Shell", soap.DOM_NS_WIN_SHELL)
Expand Down Expand Up @@ -73,8 +73,8 @@ func NewExecuteCommandRequest(uri, shellID, command string, arguments []string,
Action("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command").
ResourceURI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd").
ShellId(shellID).
AddOption(soap.NewHeaderOption("WINRS_CONSOLEMODE_STDIN", "FALSE")).
AddOption(soap.NewHeaderOption("WINRS_SKIP_CMD_SHELL", "FALSE")).
AddOption(soap.NewHeaderOption("WINRS_CONSOLEMODE_STDIN", params.RequestOptions["WINRS_CONSOLEMODE_STDIN"])).
AddOption(soap.NewHeaderOption("WINRS_SKIP_CMD_SHELL", params.RequestOptions["WINRS_SKIP_CMD_SHELL"])).
Build()

body := message.CreateBodyElement("CommandLine", soap.DOM_NS_WIN_SHELL)
Expand Down

0 comments on commit 689d380

Please sign in to comment.