Documentation
¶
Index ¶
- Constants
- Variables
- func CleanAuditLogs(auditDir string, maxAge int)
- func FindConfig(filename string) string
- func GetCertDir() string
- func GetRandomID() string
- func GetWorkDir() string
- func InitConfig() error
- func InitTestConfigRuntime(t testing.TB)
- func JoinStringSlice(slice []string) string
- func LoadMiscConfig() ([]byte, []byte, error)
- func NewCrypto(es []*clientpb.Encryption) ([]cryptostream.Cryptor, error)
- func NewDebugLog(filename string) *logs.Logger
- func NewFileLog(filename string) *logs.Logger
- func RotateLogs(logDir string, maxAge int, compress bool, reopenFn func())
- func UpdateAcmeConfig(a *AcmeConfig) error
- func UpdateGithubConfig(g *GithubConfig) error
- func UpdateMaleficRoot(path string)
- func UpdateNotifyConfig(n *NotifyConfig) error
- func UpdateSaasConfig(n *SaasConfig) error
- func UseTestPaths(t testing.TB, root string)
- type AcmeConfig
- type AutoBuildConfig
- type BindPipelineConfig
- type DatabaseConfig
- type DingTalkConfig
- type GithubConfig
- type HttpPipelineConfig
- type LLMConfig
- type LLMProviderConfig
- type LarkConfig
- type ListenerConfig
- type LogConfig
- type MiscConfig
- type NotifyConfig
- type PushPlusConfig
- type REMConfig
- type SaasConfig
- type ServerChanConfig
- type ServerConfig
- type TcpPipelineConfig
- type TelegramConfig
- type TlsConfig
- type WebContent
- type WebsiteConfig
Constants ¶
View Source
const ( // Sqlite - SQLite protocol Sqlite = "sqlite3" // Postgres - Postgresql protocol Postgres = "postgresql" // MySQL - MySQL protocol MySQL = "mysql" )
View Source
const ( DefaultLogMaxAge = 180 // days DefaultLogCompress = true // gzip old logs )
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 MaleficRoot = filepath.Join(GetWorkDir(), "malefic") BinPath = filepath.Join(ServerRootPath, "bin") SourceCodePath = filepath.Join(MaleficRoot, "source_code") ResourcePath = filepath.Join(SourceCodePath, "resources") TargetPath = filepath.Join(SourceCodePath, "target") CargoCachePath = filepath.Join(MaleficRoot, "cache") BuildOutputPath = filepath.Join(MaleficRoot, "output") )
View Source
var ( // ErrInvalidDialect - An invalid dialect was specified ErrInvalidDialect = errors.New("invalid SQL Dialect") )
View Source
var ListenerConfigFileName = "listener.yaml"
Functions ¶
func CleanAuditLogs ¶ added in v0.3.0
CleanAuditLogs removes audit log files older than maxAge days.
func FindConfig ¶ added in v0.1.1
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 InitTestConfigRuntime ¶ added in v0.3.0
func JoinStringSlice ¶ added in v0.0.3
JoinStringSlice Helper function to join string slices
func LoadMiscConfig ¶
func NewCrypto ¶ added in v0.1.0
func NewCrypto(es []*clientpb.Encryption) ([]cryptostream.Cryptor, error)
func NewDebugLog ¶
func NewFileLog ¶
func RotateLogs ¶ added in v0.3.0
RotateLogs rotates .log files in logDir:
- Rename current .log → .{date}.log
- Compress yesterday's .{date}.log → .{date}.log.gz (if compress=true)
- Delete rotated logs older than maxAge days
func UpdateAcmeConfig ¶ added in v0.3.0
func UpdateAcmeConfig(a *AcmeConfig) error
func UpdateGithubConfig ¶ added in v0.1.0
func UpdateGithubConfig(g *GithubConfig) error
func UpdateMaleficRoot ¶ added in v0.3.0
func UpdateMaleficRoot(path string)
UpdateMaleficRoot overrides the default malefic project root and all derived paths.
func UpdateNotifyConfig ¶ added in v0.1.0
func UpdateNotifyConfig(n *NotifyConfig) error
func UpdateSaasConfig ¶ added in v0.1.1
func UpdateSaasConfig(n *SaasConfig) error
func UseTestPaths ¶ added in v0.3.0
Types ¶
type AcmeConfig ¶ added in v0.3.0
type AcmeConfig struct {
Email string `config:"email" yaml:"email"`
CAUrl string `config:"ca_url" default:"https://acme-v02.api.letsencrypt.org/directory" yaml:"ca_url"`
Provider string `config:"provider" yaml:"provider"`
Credentials map[string]string `config:"credentials" yaml:"credentials"`
}
func GetAcmeConfig ¶ added in v0.3.0
func GetAcmeConfig() *AcmeConfig
func (*AcmeConfig) ToProtobuf ¶ added in v0.3.0
func (a *AcmeConfig) ToProtobuf() *clientpb.AcmeConfig
type AutoBuildConfig ¶ added in v0.1.0
type BindPipelineConfig ¶ added in v0.0.3
type BindPipelineConfig struct {
Enable bool `config:"enable" default:"true" yaml:"enable"`
Name string `config:"name" default:"bind" yaml:"name"`
TlsConfig *TlsConfig `config:"tls" yaml:"tls"`
EncryptionConfig implanttypes.EncryptionsConfig `config:"encryption" yaml:"encryption"`
PacketLength int `config:"packet_length" yaml:"packet_length"`
}
func (*BindPipelineConfig) ToProtobuf ¶ added in v0.0.3
func (pipeline *BindPipelineConfig) ToProtobuf(lisId string) (*clientpb.Pipeline, error)
type DatabaseConfig ¶
type DatabaseConfig struct {
Dialect string `json:"dialect" config:"dialect" default:"sqlite3" yaml:"dialect"`
Database string `json:"database" config:"database" yaml:"database"`
Username string `json:"username" config:"username" yaml:"username"`
Password string `json:"password" config:"password" yaml:"password"`
Host string `json:"host" config:"host" yaml:"host"`
Port uint16 `json:"port" config:"port" yaml:"port"`
Params map[string]string `json:"params" config:"params" yaml:"params"`
MaxIdleConns int `json:"max_idle_conns" config:"max_idle_conns" default:"10" yaml:"max_idle_conns"`
MaxOpenConns int `json:"max_open_conns" config:"max_open_conns" default:"100" yaml:"max_open_conns"`
LogLevel string `json:"log_level" config:"log_level" default:"warn" yaml:"log_level"`
}
DatabaseConfig - Database configuration
func GetDefaultDatabaseConfig ¶ added in v0.3.0
func GetDefaultDatabaseConfig() *DatabaseConfig
GetDefaultDatabaseConfig returns the default database configuration (SQLite)
func (*DatabaseConfig) DSN ¶
func (c *DatabaseConfig) DSN() (string, error)
DSN - Get the db connections string
type DingTalkConfig ¶ added in v0.1.0
type GithubConfig ¶ added in v0.1.0
type GithubConfig struct {
Repo string `config:"repo" default:"malefic" yaml:"repo"`
Owner string `config:"owner" default:"" yaml:"owner"`
Token string `config:"token" default:"" yaml:"token"`
Workflow string `config:"workflow" default:"generate.yaml" yaml:"workflow"`
}
func GetGithubConfig ¶ added in v0.1.0
func GetGithubConfig() *GithubConfig
func (*GithubConfig) ToProtobuf ¶ added in v0.1.1
func (g *GithubConfig) ToProtobuf() *clientpb.GithubActionBuildConfig
type HttpPipelineConfig ¶
type HttpPipelineConfig struct {
Enable bool `config:"enable" default:"true" yaml:"enable"`
Name string `config:"name" default:"http" yaml:"name"`
Host string `config:"host" default:"0.0.0.0" yaml:"host"`
Port uint16 `config:"port" default:"8080" yaml:"port"`
Parser string `config:"parser" default:"malefic" yaml:"parser"`
TlsConfig *TlsConfig `config:"tls" yaml:"tls"`
EncryptionConfig implanttypes.EncryptionsConfig `config:"encryption" yaml:"encryption"`
SecureConfig *implanttypes.SecureConfig `config:"secure" yaml:"secure"` // Age 密码学安全配置
Headers map[string][]string `config:"headers" yaml:"headers"`
ErrorPage string `config:"error_page" yaml:"error_page"`
BodyPrefix string `config:"body_prefix" yaml:"body_prefix"`
BodySuffix string `config:"body_suffix" yaml:"body_suffix"`
PacketLength int `config:"packet_length" yaml:"packet_length"`
}
func (*HttpPipelineConfig) ToProtobuf ¶ added in v0.1.0
func (http *HttpPipelineConfig) ToProtobuf(lisId string) (*clientpb.Pipeline, error)
type LLMConfig ¶ added in v0.3.0
type LLMConfig struct {
DefaultProvider string `config:"default_provider" default:"openai" yaml:"default_provider"`
Endpoint string `config:"endpoint" default:"" yaml:"endpoint"`
APIKey string `config:"api_key" default:"" yaml:"api_key"`
ProxyURL string `config:"proxy_url" default:"" yaml:"proxy_url"`
Timeout int `config:"timeout" default:"120" yaml:"timeout"`
Providers map[string]*LLMProviderConfig `config:"providers" yaml:"providers"`
}
func GetLLMConfig ¶ added in v0.3.0
func GetLLMConfig() *LLMConfig
type LLMProviderConfig ¶ added in v0.3.0
type LarkConfig ¶ added in v0.1.0
type ListenerConfig ¶
type ListenerConfig struct {
Enable bool `config:"enable" default:"true" yaml:"enable"`
Name string `config:"name" default:"listener" yaml:"name"`
Auth string `config:"auth" default:"listener.auth" yaml:"auth"`
//Server string `config:"server" default:"127.0.0.1"`
IP string `config:"ip" yaml:"ip"`
TcpPipelines []*TcpPipelineConfig `config:"tcp" yaml:"tcp"`
BindPipelineConfig []*BindPipelineConfig `config:"bind" yaml:"bind"`
HttpPipelines []*HttpPipelineConfig `config:"http" yaml:"http"`
Websites []*WebsiteConfig `config:"website" yaml:"website"`
REMs []*REMConfig `config:"rem" yaml:"rem"`
AutoBuildConfig *AutoBuildConfig `config:"auto_build" yaml:"auto_build"`
}
func GetListenerConfig ¶
func GetListenerConfig() *ListenerConfig
type LogConfig ¶
type LogConfig struct {
Level int `json:"level" default:"20" config:"level" yaml:"level"`
}
LogConfig - Server logging config
type MiscConfig ¶
type NotifyConfig ¶ added in v0.0.2
type NotifyConfig struct {
Enable bool `config:"enable" default:"true" yaml:"enable"`
Telegram *TelegramConfig `config:"telegram" yaml:"telegram"`
DingTalk *DingTalkConfig `config:"dingtalk" yaml:"dingtalk"`
Lark *LarkConfig `config:"lark" yaml:"lark"`
ServerChan *ServerChanConfig `config:"serverchan" yaml:"serverchan"`
PushPlus *PushPlusConfig `config:"pushplus" yaml:"pushplus"`
}
func GetNotifyConfig ¶ added in v0.1.0
func GetNotifyConfig() *NotifyConfig
type PushPlusConfig ¶ added in v0.1.2
type REMConfig ¶ added in v0.1.0
type SaasConfig ¶ added in v0.1.1
type SaasConfig struct {
Enable bool `config:"enable" yaml:"enable"`
Url string `config:"url" default:"" yaml:"url"`
Token string `config:"token" default:"" yaml:"token"`
}
func GetSaasConfig ¶ added in v0.1.1
func GetSaasConfig() *SaasConfig
type ServerChanConfig ¶ added in v0.1.0
type ServerConfig ¶
type ServerConfig struct {
Enable bool `config:"enable" default:"true" yaml:"enable"`
GRPCPort uint16 `config:"grpc_port" default:"5004" yaml:"grpc_port"`
GRPCHost string `config:"grpc_host" default:"0.0.0.0" yaml:"grpc_host"`
IP string `config:"ip" default:"" yaml:"ip"`
DaemonConfig bool `config:"daemon" default:"false" yaml:"daemon"`
EncryptionKey string `config:"encryption_key" default:"maliceofinternal" yaml:"encryption_key"`
SourceCodeRoot string `config:"source_code_root" default:"" yaml:"source_code_root"`
LogConfig *LogConfig `config:"log" yaml:"log"`
MiscConfig *MiscConfig `config:"config" yaml:"config"`
NotifyConfig *NotifyConfig `config:"notify" yaml:"notify"`
GithubConfig *GithubConfig `config:"github" yaml:"github"`
SaasConfig *SaasConfig `config:"saas" yaml:"saas"`
AcmeConfig *AcmeConfig `config:"acme" yaml:"acme"`
LLMConfig *LLMConfig `config:"llm" yaml:"llm"`
DatabaseConfig *DatabaseConfig `config:"database" yaml:"database"`
}
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" yaml:"enable"`
Name string `config:"name" default:"tcp" yaml:"name"`
Host string `config:"host" default:"0.0.0.0" yaml:"host"`
Port uint16 `config:"port" default:"5001" yaml:"port"`
Parser string `config:"parser" default:"malefic" yaml:"parser"`
TlsConfig *TlsConfig `config:"tls" yaml:"tls"`
EncryptionConfig implanttypes.EncryptionsConfig `config:"encryption" yaml:"encryption"`
SecureConfig *implanttypes.SecureConfig `config:"secure" yaml:"secure"` // Age 密码学安全配置
PacketLength int `config:"packet_length" yaml:"packet_length"`
}
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 TlsConfig ¶
type TlsConfig struct {
Enable bool `config:"enable" yaml:"enable"`
MTLS bool `config:"mtls" yaml:"mtls"`
CertFile string `config:"cert_file" yaml:"cert_file"`
KeyFile string `config:"key_file" yaml:"key_file"`
CAFile string `config:"ca_file" yaml:"ca_file"`
//Acme bool `config:"acme"`
//Domain string `config:"domain"`
//Name string `config:"name"`
CN string `config:"CN" yaml:"CN"`
O string `config:"O" yaml:"O"`
C string `config:"C" yaml:"C"`
L string `config:"L" yaml:"L"`
OU string `config:"OU" yaml:"OU"`
ST string `config:"ST" yaml:"ST"`
}
type WebContent ¶ added in v0.0.3
type WebContent struct {
File string `config:"file" yaml:"file"`
Path string `config:"path" yaml:"path"`
Type string `config:"type" default:"raw" yaml:"type"`
Auth string `config:"auth" default:"" yaml:"auth"` // per-path auth "user:pass", "none" = skip
}
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" yaml:"enable"`
RootPath string `config:"root" default:"." yaml:"root"`
WebsiteName string `config:"name" default:"web" yaml:"name"`
Port uint16 `config:"port" default:"443" yaml:"port"`
Auth string `config:"auth" default:"" yaml:"auth"` // website-level default auth "user:pass"
WebContents []*WebContent `config:"content" default:"" yaml:"content"`
TlsConfig *TlsConfig `config:"tls" yaml:"tls"`
}
Click to show internal directories.
Click to hide internal directories.