diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/main.go b/main.go index 2928196..2ebc6fa 100644 --- a/main.go +++ b/main.go @@ -56,18 +56,27 @@ func handleConnection(s ssh.Session) { var char string // read until ENTER is pressed - for char != "\x0d"{ + for char != "\x0d" { // read the char inserted by the user into the buffer _, readErr = s.Read(buf) + if len(bytes.Trim(buf, "\x00")) == 0 { + buf[0] = []byte("\x108\x105")[0] + } + // trim the char and append it to the commandBuffer - char1 := bytes.Trim(buf, "\x00")[0] - if char1 == []byte("\x03")[0] { + currentChar := bytes.Trim(buf, "\x00")[0] + log.Println(currentChar) + + // if <C-c> ist pressed, close the connection + if currentChar == []byte("\x03")[0] { s.Close() return } - commandBuffer = append(commandBuffer, char1) + + // append the current char to the command buffer + commandBuffer = append(commandBuffer, currentChar) // write the char to stdout char = string(bytes.Trim(buf, "\x00")) @@ -113,4 +122,3 @@ func handlePass(ctx ssh.Context, pass string) bool { func metricsHandler(w http.ResponseWriter, req *http.Request) { fmt.Fprintf(w, "num_passwords %d\n", metrics_num_passwords) } - |