42 lines
997 B
Go
42 lines
997 B
Go
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)
|
|
}
|
|
}
|