Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleAdmin    = "admin"    // Full access, can manage operators and rules
	RoleOperator = "operator" // Access to MaliceRPC (implant operations)
	RoleListener = "listener" // Access to ListenerRPC only
)

Role constants for operator authorization

Variables

ValidRoles is the set of recognized role values.

Functions

func FromRegister added in v0.0.3

func FromRegister(register *implantpb.Register) string

FromRegister - convert session to context json string

func ToRegister added in v0.0.3

func ToRegister(context string) *implantpb.Register

Types

type Artifact added in v0.1.1

type Artifact struct {
	ID          uint32 `gorm:"primaryKey;autoIncrement"`
	Name        string `gorm:"unique"`
	ProfileName string `gorm:"index;"`

	CreatedAt time.Time `gorm:"->;<-:create;"`
	UpdatedAt time.Time `gorm:"->;<-:update;"`
	Target    string    // build target, like win64, win32, linux64
	Type      string    // beacon、pulse、modules、prelude
	//Type      string    // build type, pe, dll, shellcode
	Source string // docker 、 saas 、github action、upload...
	//CA            string // ca file , ca file content
	Path        string
	Profile     Profile `gorm:"foreignKey:ProfileName;references:Name;-:migration;"`
	Os          string
	Format      string // file extension like .exe/.dll/.so/.dylib or ""
	Arch        string
	Log         string
	Status      string
	ParamsData  string
	Params      *implanttypes.ProfileParams `gorm:"-"`
	ProfileByte []byte
	Comment     string
}

func (*Artifact) AfterFind added in v0.1.1

func (a *Artifact) AfterFind(tx *gorm.DB) (err error)

func (*Artifact) BeforeCreate added in v0.1.1

func (a *Artifact) BeforeCreate(tx *gorm.DB) (err error)

func (*Artifact) BeforeSave added in v0.1.1

func (a *Artifact) BeforeSave(tx *gorm.DB) error

BeforeSave GORM 钩子 - 保存前将 Params 序列化

func (*Artifact) ToArtifact added in v0.1.2

func (a *Artifact) ToArtifact() (*clientpb.Artifact, error)

func (*Artifact) ToProtobuf added in v0.1.1

func (a *Artifact) ToProtobuf(bin []byte) *clientpb.Artifact

type AuthzRule added in v0.3.0

type AuthzRule struct {
	ID        uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`
	CreatedAt time.Time `gorm:"->;<-:create;"`
	Role      string    `gorm:"index;type:string;"`
	Method    string    `gorm:"type:string;"`
	Allow     bool      `gorm:"default:true"`
}

AuthzRule maps a role to allowed (or denied) gRPC method patterns. Pattern supports:

  • Exact match: "/clientrpc.MaliceRPC/GetSessions"
  • Service wildcard: "/clientrpc.MaliceRPC/*"
  • Package prefix: "/listenerrpc.*"

func (*AuthzRule) BeforeCreate added in v0.3.0

func (a *AuthzRule) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate - GORM hook

type Certificate

type Certificate struct {
	ID        uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`
	CreatedAt time.Time `gorm:"->;<-:create;"`
	Name      string    `gorm:"unique"`
	Type      string    // 证书类型: selfsigned, letsencrypt, imported
	Domain    string    // 证书绑定域名
	CertPEM   string    // 证书内容 PEM
	KeyPEM    string    // 私钥内容 PEM
	CACertPEM string    // CA 证书内容 PEM
	CAKeyPEM  string    // CA 私钥内容 PEM
}

func (*Certificate) BeforeCreate

func (c *Certificate) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate - GORM hook 自动设置ID和创建时间

func (*Certificate) ToProtobuf added in v0.1.1

func (c *Certificate) ToProtobuf() *clientpb.TLS

type Context added in v0.1.0

type Context struct {
	ID         uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid"`
	CreatedAt  time.Time `gorm:"->;<-:create"`
	UpdatedAt  time.Time
	SessionID  string `gorm:"type:string;index;"`
	PipelineID string `gorm:"type:string;index;"`
	TaskID     string `gorm:"type:string;index;"`
	Type       string
	Nonce      string
	Value      []byte
	Context    output.Context `gorm:"-"`

	Session  *Session  `gorm:"foreignKey:SessionID;references:SessionID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Pipeline *Pipeline `gorm:"foreignKey:PipelineID;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Task     *Task     `gorm:"foreignKey:TaskID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

func FromContextProtobuf added in v0.1.0

func FromContextProtobuf(ctx *clientpb.Context) (*Context, error)

func (*Context) AfterFind added in v0.1.0

func (c *Context) AfterFind(tx *gorm.DB) (err error)

func (*Context) BeforeCreate added in v0.1.0

func (c *Context) BeforeCreate(tx *gorm.DB) (err error)

func (*Context) ToProtobuf added in v0.1.0

func (c *Context) ToProtobuf() *clientpb.Context

type Operator

type Operator struct {
	ID               uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`
	CreatedAt        time.Time `gorm:"->;<-:create;"`
	Name             string    `gorm:"uniqueIndex"`
	Remote           string    `gorm:"type:string;"`
	Type             string    `gorm:"type:string;"`
	Role             string    `gorm:"type:string;default:'operator'"`
	Fingerprint      string    `gorm:"uniqueIndex;type:string;"`
	Revoked          bool      `gorm:"default:false"`
	CAType           int
	KeyType          string
	CaCertificatePEM string
	CertificatePEM   string
	PrivateKeyPEM    string
}

Operator represents a registered client or listener identity.

func (*Operator) BeforeCreate

func (o *Operator) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate - GORM hook

func (*Operator) ToListener added in v0.1.0

func (o *Operator) ToListener() *clientpb.Listener

func (*Operator) ToProtobuf added in v0.1.0

func (o *Operator) ToProtobuf() *clientpb.Client

type Pipeline added in v0.0.2

type Pipeline struct {
	ID                           uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`
	CreatedAt                    time.Time `gorm:"->;<-:create;"`
	ListenerId                   string    `gorm:"type:string;uniqueIndex:idx_pipelines_listener_name"`
	Name                         string    `gorm:"type:string;unique;uniqueIndex:idx_pipelines_listener_name"`
	IP                           string    `gorm:"type:string;default:''"`
	Host                         string    `config:"host"`
	Port                         uint32    `config:"port"`
	Type                         string    `gorm:"type:string;"`
	Enable                       bool      `gorm:"type:boolean;"`
	ParamsData                   string    `gorm:"column:params"`
	CertName                     string    `gorm:"type:string;"`
	*implanttypes.PipelineParams `gorm:"-"`
}

Pipeline

func FromPipelinePb added in v0.0.3

func FromPipelinePb(pipeline *clientpb.Pipeline) *Pipeline

func (*Pipeline) Address added in v0.0.3

func (pipeline *Pipeline) Address() string

func (*Pipeline) AfterFind added in v0.1.0

func (pipeline *Pipeline) AfterFind(tx *gorm.DB) error

AfterFind GORM 钩子 - 查询后反序列化

func (*Pipeline) BeforeCreate added in v0.0.2

func (pipeline *Pipeline) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate - GORM hook

func (*Pipeline) BeforeSave added in v0.1.0

func (pipeline *Pipeline) BeforeSave(tx *gorm.DB) error

BeforeSave GORM 钩子 - 保存前将 Params 序列化

func (*Pipeline) DefaultHTTPProfile added in v0.1.2

func (pipeline *Pipeline) DefaultHTTPProfile() implanttypes.ProfileConfig

func (*Pipeline) DefaultRemProfile added in v0.1.2

func (pipeline *Pipeline) DefaultRemProfile(backend *Pipeline) implanttypes.ProfileConfig

func (*Pipeline) DefaultTCPProfile added in v0.1.2

func (pipeline *Pipeline) DefaultTCPProfile() implanttypes.ProfileConfig

func (*Pipeline) GetUrl added in v0.1.2

func (pipeline *Pipeline) GetUrl() string

func (*Pipeline) ToProfile added in v0.1.2

func (pipeline *Pipeline) ToProfile(backend *Pipeline) (implanttypes.ProfileConfig, error)

func (*Pipeline) ToProtobuf added in v0.1.0

func (pipeline *Pipeline) ToProtobuf() *clientpb.Pipeline

type Profile added in v0.0.3

type Profile struct {
	ID uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`

	// build
	Name string `gorm:"unique"` // Ensuring Name is unique

	// params
	Params     *implanttypes.ProfileParams `gorm:"-"`             // 使用 interface{} 使其更灵活
	ParamsData string                      `gorm:"column:params"` // 改用更简洁的数据库字段名

	// BasicPipeline 和 PulsePipeline
	PipelineID string `gorm:"type:string;index;"`

	// BasicPipeline 和 PulsePipeline
	Pipeline *Pipeline `gorm:"foreignKey:PipelineID;references:Name;-:migration;"`

	CreatedAt time.Time `gorm:"->;<-:create;"`
}

func (*Profile) AfterFind added in v0.0.3

func (p *Profile) AfterFind(tx *gorm.DB) (err error)

func (*Profile) BeforeCreate added in v0.0.3

func (p *Profile) BeforeCreate(tx *gorm.DB) (err error)

func (*Profile) BeforeSave added in v0.1.0

func (p *Profile) BeforeSave(tx *gorm.DB) error

BeforeSave GORM 钩子 - 保存前将 Params 序列化

func (*Profile) DiskPath added in v0.3.0

func (p *Profile) DiskPath() string

DiskPath 返回该 profile 在磁盘上的存储目录

func (*Profile) ToProtobuf added in v0.0.3

func (p *Profile) ToProtobuf() *clientpb.Profile

type Session

type Session struct {
	SessionID   string `gorm:"primaryKey;->;<-:create;type:uuid;"`
	RawID       uint32
	CreatedAt   time.Time `gorm:"->;<-:create;"`
	Note        string
	GroupName   string
	Target      string
	Initialized bool
	Type        string
	PipelineID  string
	ListenerID  string
	IsAlive     bool
	LastCheckin int64
	IsRemoved   bool                   `gorm:"default:false"`
	Data        *client.SessionContext `gorm:"-"`
	DataString  string                 `gorm:"column:data"`

	ProfileName string  `gorm:"index;"`
	Profile     Profile `gorm:"foreignKey:ProfileName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

func (*Session) AfterFind added in v0.1.0

func (s *Session) AfterFind(tx *gorm.DB) error

func (*Session) BeforeCreate

func (s *Session) BeforeCreate(tx *gorm.DB) (err error)

func (*Session) BeforeSave added in v0.1.0

func (s *Session) BeforeSave(tx *gorm.DB) error

func (*Session) ToProtobuf added in v0.0.3

func (s *Session) ToProtobuf() *clientpb.Session

type Task

type Task struct {
	ID          string    `gorm:"primaryKey;->;<-:create;"`
	Created     time.Time `gorm:"->;<-:create;"`
	Deadline    time.Time
	CallBy      string
	Seq         uint32
	Type        string
	SessionID   string
	Session     Session `gorm:"foreignKey:SessionID;references:SessionID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Cur         int
	Total       int
	Description string
	ClientName  string
	FinishTime  time.Time
	LastTime    time.Time
}

func (*Task) BeforeCreate

func (t *Task) BeforeCreate(tx *gorm.DB) (err error)

func (*Task) ToProtobuf

func (t *Task) ToProtobuf() *clientpb.Task

func (*Task) UpdateCur

func (t *Task) UpdateCur(db *gorm.DB, newCur int) error

func (*Task) UpdateFinish added in v0.1.2

func (t *Task) UpdateFinish(db *gorm.DB) error

func (*Task) UpdateTotal added in v0.0.3

func (t *Task) UpdateTotal(db *gorm.DB, newTotal int) error

type Timer

type Timer struct {
	Expression string  `json:"expression"`
	Jitter     float64 `json:"jitter"`
}

func FromTimePb added in v0.0.3

func FromTimePb(timer *implantpb.Timer) *Timer

type WebsiteContent added in v0.0.3

type WebsiteContent struct {
	ID        uuid.UUID `gorm:"primaryKey;->;<-:create;type:uuid;"`
	CreatedAt time.Time `gorm:"->;<-:create;"`

	File        string `gorm:""`
	Path        string `gorm:""`
	Size        uint64 `gorm:""`
	Type        string `gorm:""`
	ContentType string `gorm:""`
	Auth        string `gorm:""` // "user:pass" or empty; "none" = skip website default

	Pipeline   *Pipeline `gorm:"foreignKey:PipelineID;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	PipelineID string    `gorm:"type:string;index;"`
}

WebsiteContent - Single table that combines Website and WebContent

func FromWebContentPb added in v0.1.0

func FromWebContentPb(content *clientpb.WebContent) *WebsiteContent

func (*WebsiteContent) BeforeCreate added in v0.0.3

func (wc *WebsiteContent) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate - GORM hook to automatically set values

func (*WebsiteContent) ToProtobuf added in v0.0.3

func (wc *WebsiteContent) ToProtobuf(read bool) *clientpb.WebContent

ToProtobuf - Converts to protobuf object

func (*WebsiteContent) URL added in v0.1.0

func (wc *WebsiteContent) URL() string

Jump to

Keyboard shortcuts

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