|
|
@ -11,7 +11,6 @@ import (
|
|
|
|
"golang.org/x/crypto/ssh"
|
|
|
|
"golang.org/x/crypto/ssh"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -31,7 +30,7 @@ func init() {
|
|
|
|
cmdSSHJar.Flags().StringVarP(&keyFile, "key", "k", "", "私钥文件")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&keyFile, "key", "k", "", "私钥文件")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&KeyPasswd, "passwd", "p", "", "私钥密码")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&KeyPasswd, "passwd", "p", "", "私钥密码")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&outpath, "output", "o", "", "输出文件")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&outpath, "output", "o", "", "输出文件")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&serverVersion, "version", "v", "OpenSSH", "SSH版本")
|
|
|
|
cmdSSHJar.Flags().StringVarP(&serverVersion, "version", "v", "SSH-2.0-OpenSSH_8.0", "SSH版本")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var cmdSSHJar = &cobra.Command{
|
|
|
|
var cmdSSHJar = &cobra.Command{
|
|
|
@ -64,6 +63,7 @@ func runSSHHoneyJar(listenAddr, keyFile, KeyPasswd, outpath, version string) {
|
|
|
|
data := []string{time.Now().Format("2006-01-02 15:04:05"), c.RemoteAddr().String(), c.User(), string(pass)}
|
|
|
|
data := []string{time.Now().Format("2006-01-02 15:04:05"), c.RemoteAddr().String(), c.User(), string(pass)}
|
|
|
|
if f != nil {
|
|
|
|
if f != nil {
|
|
|
|
conn.Write(data)
|
|
|
|
conn.Write(data)
|
|
|
|
|
|
|
|
conn.Flush()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if curlUrl != "" {
|
|
|
|
if curlUrl != "" {
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
@ -125,16 +125,7 @@ func runSSHHoneyJar(listenAddr, keyFile, KeyPasswd, outpath, version string) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
starlog.Noticeln("SSH HoneyJar is listening on", listenAddr)
|
|
|
|
starlog.Noticeln("SSH HoneyJar is listening on", listenAddr)
|
|
|
|
sig := make(chan os.Signal, 1)
|
|
|
|
|
|
|
|
signal.Notify(sig, os.Interrupt, os.Kill)
|
|
|
|
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
|
|
|
|
case <-sig:
|
|
|
|
|
|
|
|
starlog.Noticef("SSH HoneyJar is shutting down")
|
|
|
|
|
|
|
|
listener.Close()
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
conn, err := listener.Accept()
|
|
|
|
conn, err := listener.Accept()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|