db

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: GPL-3.0 Imports: 19 Imported by: 36

README

server/db

Overview

Database access layer including migrations and helpers. Establishes database connections, adapters, and query utilities. Key routines cover SQL CGO, SQL GO, SQL WASM, and SQL within the db subsystem.

Go Files

  • db.go – Initializes database connections and manages migrations.
  • helpers.go – Utility functions shared across the database layer.
  • logger.go – Database logging adapter for structured output.
  • sql-cgo.go – CGO-backed SQLite driver wiring.
  • sql-go.go – Pure-Go SQLite driver wiring.
  • sql-wasm.go – WebAssembly SQLite integration for embedded builds.
  • sql.go – Common SQL helpers and abstractions.

Sub-packages

  • models/ – Database models and ORM definitions for server state. Defines data schemas, relationships, and query helpers.
  • wasmsqlite/ – WebAssembly SQLite bridge for embedded database support. Adapts wasm-sqlite bindings for browser-compatible runtimes.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client = newDBClient()

Client - Database Client

View Source
var (
	// ErrRecordNotFound - Record not found error
	ErrRecordNotFound = gorm.ErrRecordNotFound
)

Functions

func AddContent added in v1.6.0

func AddContent(pbWebContent *clientpb.WebContent, webContentDir string) (*clientpb.WebContent, error)

AddContent - Add content to website

func AddWebSite added in v1.6.0

func AddWebSite(webSiteName string, webContentDir string) (*clientpb.Website, error)

AddWebsite - Return website, create if it does not exist

func AllCrackFiles added in v1.6.0

func AllCrackFiles() ([]*models.CrackFile, error)

func BeaconByID added in v1.5.0

func BeaconByID(id string) (*models.Beacon, error)

BeaconByID - Select a Beacon by ID

func BeaconTaskByEnvelopeID added in v1.5.0

func BeaconTaskByEnvelopeID(beaconID string, envelopeID int64) (*clientpb.BeaconTask, error)

BeaconTasksByEnvelopeID - Select a (sent) BeaconTask by its envelope ID

func BeaconTaskByID added in v1.5.0

func BeaconTaskByID(id string) (*clientpb.BeaconTask, error)

BeaconTaskByID - Select a specific BeaconTask by ID, this will fetch the full request/response

func BeaconTasksByBeaconID added in v1.5.0

func BeaconTasksByBeaconID(beaconID string) ([]*clientpb.BeaconTask, error)

BeaconTasksByBeaconID - Get all tasks for a specific beacon by default will not fetch the request/response columns since these could be arbitrarily large.

func CanaryByDomain

func CanaryByDomain(domain string) (*clientpb.DNSCanary, error)

CanaryByDomain - Check if a canary exists

func CheckKeyExReplay added in v1.6.0

func CheckKeyExReplay(ciphertext []byte) error

CheckKeyExReplay - Store the hash of a key exchange to prevent replays

func CountTasksByBeaconID added in v1.5.0

func CountTasksByBeaconID(beaconID string) (int64, int64, error)

CountTasksByBeaconID - Select a (sent) BeaconTask by its envelope ID

func CrackFilesByType added in v1.6.0

func CrackFilesByType(fileType clientpb.CrackFileType) ([]*models.CrackFile, error)

CrackFilesByType - Get all files by crack file type

func CrackFilesDiskUsage added in v1.6.0

func CrackFilesDiskUsage() (int64, error)

CrackFilesDiskUsage - Get all files by crack file type

func CrackWordlistByName added in v1.6.0

func CrackWordlistByName(name string) (*models.CrackFile, error)

CrackWordlistByName - Get all files by crack file type

func CrackstationByHostUUID added in v1.6.0

func CrackstationByHostUUID(hostUUID string) (*models.Crackstation, error)

CrackstationByHostUUID - Get crackstation by the session's reported HostUUID

func CredentialByID added in v1.6.0

func CredentialByID(id string) (*clientpb.Credential, error)

CredentialsByID

func CredentialsByCollection added in v1.6.0

func CredentialsByCollection(collection string) ([]*clientpb.Credential, error)

CredentialsByHashType

func CredentialsByHashType added in v1.6.0

func CredentialsByHashType(hashType clientpb.HashType) ([]*clientpb.Credential, error)

CredentialsByHashType

func DeleteC2 added in v1.6.0

func DeleteC2(c2ID uuid.UUID) error

func DeleteKeyValue added in v1.5.0

func DeleteKeyValue(key string, value string) error

DeleteKeyValue - Delete a key/value pair

func DeleteListener added in v1.6.0

func DeleteListener(JobID uint32) error

func DeleteProfile added in v1.6.0

func DeleteProfile(name string) error

DeleteProfile - Delete a profile from the database

func GetByCrackFileByID added in v1.6.0

func GetByCrackFileByID(id string) (*models.CrackFile, error)

GetByCrackFileByID - Get a crack task by its ID

func GetCertificateInfo added in v1.6.0

func GetCertificateInfo(categoryOptions uint32, cn string) ([]*models.Certificate, error)

Certificates

func GetCrackTaskByID added in v1.6.0

func GetCrackTaskByID(id string) (*models.CrackTask, error)

GetCrackTaskByID - Get a crack task by its ID

func GetKeyValue added in v1.5.0

func GetKeyValue(key string) (string, error)

GetKeyValue - Get a value from a key

func HTTPC2ConfigUpdate added in v1.6.0

func HTTPC2ConfigUpdate(newConf *clientpb.HTTPC2Config, oldConf *clientpb.HTTPC2Config) error

func HostByHostID added in v1.5.0

func HostByHostID(id uuid.UUID) (*clientpb.Host, error)

HostByHostID - Get host by the session's reported HostUUID

func HostByHostUUID added in v1.5.0

func HostByHostUUID(id string) (*models.Host, error)

HostByHostUUID - Get host by the session's reported HostUUID

func IOCByID added in v1.5.0

func IOCByID(id string) (*clientpb.IOC, error)

IOCByID - Select an IOC by ID

func ImplantBuildByID added in v1.6.0

func ImplantBuildByID(id string) (*clientpb.ImplantBuild, error)

ImplantBuildByID - Fetch implant build from ID

func ImplantBuildByName

func ImplantBuildByName(name string) (*clientpb.ImplantBuild, error)

ImplantBuildByName - Fetch implant build by name

func ImplantBuildByPublicKeyDigest added in v1.6.0

func ImplantBuildByPublicKeyDigest(publicKeyDigest [32]byte) (*clientpb.ImplantBuild, error)

ImplantBuildByPublicKeyDigest - Fetch implant build by it's ecc public key

func ImplantBuildByResourceID added in v1.6.0

func ImplantBuildByResourceID(resourceID uint64) (*clientpb.ImplantBuild, error)

ImplantBuildByResourceID - Fetch implant build from resource ID

func ImplantBuilds

func ImplantBuilds() (*clientpb.ImplantBuilds, error)

ImplantBuilds - Return all implant builds

func ImplantConfigByID added in v1.5.0

func ImplantConfigByID(id string) (*clientpb.ImplantConfig, error)

ImplantConfigByID - Fetch implant config by id

func ImplantConfigWithC2sByID added in v1.5.30

func ImplantConfigWithC2sByID(id string) (*clientpb.ImplantConfig, error)

ImplantConfigWithC2sByID - Fetch implant build by name

func ImplantProfileByName

func ImplantProfileByName(name string) (*clientpb.ImplantProfile, error)

ImplantProfileByName - Fetch implant build by name

func ImplantProfileNames

func ImplantProfileNames() ([]string, error)

ImplantProfileNames - Fetch a list of all build names

func ImplantProfiles

func ImplantProfiles() ([]*clientpb.ImplantProfile, error)

ImplantProfiles - Fetch a map of name<->profiles current in the database

func ListBeacons added in v1.5.0

func ListBeacons() ([]*clientpb.Beacon, error)

ListBeacons - Select a Beacon by ID

func ListCanaries

func ListCanaries() ([]*clientpb.DNSCanary, error)

ListCanaries - List of all embedded canaries

func ListHosts added in v1.5.0

func ListHosts() ([]*clientpb.Host, error)

ListHosts - List of all hosts in the database

func ListenerByJobID added in v1.6.0

func ListenerByJobID(JobID uint32) (*clientpb.ListenerJob, error)

func ListenerJobs added in v1.6.0

func ListenerJobs() ([]*clientpb.ListenerJob, error)

func LoadHTTPC2ConfigByName added in v1.6.0

func LoadHTTPC2ConfigByName(name string) (*clientpb.HTTPC2Config, error)

func LoadHTTPC2s added in v1.6.0

func LoadHTTPC2s() ([]*clientpb.HTTPC2Config, error)

func OperatorAll added in v1.5.0

func OperatorAll() ([]*models.Operator, error)

OperatorAll - Select all operators from the database

func OperatorByToken added in v1.5.0

func OperatorByToken(value string) (*models.Operator, error)

OperatorByToken - Select an operator by token value

func PendingBeaconTasksByBeaconID added in v1.5.0

func PendingBeaconTasksByBeaconID(id string) ([]*models.BeaconTask, error)

PendingBeaconTasksByBeaconID - Select a Beacon by ID, ordered by creation time

func PlaintextCredentialsByHashType added in v1.6.0

func PlaintextCredentialsByHashType(hashType clientpb.HashType) ([]*clientpb.Credential, error)

PlaintextCredentials

func ProfileByName

func ProfileByName(name string) (*clientpb.ImplantProfile, error)

ProfileByName - Fetch a single profile from the database

func RemoveContent added in v1.6.0

func RemoveContent(id string) error

func RemoveWebSite added in v1.6.0

func RemoveWebSite(id string) error

func RenameBeacon added in v1.5.5

func RenameBeacon(id string, name string) error

RenameBeacon - Rename a beacon

func ResourceIDByName added in v1.6.0

func ResourceIDByName(name string) (*clientpb.ResourceID, error)

ResourceID by name

func ResourceIDByType added in v1.6.0

func ResourceIDByType(resourceType string) ([]*clientpb.ResourceID, error)

ResourceID queries

func ResourceIDByValue added in v1.6.0

func ResourceIDByValue(id uint64) (*clientpb.ResourceID, error)

ResourceID by value

func ResourceIDs added in v1.6.0

func ResourceIDs() ([]*clientpb.ResourceID, error)

func SaveC2Listener added in v1.6.0

func SaveC2Listener(listenerConf *clientpb.ListenerJob) error

func SaveHTTPC2Config added in v1.6.0

func SaveHTTPC2Config(httpC2Config *clientpb.HTTPC2Config) error

func SaveImplantBuild added in v1.6.0

func SaveImplantBuild(ib *clientpb.ImplantBuild) (*clientpb.ImplantBuild, error)

SaveImplantBuild

func SaveImplantConfig added in v1.6.0

func SaveImplantConfig(ic *clientpb.ImplantConfig) (*clientpb.ImplantConfig, error)

SaveImplantConfig

func SaveResourceID added in v1.6.0

func SaveResourceID(r *clientpb.ResourceID) error

func SaveWatchTowerConfig added in v1.6.0

func SaveWatchTowerConfig(m *clientpb.MonitoringProvider) error

func Session

func Session() *gorm.DB

Session - Database session

func SetKeyValue added in v1.5.0

func SetKeyValue(key string, value string) error

SetKeyValue - Set the value for a key/value pair

func UpdateBeaconCheckinByID added in v1.5.0

func UpdateBeaconCheckinByID(id string, next int64) error

UpdateBeaconCheckinByID - Update the beacon's last / next checkin

func UpdateHTTPC2Listener added in v1.6.0

func UpdateHTTPC2Listener(listenerConf *clientpb.ListenerJob) error

func WGPeerIPs added in v1.4.9

func WGPeerIPs() ([]string, error)

WGPeerIPs - Fetch a list of ips for all wireguard peers

func WatchTowerConfigDel added in v1.6.0

func WatchTowerConfigDel(m *clientpb.MonitoringProvider) error

func WatchTowerConfigs added in v1.6.0

func WatchTowerConfigs() ([]*clientpb.MonitoringProvider, error)

watchtower - List configurations

func WebContentByIDAndPath added in v1.6.0

func WebContentByIDAndPath(id string, path string, webContentDir string, eager bool) (*clientpb.WebContent, error)

WebContent by ID and path

func WebsiteByName

func WebsiteByName(name string, webContentDir string) (*clientpb.Website, error)

WebsiteByName - Get website by name

func Websites added in v1.6.0

func Websites(webContentDir string) ([]*clientpb.Website, error)

Websites - Return all websites

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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