Documentation ¶
Index ¶
- Constants
- Variables
- func AddJobCrackedHash(jobId string, hash string, plaintextHex string) error
- func AddJobStatusUpdate(jobId string, status hashcattypes.HashcatStatus) error
- func AddJobStdline(jobId string, stream string, line string) error
- func AppendToHashlist(newHashes []HashlistHash) (int64, error)
- func Connect(dsn string) error
- func DeleteAgentRegistrationKey(id string) error
- func DeleteAttack(attackId string) error
- func DeleteAttackTemplate(id string) error
- func DeleteAttackTemplateSet(id string) error
- func DeleteHashlist(hashlistId string) error
- func DeleteProject(projectId string) error
- func DeleteProjectShare(projId string, userId string) error
- func FindAgentIDByAuthKey(authKey string) (string, error)
- func GetAll[T any]() ([]T, error)
- func GetAttackProjID(attackId string) (string, error)
- func GetByID[T any](id string) (*T, error)
- func GetConfig[ConfigT interface{}]() (*ConfigT, error)
- func GetConfigJSONString() (string, error)
- func GetHashlistProjID(hashlistId string) (string, error)
- func GetInstance() *gorm.DB
- func GetJobHashtype(jobId string) (uint, error)
- func GetJobProjID(jobId string) (string, error)
- func HardDelete[T any](obj *T) error
- func MarkListfileAsAvailable(id string) error
- func MarkListfileForDeletion(id string) error
- func NormalizeUsername(username string) string
- func PopulateHashlistFromPotfile(hashlistId string) (int64, error)
- func Save[T any](obj *T) error
- func SeedConfig[ConfigT interface{}](defaultConfig ConfigT) error
- func SetAttackProgressString(attackId string, progressString string) error
- func SetConfig[ConfigT interface{}](newConf ConfigT) error
- func SetJobExited(jobId string, reason string, errStr string, exitTime time.Time) error
- func SetJobScheduled(jobId string, agentId string) error
- func SetJobStarted(jobId string, cmdLine string, startTime time.Time) error
- func SoftDelete[T any](obj *T) error
- func UpdateAgentDevices(agentId string, devices []hashcattypes.HashcatStatusDevice) error
- func UpdateAgentInfo(agentId string, info AgentInfo) error
- func UpdateAgentMaintenanceMode(agentId string, isMaintenance bool) error
- func UpdateAgentStatus(agentId string, status string) error
- func WipeEverything() error
- type Agent
- func CreateAgent(name string, ephemeral bool) (newAgent *Agent, plaintextKey string, err error)
- func FindAgentByAuthKey(authKey string) (*Agent, error)
- func GetAgent(id string) (*Agent, error)
- func GetAllAgents() ([]Agent, error)
- func GetAllHealthyAgents() ([]Agent, error)
- func GetAllSchedulableAgents() ([]Agent, error)
- type AgentDeviceInfo
- type AgentFile
- type AgentInfo
- type AgentRegistrationKey
- type Attack
- type AttackIDTree
- type AttackTemplate
- type AttackTemplateSet
- type Config
- type Hashlist
- type HashlistHash
- type Job
- func CreateJob(job *Job) (*Job, error)
- func CreateJobTx(job *Job, tx *gorm.DB) (*Job, error)
- func GetAllIncompleteJobs(includeRuntimeData bool) ([]Job, error)
- func GetAllPendingJobs(includeRuntimeData bool) ([]Job, error)
- func GetJob(jobId string, includeRuntimeData bool) (*Job, error)
- func GetJobsForAttack(attackId string, includeRuntimeData bool, includeTargetHashes bool) ([]Job, error)
- func GetJobsForHashlist(hashlistId string) ([]Job, error)
- func GetJobsForProject(projectId string) ([]Job, error)
- type JobRuntimeData
- type JobRuntimeOutputLine
- type Listfile
- func CreateListfile(listfile *Listfile) (*Listfile, error)
- func GetAllListfiles() ([]Listfile, error)
- func GetAllListfilesAvailableToProject(projectID string) ([]Listfile, error)
- func GetAllProjectSpecificListfiles(projectID string) ([]Listfile, error)
- func GetAllPublicListfiles() ([]Listfile, error)
- func GetAllPublicRulefiles() ([]Listfile, error)
- func GetAllPublicWordlists() ([]Listfile, error)
- func GetListfile(id string) (*Listfile, error)
- type PotfileEntry
- type PotfileSearchResult
- type Project
- type ProjectShare
- type ProjectShares
- type RunningJobCountForUser
- type RunningJobCountPerUserList
- type RunningJobForUser
- type RunningJobsForUser
- type SimpleBaseModel
- type UUIDBaseModel
- type User
- func GetAllUsers() ([]User, error)
- func GetServiceAccountByAPIKey(key string) (*User, error)
- func GetUserByID(id string) (*User, error)
- func GetUserByUsername(username string) (*User, error)
- func RegisterServiceAccount(username string, apiKey string, roles []string) (*User, error)
- func RegisterUserWithCredentials(username, password string, roles []string) (*User, error)
- func RegisterUserWithoutPassword(username string, roles []string) (*User, error)
Constants ¶
View Source
const ( AgentStatusHealthy = "AgentStatusHealthy" AgentStatusUnhealthyButConnected = "AgentStatusUnhealthyButConnected" AgentStatusUnhealthyAndDisconnected = "AgentStatusUnhealthyAndDisconnected" AgentStatusDead = "AgentStatusDead" )
View Source
const ( JobStatusCreated = "JobStatus-Created" JobStatusAwaitingStart = "JobStatus-AwaitingStart" JobStatusStarted = "JobStatus-Started" JobStatusExited = "JobStatus-Exited" )
View Source
const ( // Clean exit JobStopReasonFinished = "JobStopReason-Finished" // User stopped it JobStopReasonUserStopped = "JobStopReason-UserStopped" // Never started in the first place JobStopReasonFailedToStart = "JobStopReason-FailedToStart" // General failure JobStopReasonFailed = "JobStopReason-Failed" // Agent timed out and we lost contact JobStopReasonTimeout = "JobStopReason-Timeout" )
View Source
const ( JobStdLineStreamStdout = "stdout" JobStdLineStreamStderr = "stderr" )
View Source
const ( ListfileTypeWordlist = "Wordlist" ListfileTypeRulefile = "Rulefile" ListfileTypeHashlist = "Hashlist" ListfileTypeCharset = "Charset" )
View Source
const AttackTemplateSetType = "attack-template-set"
View Source
const AttackTemplateType = "attack-template"
View Source
const MaxJobOutputs = 10
TODO: actually, on second thought, I want to keep all stderr lines, and only roll-over stdout lines
View Source
const UserPasswordLocked = "*"
Variables ¶
View Source
var ErrNotFound = gorm.ErrRecordNotFound
Functions ¶
func AddJobCrackedHash ¶
func AddJobStatusUpdate ¶
func AddJobStatusUpdate(jobId string, status hashcattypes.HashcatStatus) error
func AppendToHashlist ¶
func AppendToHashlist(newHashes []HashlistHash) (int64, error)
Caller must ensure HashlistHash.HashlistID is set correctly
func DeleteAttackTemplate ¶
func DeleteAttackTemplateSet ¶
func DeleteProject ¶
Also deletes hashlists, attacks, jobs
func DeleteProjectShare ¶
func FindAgentIDByAuthKey ¶
func GetAttackProjID ¶
func GetConfigJSONString ¶
func GetHashlistProjID ¶
func GetInstance ¶
func GetJobHashtype ¶
func GetJobProjID ¶
func HardDelete ¶
func MarkListfileAsAvailable ¶
func MarkListfileForDeletion ¶
func NormalizeUsername ¶
func SeedConfig ¶
func SeedConfig[ConfigT interface{}](defaultConfig ConfigT) error
func SetAttackProgressString ¶
func SetJobExited ¶
func SetJobScheduled ¶
func SoftDelete ¶
func UpdateAgentDevices ¶
func UpdateAgentDevices(agentId string, devices []hashcattypes.HashcatStatusDevice) error
func UpdateAgentInfo ¶
func UpdateAgentStatus ¶
func WipeEverything ¶
func WipeEverything() error
Types ¶
type Agent ¶
type Agent struct { UUIDBaseModel Name string KeyHash string IsMaintenanceMode bool `gorm:"default:false; not null"` Ephemeral bool AgentInfo datatypes.JSONType[AgentInfo] AgentDevices datatypes.JSONType[AgentDeviceInfo] }
func CreateAgent ¶
func FindAgentByAuthKey ¶
func GetAllAgents ¶
func GetAllHealthyAgents ¶
func GetAllSchedulableAgents ¶
type AgentDeviceInfo ¶
type AgentDeviceInfo struct {
Devices []hashcattypes.HashcatStatusDevice
}
type AgentInfo ¶
type AgentInfo struct { Status string `json:"status"` Version string `json:"version"` TimeOfLastHeartbeat time.Time `json:"time_of_last_heartbeat,omitempty"` TimeOfLastDisconnect time.Time `json:"time_of_last_disconnect,omitempty"` TimeOfLastConnect time.Time `json:"time_of_last_connect,omitempty"` AvailableListfiles []AgentFile `json:"available_listfiles,omitempty"` ActiveJobIDs []string `json:"active_job_ids,omitempty"` }
func (AgentInfo) ToDTO ¶
func (a AgentInfo) ToDTO() apitypes.AgentInfoDTO
type AgentRegistrationKey ¶
type AgentRegistrationKey struct { SimpleBaseModel Name string KeyHint string KeyHash string ForEphemeralAgent bool }
func CreateAgentRegistrationKey ¶
func CreateAgentRegistrationKey(name string, ephemeral bool) (newKey *AgentRegistrationKey, plaintextKey string, err error)
func GetAgentRegistrationKeyByKey ¶
func GetAgentRegistrationKeyByKey(key string) (*AgentRegistrationKey, error)
func GetAllAgentRegistrationKeys ¶
func GetAllAgentRegistrationKeys() ([]AgentRegistrationKey, error)
func (AgentRegistrationKey) ToDTO ¶
func (a AgentRegistrationKey) ToDTO() apitypes.AdminGetAgentRegistrationKeyDTO
type Attack ¶
type Attack struct { UUIDBaseModel HashcatParams datatypes.JSONType[hashcattypes.HashcatParams] IsDistributed bool ProgressString string Jobs []Job `gorm:"constraint:OnDelete:CASCADE;"` HashlistID uuid.UUID `gorm:"type:uuid"` }
func CreateAttack ¶
type AttackIDTree ¶
func GetAllAttacksWithProgressStringsForUser ¶
func GetAllAttacksWithProgressStringsForUser(user *User) ([]AttackIDTree, error)
func (*AttackIDTree) ToDTO ¶
func (a *AttackIDTree) ToDTO() apitypes.AttackIDTreeDTO
type AttackTemplate ¶
type AttackTemplate struct { UUIDBaseModel Name string HashcatParams datatypes.JSONType[hashcattypes.HashcatParams] CreatedByUser User `gorm:"constraint:OnDelete:SET NULL;"` CreatedByUserID uuid.UUID `gorm:"type:uuid"` }
func CreateAttackTemplate ¶
func CreateAttackTemplate(attackTemplate *AttackTemplate) (*AttackTemplate, error)
func GetAllAttackTemplates ¶
func GetAllAttackTemplates() ([]AttackTemplate, error)
func GetAttackTemplate ¶
func GetAttackTemplate(id string) (*AttackTemplate, error)
func (AttackTemplate) ToDTO ¶
func (at AttackTemplate) ToDTO() apitypes.AttackTemplateDTO
type AttackTemplateSet ¶
type AttackTemplateSet struct { UUIDBaseModel Name string AttackTemplateIDs datatypes.JSONSlice[string] CreatedByUser User `gorm:"constraint:OnDelete:SET NULL;"` CreatedByUserID uuid.UUID `gorm:"type:uuid"` }
func CreateAttackTemplateSet ¶
func CreateAttackTemplateSet(templateSet *AttackTemplateSet) (*AttackTemplateSet, error)
func GetAllAttackTemplateSets ¶
func GetAllAttackTemplateSets() ([]AttackTemplateSet, error)
func GetAttackTemplateSet ¶
func GetAttackTemplateSet(id string) (*AttackTemplateSet, error)
func (AttackTemplateSet) ToDTO ¶
func (at AttackTemplateSet) ToDTO() apitypes.AttackTemplateDTO
type Config ¶
type Config struct { SimpleBaseModel Config datatypes.JSON }
type Hashlist ¶
type Hashlist struct { UUIDBaseModel ProjectID uuid.UUID `gorm:"type:uuid"` Name string Version uint HashType int Hashes []HashlistHash `gorm:"constraint:OnDelete:CASCADE;"` HasUsernames bool Attacks []Attack `gorm:"constraint:OnDelete:CASCADE;"` }
func CreateHashlist ¶
func GetHashlist ¶
func GetHashlistWithHashes ¶
type HashlistHash ¶
type HashlistHash struct { SimpleBaseModel HashlistID uuid.UUID `gorm:"type:uuid"` NormalizedHash string InputHash string PlaintextHex string Username string IsCracked bool IsUnexpected bool }
func (*HashlistHash) ToDTO ¶
func (h *HashlistHash) ToDTO() apitypes.HashlistHashDTO
type Job ¶
type Job struct { UUIDBaseModel HashlistVersion uint Attack Attack AttackID *uuid.UUID `gorm:"type:uuid"` HashcatParams datatypes.JSONType[hashcattypes.HashcatParams] TargetHashes pq.StringArray `gorm:"type:text[]"` HashType int RuntimeData JobRuntimeData `gorm:"constraint:OnDelete:CASCADE;"` AssignedAgent Agent `gorm:"constraint:OnDelete:SET NULL;"` AssignedAgentID *uuid.UUID `gorm:"type:uuid"` }
func GetAllIncompleteJobs ¶
func GetAllPendingJobs ¶
func GetJobsForAttack ¶
func GetJobsForHashlist ¶
func GetJobsForProject ¶
func (*Job) ToSimpleDTO ¶
func (j *Job) ToSimpleDTO() apitypes.JobSimpleDTO
type JobRuntimeData ¶
type JobRuntimeData struct { SimpleBaseModel JobID uuid.UUID `gorm:"type:uuid"` // when we ask the job to start StartRequestTime time.Time // when it actually starts on the agent StartedTime time.Time StoppedTime time.Time Status string StopReason string ErrorString string CmdLine string // hashcat command OutputLines pgJSONBArray[JobRuntimeOutputLine] StatusUpdates pgJSONBArray[hashcattypes.HashcatStatus] }
func (JobRuntimeData) ToDTO ¶
func (r JobRuntimeData) ToDTO() apitypes.JobRuntimeDataDTO
func (*JobRuntimeData) ToSummaryDTO ¶
func (r *JobRuntimeData) ToSummaryDTO() apitypes.JobRuntimeSummaryDTO
type JobRuntimeOutputLine ¶
type Listfile ¶
type Listfile struct { UUIDBaseModel Name string AvailableForDownload bool AvailableForUse bool FileType string SizeInBytes uint64 Lines uint64 PendingDelete bool CreatedByUser User `gorm:"constraint:OnDelete:SET NULL;"` CreatedByUserID uuid.UUID `gorm:"type:uuid"` AttachedProjectID *uuid.UUID `gorm:"type:uuid"` AttachedProject *Project `gorm:"constraint:OnDelete:SET NULL;"` }
func CreateListfile ¶
func GetAllListfiles ¶
func GetAllPublicListfiles ¶
func GetAllPublicRulefiles ¶
A "Public" listfile is a listfile which is not attached to a specific project
func GetAllPublicWordlists ¶
func GetListfile ¶
func (*Listfile) ToDTO ¶
func (w *Listfile) ToDTO() apitypes.ListfileDTO
type PotfileEntry ¶
type PotfileEntry struct { UUIDBaseModel Hash string `gorm:"index:idx_potfile_hash,type:hash"` PlaintextHex string HashType uint }
func AddPotfileEntry ¶
func AddPotfileEntry(newEntry *PotfileEntry) (*PotfileEntry, error)
type PotfileSearchResult ¶
type PotfileSearchResult struct { Entry *PotfileEntry Hash string Found bool }
func SearchPotfile ¶
func SearchPotfile(hashes []string) ([]PotfileSearchResult, error)
func (PotfileSearchResult) ToDTO ¶
func (r PotfileSearchResult) ToDTO() apitypes.PotfileSearchResultDTO
type Project ¶
type Project struct { UUIDBaseModel Name string Description string Hashlists []Hashlist `gorm:"constraint:OnDelete:CASCADE;"` OwnerUser User `gorm:"constraint:OnDelete:SET NULL;"` OwnerUserID uuid.UUID `gorm:"type:uuid"` }
func CreateProject ¶
func GetAllProjects ¶
func GetAllProjectsForUser ¶
func GetProject ¶
func (*Project) ToDTO ¶
func (p *Project) ToDTO() apitypes.ProjectDTO
type ProjectShare ¶
type ProjectShare struct {}
func CreateProjectShare ¶
func CreateProjectShare(share *ProjectShare) (*ProjectShare, error)
type ProjectShares ¶
type ProjectShares []ProjectShare
func GetProjectShares ¶
func GetProjectShares(projId string) (ProjectShares, error)
func (ProjectShares) ToDTO ¶
func (shares ProjectShares) ToDTO() apitypes.ProjectSharesDTO
type RunningJobCountForUser ¶
type RunningJobCountPerUserList ¶
type RunningJobCountPerUserList []RunningJobCountForUser
func GetRunningJobCountPerUser ¶
func GetRunningJobCountPerUser() (RunningJobCountPerUserList, error)
func (RunningJobCountPerUserList) ToDTO ¶
func (l RunningJobCountPerUserList) ToDTO() apitypes.RunningJobCountPerUsersDTO
type RunningJobForUser ¶
type RunningJobForUser struct { ProjectID uuid.UUID HashlistID uuid.UUID AttackID uuid.UUID JobID uuid.UUID }
func (*RunningJobForUser) ToDTO ¶
func (j *RunningJobForUser) ToDTO() apitypes.RunningJobForUserDTO
type RunningJobsForUser ¶
type RunningJobsForUser []RunningJobForUser
func GetAllRunningJobsForUser ¶
func GetAllRunningJobsForUser(user *User) (RunningJobsForUser, error)
func (RunningJobsForUser) ToDTO ¶
func (jobs RunningJobsForUser) ToDTO() []apitypes.RunningJobForUserDTO
type SimpleBaseModel ¶
type SimpleBaseModel struct {
ID uint `gorm:"primarykey"`
}
type UUIDBaseModel ¶
type UUIDBaseModel struct { ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` }
Same as gorm default, except uses uuid instead of uint
type User ¶
type User struct { UUIDBaseModel Username string `gorm:"uniqueIndex"` PasswordHash string Roles datatypes.JSONSlice[string] APIKeyHash string // Only for service accounts MFAType string MFAData datatypes.JSON }
func GetAllUsers ¶
func GetUserByID ¶
func GetUserByUsername ¶
func RegisterServiceAccount ¶
caller is responsible for ensuring service account role is present
func (*User) IsPasswordLocked ¶
func (*User) ToAdminDTO ¶
func (u *User) ToAdminDTO() apitypes.AdminGetUserDTO
func (*User) ToMinimalDTO ¶
func (u *User) ToMinimalDTO() apitypes.UserMinimalDTO
Click to show internal directories.
Click to hide internal directories.