diff --git a/src/prompt/completer.go b/src/prompt/completer.go index 950966e..4cfad27 100644 --- a/src/prompt/completer.go +++ b/src/prompt/completer.go @@ -25,6 +25,7 @@ var optionsSubCommand = []prompt.Suggest{ {Text: "debug", Description: "Manage debug option"}, {Text: "port", Description: "Manage port listener option"}, {Text: "conpty", Description: "Manage conpty option"}, + {Text: "raw", Description: "Manage the activation of raw terminal"}, } var conptySubCommand = []prompt.Suggest{ diff --git a/src/prompt/helper.go b/src/prompt/helper.go index 1cff93c..b30b329 100644 --- a/src/prompt/helper.go +++ b/src/prompt/helper.go @@ -15,6 +15,7 @@ func helpConnect() { func helpOptions() { fmt.Println(`debug: enable/disable debug output port: update listener port +raw: true (default) the terminal will be set to raw mode. Otherwise will stay in cooked mode conpty disableconpty: In the case of conpty causing issue on your reverse shell you could disable it but your reverse shell will not be interactive onlywebserver: if you have already a powershell commande execution you can use this option to serve the ConPty scripts and get your interactive reverse shell`) diff --git a/src/prompt/prompt.go b/src/prompt/prompt.go index fa13589..2d144a3 100644 --- a/src/prompt/prompt.go +++ b/src/prompt/prompt.go @@ -65,6 +65,12 @@ func executor(in string) { } else { sessions.PrintPortOptions() } + case "raw": + if len(command) > 2 { + sessions.SetRaw(command[2]) + } else { + sessions.PrintRawOptions() + } case "conpty": if len(command) > 2 { third := command[2] diff --git a/src/sessions/sessions.go b/src/sessions/sessions.go index fea113a..fbd3bbc 100644 --- a/src/sessions/sessions.go +++ b/src/sessions/sessions.go @@ -10,8 +10,8 @@ import ( logging "github.com/op/go-logging" ) -// OptionsSession contains the option of the futur terminal and the listener -var OptionsSession terminal.Options +// OptionsSession contains the option of the futur terminal and the listener. Default enable the terminal to be set in raw mode +var OptionsSession = terminal.Options{Raw: true} // PrintSessions will list all active sessions func PrintSessions() { @@ -89,6 +89,17 @@ func SetPort(portString string) { } } +// SetRaw update the option Raw +func SetRaw(rawString string) { + if raw, err := strconv.ParseBool(rawString); err == nil { + OptionsSession.Raw = raw + PrintRawOptions() + Restart() + } else { + log.Error("Raw option " + rawString + " invalid") + } +} + // SetDisableConPTY update the option DisableConPTY func SetDisableConPTY(disableConPTYString string) { if disableConPTY, err := strconv.ParseBool(disableConPTYString); err == nil { @@ -125,6 +136,11 @@ func PrintPortOptions() { fmt.Println("Port => " + strconv.Itoa(OptionsSession.Port)) } +// PrintRawOptions print the value of Raw options +func PrintRawOptions() { + fmt.Println("Raw => " + strconv.FormatBool(OptionsSession.Raw)) +} + // PrintDisableConPTYOptions print the value of DisableConPTY options func PrintDisableConPTYOptions() { fmt.Println("DisableConPTY => " + strconv.FormatBool(OptionsSession.DisableConPTY)) @@ -139,6 +155,7 @@ func PrintOnlyWebserverOptions() { func PrintOptions() { PrintDebugOptions() PrintPortOptions() + PrintRawOptions() PrintDisableConPTYOptions() PrintOnlyWebserverOptions() } diff --git a/src/terminal/terminal.go b/src/terminal/terminal.go index c7cff39..3b50402 100644 --- a/src/terminal/terminal.go +++ b/src/terminal/terminal.go @@ -30,6 +30,7 @@ type Options struct { Debug bool DisableConPTY bool OnlyWebserver bool + Raw bool } // New will initialize the logging configuration and start the listener and wait for client. @@ -139,7 +140,7 @@ func (terminal *Terminal) Connect() int { } // The terminal is natively in raw mode with go-prompt, we need to disable the raw mode when this is not necessary // If the client is windows OS and we disable ConPTY, the raw mode is not needed - if terminal.OS == "windows" && terminal.Options.DisableConPTY { + if !terminal.Options.Raw || (terminal.OS == "windows" && terminal.Options.DisableConPTY) { terminal.sttyRawEcho("disable") }