| 1 | //go:build windows |
| 2 | |
| 3 | package persistentshell |
| 4 | |
| 5 | import ( |
| 6 | "net" |
| 7 | "os/exec" |
| 8 | |
| 9 | "github.com/Microsoft/go-winio" |
| 10 | "golang.org/x/sys/windows" |
| 11 | "reasonix/internal/proc" |
| 12 | ) |
| 13 | |
| 14 | func listenShellControl(name string) (net.Listener, error) { |
| 15 | user, err := windows.GetCurrentProcessToken().GetTokenUser() |
| 16 | if err != nil { |
| 17 | return nil, err |
| 18 | } |
| 19 | return winio.ListenPipe(`\\.\pipe\`+name, &winio.PipeConfig{ |
| 20 | SecurityDescriptor: "D:P(A;;GA;;;" + user.User.Sid.String() + ")", InputBufferSize: 65536, OutputBufferSize: 65536, |
| 21 | }) |
| 22 | } |
| 23 | |
| 24 | func startShellTracked(cmd *exec.Cmd) (uintptr, error) { return proc.StartTrackedRequired(cmd) } |
| 25 |