refuse to run with ssh -t or -tt, detect nil runPacket

This commit is contained in:
sawka 2022-06-25 00:30:41 -07:00
parent 935500f1f1
commit fec7721e32

View File

@ -243,6 +243,10 @@ func handleRemote() {
sender.SendErrorPacket(fmt.Sprintf("invalid packet '%s' sent to mshell", pk.GetType()))
return
}
if runPacket == nil {
sender.SendErrorPacket(fmt.Sprintf("no run packet received"))
return
}
cmd, err := shexec.RunCommand(runPacket, sender)
if err != nil {
sender.SendErrorPacket(fmt.Sprintf("error running command: %v", err))
@ -311,6 +315,9 @@ func parseClientOpts() (*shexec.ClientOpts, error) {
opts.SSHOptsTerm = true
break
}
if argStr == "-t" || argStr == "-tt" {
return nil, fmt.Errorf("mshell cannot run over ssh -t")
}
opts.SSHOpts = append(opts.SSHOpts, argStr)
}
if !opts.SSHOptsTerm {