Skip to content

Commit

Permalink
#163 [SL] - Hide command prompt on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura committed Jul 31, 2024
1 parent 6e35f44 commit 28e1674
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions exec/exec_posix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !windows

package exec

import (
"os/exec"
)

func HideCommandWindow(cmd *exec.Cmd) {}
10 changes: 10 additions & 0 deletions exec/exec_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package exec

import (
"os/exec"
"syscall"
)

func HideCommandWindow(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
3 changes: 3 additions & 0 deletions tor/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
log "github.com/sirupsen/logrus"

"github.com/digitalautonomy/wahay/config"

execUtils "github.com/digitalautonomy/wahay/exec"
)

const libTorsocks = "libtorsocks.so"
Expand Down Expand Up @@ -368,6 +370,7 @@ func (b *binary) start(configFile string) (*runningTor, error) {
// no user input to these
/* #nosec G204 */
cmd := exec.CommandContext(ctx, b.path, "-f", configFile)
execUtils.HideCommandWindow(cmd)

if b.isBundle && len(b.env) > 0 {
log.Debugf("Tor is bundled with environment variables: %s", b.env)
Expand Down
2 changes: 2 additions & 0 deletions tor/facades.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strconv"

"github.com/digitalautonomy/wahay/config"
execUtils "github.com/digitalautonomy/wahay/exec"
"github.com/wybiral/torgo"
"golang.org/x/net/proxy"
)
Expand Down Expand Up @@ -138,6 +139,7 @@ func (*realExecImplementation) ExecWithModify(bin string, args []string, cm Modi
// This executes the tor command, which is under control of the code
/* #nosec G204 */
cmd := exec.Command(bin, args...)
execUtils.HideCommandWindow(cmd)

if cm != nil {
cm(cmd)
Expand Down
2 changes: 2 additions & 0 deletions tor/proxychains_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os/exec"

"github.com/digitalautonomy/wahay/config"
execUtils "github.com/digitalautonomy/wahay/exec"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -35,6 +36,7 @@ func (i *instance) exec(mumbleBinary string, args []string, pre ModifyCommand) (
// This executes the proxychains command, and the args which are both under control of the code
/* #nosec G204 */
cmd := exec.CommandContext(ctx, mainArg, args...)
execUtils.HideCommandWindow(cmd)

if pre != nil {
pre(cmd)
Expand Down

0 comments on commit 28e1674

Please sign in to comment.