This repository has been archived on 2023-07-12. You can view files and clone it, but cannot push or open issues or pull requests.
sshoneypot/main.go

42 lines
997 B
Go
Raw Normal View History

2022-04-28 20:01:08 +02:00
package main
import (
"github.com/bytedream/sshoneypot/sshoneypot"
"github.com/bytedream/sshoneypot/sshoneypot/info"
"golang.org/x/crypto/ssh"
"io/fs"
"io/ioutil"
"os"
)
func main() {
//fmt.Println(strings.Split("/etc/aaa", string(os.PathSeparator))[1:])
/*fs, err := sshoneypot.LoadFSFromJson("fs.json")
if err != nil {
panic(err)
}
if file, ok := fs.GetFile("/etc"); ok {
d, _ := file.(sshoneypot.Directory)
fmt.Println(d.Files)
//fmt.Println(file.(sshoneypot.Directory).Files)
}*/
var key ssh.Signer
if _, err := os.Stat("ssh.key"); os.IsNotExist(err) {
privateKey, _ := sshoneypot.GenerateSSHKey()
ioutil.WriteFile("ssh.key", privateKey, fs.ModePerm)
key, _ = sshoneypot.LoadSSHKey(privateKey)
} else {
key, _ = sshoneypot.LoadSSHKeyFromFile("ssh.key")
}
filesystem, _ := info.LoadFSFromJson("fs.json")
filesystem.Manipulate = true
sshServer := sshoneypot.DefaultSSHoneypot(filesystem, key)
if err := sshServer.Serve(); err != nil {
panic(err)
}
}