Initial commit

This commit is contained in:
2022-04-28 20:01:08 +02:00
commit 0873cadc4c
22 changed files with 2642 additions and 0 deletions

41
main.go Normal file
View File

@ -0,0 +1,41 @@
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)
}
}