2023-11-18 21:23:29 +03:00
|
|
|
package sshtun
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
|
2023-11-18 21:51:44 +03:00
|
|
|
"github.com/Neur0toxine/sshpoke/pkg/proto/ssh"
|
2023-11-18 21:23:29 +03:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func StdoutPrinterSessionCallback(log *zap.SugaredLogger) SessionCallback {
|
|
|
|
return func(session *ssh.Session) {
|
|
|
|
stdout, err := session.StdoutPipe()
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
scan := bufio.NewScanner(stdout)
|
|
|
|
for scan.Scan() {
|
|
|
|
log.Debug(scan.Text())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-18 23:02:41 +03:00
|
|
|
|
|
|
|
func StdoutPrinterBannerCallback(log *zap.SugaredLogger) ssh.BannerCallback {
|
|
|
|
return func(msg string) error {
|
|
|
|
log.Debug(msg)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|