core

package
v0.0.0-...-bad515c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteArrayToHex

func ByteArrayToHex(payload []byte) string

ByteArrayToHex converts a set of bytes to a hex encoded string.

func ChangePermissions

func ChangePermissions(name string) (uint32, uint32, error)

ChangePermissions changes the permissions to a specific user. For example, you can supply `nobody` when the server is run so that even if there's a vulnerability and an attacker can escape the sandbox, they won't have any permissions.

func ConnectDB

func ConnectDB(verbose bool) (*gorm.DB, error)

ConnectDB connects to the database and returns the db object.

func GetPasswd

func GetPasswd(name string) (*C.struct_passwd, error)

GetPasswd gets the passwd of a specific user.

func GetSHA3256Hash

func GetSHA3256Hash(str []byte) ([]byte, error)

GetSHA3256Hash returns the SHA3-256 hash of a given string.

func SockAddrToIP

func SockAddrToIP(sock *syscall.Sockaddr) (ip net.IP, port int, success bool)

SockAddrToIP returns the IP address of a sockaddr.

Types

type Encryption

type Encryption struct {
	// contains filtered or unexported fields
}

Encryption is the object that defines an encryption key class.

func (*Encryption) GenerateKey

func (enc *Encryption) GenerateKey() bool

GenerateKey generates a set of public and private keys.

func (*Encryption) GetPrivateKey

func (enc *Encryption) GetPrivateKey() string

GetPrivateKey gets the PEM private key string.

func (*Encryption) GetPublicKey

func (enc *Encryption) GetPublicKey() string

GetPublicKey gets the public PEM key string.

type KeyConnection

type KeyConnection struct {
	gorm.Model
	ID        uint64    `gorm:"primaryKey; autoIncrement; not_null;"` // type:bigint for MySQL
	IPAddress string    `gorm:"index; type:mediumtext not null; unique_index:uidx_key_ip"`
	Username  string    `gorm:"index; not null"`
	Key       string    `gorm:"index; not null"`
	KeyHash   string    `gorm:"index; not null; unique_index:uidx_key_ip"`
	Type      string    `gorm:"not null"`
	CreatedAt time.Time `gorm:"autoCreateTime:milli"`
	UpdatedAt time.Time `gorm:"autoCreateTime:milli"`
}

KeyConnection defines the model that describes the table in which all the usernames and public key that any peer attempts to access the system with will be stored.

type Logman

type Logman struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logman is a struct that handles logging to a file.

func CreateLogmanLogger

func CreateLogmanLogger(fname string) *Logman

CreateLogmanLogger creates a logger.

func GetLogmanInstance

func GetLogmanInstance() *Logman

GetLogmanInstance gets (or create) the instance of the logger.

type PasswordConnection

type PasswordConnection struct {
	gorm.Model
	ID        uint64    `gorm:"primaryKey; autoIncrement; not_null;"` // type:bigint for MySQL
	IPAddress string    `gorm:"index; type:mediumtext not null"`
	Username  string    `gorm:"index; not null"`
	Password  string    `gorm:"index; not null"`
	CreatedAt time.Time `gorm:"autoCreateTime:milli"`
	UpdatedAt time.Time `gorm:"autoCreateTime:milli"`
}

PasswordConnection defines the model that describes the table in which all the usernames and passwords that any peer attempts to access the system with will be stored.

type SSHServer

type SSHServer struct {
	Logger *Logman

	Port    int
	Address string
	Key     string
	Banner  string

	PluginManager *plugin.PluginManager
	// contains filtered or unexported fields
}

SSHServer This is the object that defines an SSH server.

func (*SSHServer) HandleSSHAuth

func (server *SSHServer) HandleSSHAuth(connection *net.Conn) bool

HandleSSHAuth Handles the authentication process, as well as any individual session.

func (*SSHServer) Init

func (server *SSHServer) Init() bool

Init Initializes the SSH server.

func (*SSHServer) ListenLoop

func (server *SSHServer) ListenLoop()

ListenLoop Run the listener for our server.

func (*SSHServer) SetDB

func (server *SSHServer) SetDB(db *gorm.DB)

SetDB sets the database. For some reason this can't be passed in the constructor / initializer, because this error happens: "panic: runtime error: cgo argument has Go pointer to Go pointer".

func (*SSHServer) Stop

func (server *SSHServer) Stop()

Stop will stop the SSH server from running.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL