configs

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Sqlite - SQLite protocol
	Sqlite = "sqlite3"
	// Postgres - Postgresql protocol
	Postgres = "postgresql"
	// MySQL - MySQL protocol
	MySQL = "mysql"
)

Variables

View Source
var (
	ServerConfigFileName        = "config.yaml"
	ServerRootPath              = filepath.Join(GetWorkDir(), ".malice")
	CurrentServerConfigFilename = "config.yaml"
	ContextPath                 = filepath.Join(ServerRootPath, "context")
	LogPath                     = filepath.Join(ServerRootPath, "log")
	CertsPath                   = filepath.Join(ServerRootPath, "certs")
	ListenerPath                = filepath.Join(ServerRootPath, "listener")
	TempPath                    = filepath.Join(ServerRootPath, "temp")
	PluginPath                  = filepath.Join(ServerRootPath, "plugins")
	AuditPath                   = filepath.Join(ServerRootPath, "audit")
	ErrNoConfig                 = errors.New("no config found")
	WebsitePath                 = filepath.Join(ServerRootPath, "web")
	ProfilePath                 = filepath.Join(ServerRootPath, "profile")
	// variables for implant build
	BuildPath       = filepath.Join(GetWorkDir(), "..", "malefic", "build")
	BinPath         = filepath.Join(ServerRootPath, "bin")
	SourceCodePath  = filepath.Join(BuildPath, "src")
	ResourcePath    = filepath.Join(SourceCodePath, "resources")
	TargetPath      = filepath.Join(SourceCodePath, "target")
	CargoCachePath  = filepath.Join(BuildPath, "cache")
	BuildOutputPath = filepath.Join(BuildPath, "output")
)
View Source
var (
	// ErrInvalidDialect - An invalid dialect was specified
	ErrInvalidDialect = errors.New("invalid SQL Dialect")
)
View Source
var ListenerConfigFileName = "listener.yaml"

Functions

func FindConfig added in v0.1.1

func FindConfig(filename string) string

func GetCertDir added in v0.0.3

func GetCertDir() string

func GetRandomID added in v0.0.3

func GetRandomID() string

func GetWorkDir added in v0.0.3

func GetWorkDir() string

func InitConfig

func InitConfig() error

func JoinStringSlice added in v0.0.3

func JoinStringSlice(slice []string) string

JoinStringSlice Helper function to join string slices

func LoadMiscConfig

func LoadMiscConfig() ([]byte, []byte, error)

func NewCrypto added in v0.1.0

func NewCrypto(es []*clientpb.Encryption) ([]cryptostream.Cryptor, error)

func NewDebugLog

func NewDebugLog(filename string) *logs.Logger

func NewFileLog

func NewFileLog(filename string) *logs.Logger

func UpdateGithubConfig added in v0.1.0

func UpdateGithubConfig(g *GithubConfig) error

func UpdateNotifyConfig added in v0.1.0

func UpdateNotifyConfig(n *NotifyConfig) error

func UpdateSaasConfig added in v0.1.1

func UpdateSaasConfig(n *SaasConfig) error

Types

type AutoBuildConfig added in v0.1.0

type AutoBuildConfig struct {
	Enable     bool     `config:"enable" default:"false"`
	BuildPulse bool     `config:"build_pulse" default:"false"`
	Target     []string `config:"target" default:""`
	Pipeline   []string `config:"pipeline" default:""`
}

type BindPipelineConfig added in v0.0.3

type BindPipelineConfig struct {
	Enable           bool                    `config:"enable" default:"true"`
	Name             string                  `config:"name" default:"bind"`
	TlsConfig        *TlsConfig              `config:"tls"`
	EncryptionConfig types.EncryptionsConfig `config:"encryption"`
}

func (*BindPipelineConfig) ToProtobuf added in v0.0.3

func (pipeline *BindPipelineConfig) ToProtobuf(lisId string) (*clientpb.Pipeline, error)

type CertConfig added in v0.0.3

type CertConfig struct {
	*types.CertConfig
	Ca     *types.CertConfig
	Enable bool `yaml:"enable"`
}

func (*CertConfig) ToProtobuf added in v0.0.3

func (t *CertConfig) ToProtobuf() *clientpb.TLS

type DatabaseConfig

type DatabaseConfig struct {
	Dialect  string `json:"dialect"`
	Database string `json:"database"`
	Username string `json:"username"`
	Password string `json:"password"`
	Host     string `json:"host"`
	Port     uint16 `json:"port"`

	Params map[string]string `json:"params"`

	MaxIdleConns int `json:"max_idle_conns"`
	MaxOpenConns int `json:"max_open_conns"`

	LogLevel string `json:"log_level"`
}

DatabaseConfig - Server config

func GetDatabaseConfig

func GetDatabaseConfig() *DatabaseConfig

GetDatabaseConfig - Get config value

func (*DatabaseConfig) DSN

func (c *DatabaseConfig) DSN() (string, error)

DSN - Get the db connections string https://github.com/go-sql-driver/mysql#examples

func (*DatabaseConfig) Save added in v0.0.2

func (c *DatabaseConfig) Save() error

Save - Save config file to disk

type DingTalkConfig added in v0.1.0

type DingTalkConfig struct {
	Enable bool   `config:"enable" default:"false"`
	Secret string `config:"secret"`
	Token  string `config:"token"`
}

type GithubConfig added in v0.1.0

type GithubConfig struct {
	Repo     string `config:"repo" default:"malefic"`
	Owner    string `config:"owner" default:""`
	Token    string `config:"token" default:""`
	Workflow string `config:"workflow" default:"generate.yaml"`
}

func GetGithubConfig added in v0.1.0

func GetGithubConfig() *GithubConfig

func (*GithubConfig) ToProtobuf added in v0.1.1

type HttpPipelineConfig

type HttpPipelineConfig struct {
	Enable           bool                    `config:"enable" default:"true"`
	Name             string                  `config:"name" default:"http"`
	Host             string                  `config:"host" default:"0.0.0.0"`
	Port             uint16                  `config:"port" default:"8080"`
	Parser           string                  `config:"parser" default:"malefic"`
	TlsConfig        *TlsConfig              `config:"tls"`
	EncryptionConfig types.EncryptionsConfig `config:"encryption"`
	SecureConfig     *types.SecureConfig     `config:"secure"` // Age 密码学安全配置
	Headers          map[string][]string     `config:"headers"`
	ErrorPage        string                  `config:"error_page"`
	BodyPrefix       string                  `config:"body_prefix"`
	BodySuffix       string                  `config:"body_suffix"`
}

func (*HttpPipelineConfig) ToProtobuf added in v0.1.0

func (http *HttpPipelineConfig) ToProtobuf(lisId string) (*clientpb.Pipeline, error)

type LarkConfig added in v0.1.0

type LarkConfig struct {
	Enable     bool   `config:"enable" default:"false"`
	WebHookUrl string `config:"webhook_url"`
}

type ListenerConfig

type ListenerConfig struct {
	Enable bool   `config:"enable" default:"true"`
	Name   string `config:"name" default:"listener"`
	Auth   string `config:"auth" default:"listener.auth"`
	//Server             string                `config:"server" default:"127.0.0.1"`
	IP                 string                `config:"ip"`
	TcpPipelines       []*TcpPipelineConfig  `config:"tcp" `
	BindPipelineConfig []*BindPipelineConfig `config:"bind"`
	HttpPipelines      []*HttpPipelineConfig `config:"http"`
	Websites           []*WebsiteConfig      `config:"website"`
	REMs               []*REMConfig          `config:"rem"`
	AutoBuildConfig    *AutoBuildConfig      `config:"auto_build"`
}

func GetListenerConfig

func GetListenerConfig() *ListenerConfig

type LogConfig

type LogConfig struct {
	Level int `json:"level" default:"20" config:"level"`
}

LogConfig - Server logging config

type MiscConfig

type MiscConfig struct {
	PacketLength int    `config:"packet_length" default:"4194304"`
	Certificate  string `config:"cert" default:""`
	PrivateKey   string `config:"key" default:""`
}

type NotifyConfig added in v0.0.2

type NotifyConfig struct {
	Enable     bool              `config:"enable" default:"true"`
	Telegram   *TelegramConfig   `config:"telegram"`
	DingTalk   *DingTalkConfig   `config:"dingtalk"`
	Lark       *LarkConfig       `config:"lark"`
	ServerChan *ServerChanConfig `config:"serverchan"`
	PushPlus   *PushPlusConfig   `config:"pushplus"`
}

func GetNotifyConfig added in v0.1.0

func GetNotifyConfig() *NotifyConfig

type PushPlusConfig added in v0.1.2

type PushPlusConfig struct {
	Enable  bool   `config:"enable" default:"false"`
	Token   string `config:"token"`
	Topic   string `config:"topic"`
	Channel string `config:"channel"`
}

type REMConfig added in v0.1.0

type REMConfig struct {
	Enable  bool   `config:"enable" default:"false"`
	Name    string `config:"name" default:"default-rem"`
	Console string `config:"console" default:""`
}

func (*REMConfig) ToProtobuf added in v0.1.0

func (r *REMConfig) ToProtobuf(lisId string) (*clientpb.Pipeline, error)

type SaasConfig added in v0.1.1

type SaasConfig struct {
	Enable bool   `config:"enable"`
	Url    string `config:"url" default:""`
	Token  string `config:"token" default:""`
}

func GetSaasConfig added in v0.1.1

func GetSaasConfig() *SaasConfig

type ServerChanConfig added in v0.1.0

type ServerChanConfig struct {
	Enable bool   `config:"enable" default:"false"`
	URL    string `config:"url"`
}

type ServerConfig

type ServerConfig struct {
	Enable        bool          `config:"enable" default:"true"`
	GRPCPort      uint16        `config:"grpc_port" default:"5004"`
	GRPCHost      string        `config:"grpc_host" default:"0.0.0.0"`
	IP            string        `config:"ip" default:""`
	DaemonConfig  bool          `config:"daemon" default:"false"`
	EncryptionKey string        `config:"encryption_key" default:"maliceofinternal"`
	LogConfig     *LogConfig    `config:"log"`
	MiscConfig    *MiscConfig   `config:"config"`
	NotifyConfig  *NotifyConfig `config:"notify"`
	GithubConfig  *GithubConfig `config:"github"`
	SassConfig    *SaasConfig   `config:"saas"`
}

func GetServerConfig

func GetServerConfig() *ServerConfig

func (*ServerConfig) Address

func (c *ServerConfig) Address() string

func (*ServerConfig) Save

func (c *ServerConfig) Save() error

type TcpPipelineConfig

type TcpPipelineConfig struct {
	Enable           bool                    `config:"enable" default:"true"`
	Name             string                  `config:"name" default:"tcp"`
	Host             string                  `config:"host" default:"0.0.0.0"`
	Port             uint16                  `config:"port" default:"5001"`
	Parser           string                  `config:"parser" default:"malefic"`
	TlsConfig        *TlsConfig              `config:"tls"`
	EncryptionConfig types.EncryptionsConfig `config:"encryption"`
	SecureConfig     *types.SecureConfig     `config:"secure"` // Age 密码学安全配置
}

func (*TcpPipelineConfig) ToProtobuf added in v0.0.3

func (tcp *TcpPipelineConfig) ToProtobuf(lisId string) (*clientpb.Pipeline, error)

type TelegramConfig added in v0.1.0

type TelegramConfig struct {
	Enable bool   `config:"enable" default:"false"`
	APIKey string `config:"api_key"`
	ChatID int64  `config:"chat_id"`
}

type TlsConfig

type TlsConfig struct {
	Enable   bool   `config:"enable"`
	CertFile string `config:"cert_file"`
	KeyFile  string `config:"key_file"`
	CAFile   string `config:"ca_file"`
	//Acme     bool   `config:"acme"`
	//Domain   string `config:"domain"`
	//Name     string `config:"name"`
	CN string `config:"CN"`
	O  string `config:"O"`
	C  string `config:"C"`
	L  string `config:"L"`
	OU string `config:"OU"`
	ST string `config:"ST"`
}

func (*TlsConfig) ReadCert added in v0.0.3

func (t *TlsConfig) ReadCert() (*types.TlsConfig, error)

func (*TlsConfig) ToPkix

func (t *TlsConfig) ToPkix() *pkix.Name

type WebContent added in v0.0.3

type WebContent struct {
	File string `config:"file"`
	Path string `config:"path"`
	Type string `config:"type" default:"raw"`
}

func (*WebContent) ToProtobuf added in v0.1.0

func (content *WebContent) ToProtobuf() (*clientpb.WebContent, error)

type WebsiteConfig

type WebsiteConfig struct {
	Enable      bool          `config:"enable" default:"false"`
	RootPath    string        `config:"root" default:"."`
	WebsiteName string        `config:"name" default:"web"`
	Port        uint16        `config:"port" default:"443"`
	WebContents []*WebContent `config:"content" default:""`
	TlsConfig   *TlsConfig    `config:"tls" `
}

Jump to

Keyboard shortcuts

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