@@ -24,6 +24,7 @@ func dcomCmdInit() {
2424 dcomShellBrowserWindowCmdInit ()
2525 dcomHtafileCmdInit ()
2626 dcomExcelXlmCmdInit ()
27+ dcomVsDteCmdInit ()
2728
2829 dcomCmd .PersistentFlags ().AddFlagSet (defaultAuthFlags .Flags )
2930 dcomCmd .PersistentFlags ().AddFlagSet (defaultLogFlags .Flags )
@@ -34,6 +35,7 @@ func dcomCmdInit() {
3435 dcomShellBrowserWindowCmd ,
3536 dcomHtafileCmd ,
3637 dcomExcelXlmCmd ,
38+ dcomVsDteCmd ,
3739 )
3840}
3941
@@ -134,12 +136,34 @@ func dcomExcelXlmCmdInit() {
134136 dcomExcelXlmCmd .MarkFlagsMutuallyExclusive ("macro" , "macro-file" , "out" )
135137}
136138
139+ func dcomVsDteCmdInit () {
140+ dcomVsDteExecFlags := newFlagSet ("Execution" )
141+ dcomVsDteExecFlags .Flags .StringVar (& dcomVisualStudioDte .CommandName , "vs-command" , "" , "Visual Studio DTE command to execute" )
142+ dcomVsDteExecFlags .Flags .StringVar (& dcomVisualStudioDte .CommandArgs , "vs-args" , "" , "Visual Studio DTE command arguments" )
143+ registerExecutionFlags (dcomVsDteExecFlags .Flags )
144+ registerExecutionOutputFlags (dcomVsDteExecFlags .Flags )
145+
146+ cmdFlags [dcomVsDteCmd ] = []* flagSet {
147+ dcomVsDteExecFlags ,
148+ defaultAuthFlags ,
149+ defaultLogFlags ,
150+ defaultNetRpcFlags ,
151+ }
152+ dcomVsDteCmd .Flags ().AddFlagSet (dcomVsDteExecFlags .Flags )
153+
154+ // Constraints
155+ dcomVsDteCmd .MarkFlagsOneRequired ("command" , "exec" , "vs-command" )
156+ dcomVsDteCmd .MarkFlagsMutuallyExclusive ("command" , "exec" , "vs-command" )
157+ dcomVsDteCmd .MarkFlagsMutuallyExclusive ("vs-command" , "out" )
158+ }
159+
137160var (
138161 dcomMmc = dcomexec.DcomMmc {}
139162 dcomShellWindows = dcomexec.DcomShellWindows {}
140163 dcomShellBrowserWindow = dcomexec.DcomShellBrowserWindow {}
141164 dcomHtafile = dcomexec.DcomHtafile {}
142165 dcomExcelXlm = dcomexec.DcomExcelXlm {}
166+ dcomVisualStudioDte = dcomexec.DcomVisualStudioDte {}
143167
144168 dcomCmd = & cobra.Command {
145169 Use : "dcom" ,
@@ -243,7 +267,7 @@ var (
243267 Short : "Execute with the Excel.Application DCOM object using XLM macros" ,
244268 Long : `Description:
245269 The excel-xlm method uses the exposed Excel.Application DCOM object to call ExecuteExcel4Macro, thus executing
246- XLM macros at will.` ,
270+ XLM macros at will. This method requires that the remote host has Microsoft Excel installed. ` ,
247271 Args : args (argsRpcClient ("host" , "" ), argsOutput ("smb" ),
248272 func (* cobra.Command , []string ) error {
249273 if dcomExcelXlm .MacroFile != "" {
@@ -261,7 +285,7 @@ var (
261285 return nil
262286 },
263287 ),
264- Run : func (cmd * cobra.Command , args []string ) {
288+ Run : func (* cobra.Command , []string ) {
265289 dcomExcelXlm .Client = & rpcClient
266290 ctx := log .With ().Str ("module" , dcomexec .ModuleName ).Str ("method" , dcomexec .MethodExcelXlm ).
267291 Logger ().WithContext (gssapi .NewSecurityContext (context .Background ()))
@@ -271,4 +295,22 @@ var (
271295 }
272296 },
273297 }
298+
299+ dcomVsDteCmd = & cobra.Command {
300+ Use : "vs-dte [target]" ,
301+ Short : "Execute with the VisualStudio.DTE object" ,
302+ Long : `Description:
303+ The vs-dte method uses the exposed VisualStudio.DTE object to spawn a process via the ExecuteCommand method.
304+ This method requires that the remote host has Microsoft Visual Studio installed.` ,
305+ Args : args (argsRpcClient ("host" , "" ), argsOutput ("smb" )),
306+ Run : func (* cobra.Command , []string ) {
307+ dcomVisualStudioDte .Client = & rpcClient
308+ ctx := log .With ().Str ("module" , dcomexec .ModuleName ).Str ("method" , dcomexec .MethodVisualStudioDTE ).
309+ Logger ().WithContext (gssapi .NewSecurityContext (context .Background ()))
310+
311+ if err := goexec .ExecuteCleanMethod (ctx , & dcomVisualStudioDte , & exec ); err != nil {
312+ log .Fatal ().Err (err ).Msg ("Operation failed" )
313+ }
314+ },
315+ }
274316)
0 commit comments