db

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

README

DB

GORM-based database interactions.

Contents:
  • gosqlite/ - A fork of the GORM sqlite driver that uses a pure go sqlite3 implementation. This can be compiled using the Go build tag gosqlite
  • models/ - The database/GORM models
  • db.go - Primary abstraction for client and db sessions
  • helpers.go - Helper functions for querying the GORM models
  • logger.go - Database logger
  • sql_cgo.go - The CGO sqlite client
  • sql_go.go - The pure Go sqlite client
  • sql.go - Database setup and configuration

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

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

AddContent - Add content to website

func AddWebSite

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

AddWebsite - Return website, create if it does not exist

func AllCrackFiles

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

func BeaconByID

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

BeaconByID - Select a Beacon by ID

func BeaconTaskByEnvelopeID

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

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

func BeaconTaskByID

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

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

func BeaconTasksByBeaconID

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

func CheckKeyExReplay(ciphertext []byte) error

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

func CountTasksByBeaconID

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

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

func CrackFilesByType

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

CrackFilesByType - Get all files by crack file type

func CrackFilesDiskUsage

func CrackFilesDiskUsage() (int64, error)

CrackFilesDiskUsage - Get all files by crack file type

func CrackWordlistByName

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

CrackWordlistByName - Get all files by crack file type

func CrackstationByHostUUID

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

CrackstationByHostUUID - Get crackstation by the session's reported HostUUID

func CredentialByID

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

CredentialsByID

func CredentialsByCollection

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

CredentialsByHashType

func CredentialsByHashType

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

CredentialsByHashType

func DeleteC2

func DeleteC2(c2ID uuid.UUID) error

func DeleteKeyValue

func DeleteKeyValue(key string, value string) error

DeleteKeyValue - Delete a key/value pair

func DeleteListener

func DeleteListener(JobID uint32) error

func DeleteProfile

func DeleteProfile(name string) error

DeleteProfile - Delete a profile from the database

func GetByCrackFileByID

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

GetByCrackFileByID - Get a crack task by its ID

func GetCertificateInfo

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

Certificates

func GetCrackTaskByID

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

GetCrackTaskByID - Get a crack task by its ID

func GetKeyValue

func GetKeyValue(key string) (string, error)

GetKeyValue - Get a value from a key

func HTTPC2ConfigUpdate

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

func HostByHostID

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

HostByHostID - Get host by the session's reported HostUUID

func HostByHostUUID

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

HostByHostUUID - Get host by the session's reported HostUUID

func IOCByID

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

IOCByID - Select an IOC by ID

func ImplantBuildByID

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

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

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

func ImplantBuildByResourceID

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

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

ImplantConfigByID - Fetch implant config by id

func ImplantConfigWithC2sByID

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

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

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

ListHosts - List of all hosts in the database

func ListenerByJobID

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

func ListenerJobs

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

func LoadHTTPC2ConfigByName

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

func LoadHTTPC2s

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

func OperatorAll

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

OperatorAll - Select all operators from the database

func OperatorByToken

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

OperatorByToken - Select an operator by token value

func PendingBeaconTasksByBeaconID

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

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

func PlaintextCredentialsByHashType

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

func RemoveContent(id string) error

func RemoveWebSite

func RemoveWebSite(id string) error

func RenameBeacon

func RenameBeacon(id string, name string) error

RenameBeacon - Rename a beacon

func ResourceIDByName

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

ResourceID by name

func ResourceIDByType

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

ResourceID queries

func ResourceIDByValue

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

ResourceID by value

func ResourceIDs

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

func SaveHTTPC2Config

func SaveHTTPC2Config(httpC2Config *clientpb.HTTPC2Config) error

func SaveHTTPC2Listener

func SaveHTTPC2Listener(listenerConf *clientpb.ListenerJob) error

func SaveImplantBuild

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

SaveImplantBuild

func SaveImplantConfig

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

SaveImplantConfig

func SaveResourceID

func SaveResourceID(r *clientpb.ResourceID) error

func SaveWatchTowerConfig

func SaveWatchTowerConfig(m *clientpb.MonitoringProvider) error

func SearchStageExtensions

func SearchStageExtensions(stagerExtension string, profileName string) error

used to prevent duplicate stager extensions

func SearchStartSessionExtensions

func SearchStartSessionExtensions(StartSessionFileExt string, profileName string) error

used to prevent duplicate start session extensions

func Session

func Session() *gorm.DB

Session - Database session

func SetKeyValue

func SetKeyValue(key string, value string) error

SetKeyValue - Set the value for a key/value pair

func UpdateBeaconCheckinByID

func UpdateBeaconCheckinByID(id string, next int64) error

UpdateBeaconCheckinByID - Update the beacon's last / next checkin

func UpdateHTTPC2Listener

func UpdateHTTPC2Listener(listenerConf *clientpb.ListenerJob) error

func WGPeerIPs

func WGPeerIPs() ([]string, error)

WGPeerIPs - Fetch a list of ips for all wireguard peers

func WatchTowerConfigDel

func WatchTowerConfigDel(m *clientpb.MonitoringProvider) error

func WatchTowerConfigs

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

watchtower - List configurations

func WebContentByIDAndPath

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

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