Initial commit
This commit is contained in:
41
main.go
Normal file
41
main.go
Normal 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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user