lib

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const AgentVersion = "0.1.1"

Variables

View Source
var (
	Configuration    AgentConfiguration // AgentConfiguration represents the configuration of the agent.
	Context          context.Context
	APIConfiguration cipherswarm.Configuration
)
View Source
var (
	AppFs  = afero.NewOsFs()
	Logger = log.NewWithOptions(os.Stderr, log.Options{
		Prefix:          "cipherswarm-agent",
		Level:           log.InfoLevel,
		ReportTimestamp: true,
		ReportCaller:    true,
	})
)

Functions

func AcceptTask

func AcceptTask(task *cipherswarm.Task) bool

func AuthenticateAgent

func AuthenticateAgent() (int64, error)

AuthenticateAgent authenticates the agent with the CipherSwarm API. It sends an authentication request to the API and returns the agent ID if successful. If there is an error connecting to the API or if the authentication fails, an error is returned.

func CleanString

func CleanString(s string) string

func CleanUpDanglingProcess

func CleanUpDanglingProcess(pidFilePath string) (bool, error)

CleanUpDanglingProcess checks for dangling processes and performs cleanup if necessary. It takes a `pidFilePath` string parameter which specifies the path to the PID file. The `killIfFound` boolean parameter determines whether to kill the process if it is found. It returns a boolean value indicating whether the cleanup was performed successfully, and an error if any occurred during the cleanup process.

func CreateDataDirs

func CreateDataDirs() error

func CreateLockFile

func CreateLockFile() (afero.File, error)

CreateLockFile creates a lock file at the specified path using the configured PID file path. It returns the created file and any error encountered during the process.

func DownloadFiles

func DownloadFiles(attack *cipherswarm.Attack) error

func GetAttackMode

func GetAttackMode(a *cipherswarm.Attack) uint8

func GetAttackParameters

func GetAttackParameters(attackID int64) (*cipherswarm.Attack, error)

func GetCurrentHashcatVersion

func GetCurrentHashcatVersion() (string, error)

GetCurrentHashcatVersion retrieves the current version of Hashcat. It checks if the Hashcat directory exists and then uses the arch.GetHashcatVersion function to get the version from the specified path. If the Hashcat directory does not exist, it returns "0.0.0" and an error. If there is an error retrieving the version, it also returns "0.0.0" and the error. Otherwise, it returns the Hashcat version and no error.

func GetLastBenchmarkDate

func GetLastBenchmarkDate(agentID int64) (time.Time, error)

func GetNewTask

func GetNewTask() (*cipherswarm.Task, error)

func GetPlatform

func GetPlatform() string

GetPlatform returns the platform of the current system.

func GetRulelistFilenames

func GetRulelistFilenames(a *cipherswarm.Attack) []string

func GetWordlistFilenames

func GetWordlistFilenames(a *cipherswarm.Attack) []string

func MarkTaskExhausted

func MarkTaskExhausted(task *cipherswarm.Task)

func RunAttackTask

func RunAttackTask(sess *hashcat.HashcatSession, task *cipherswarm.Task)

func RunTask

func RunTask(task *cipherswarm.Task, attack *cipherswarm.Attack)

func SendBenchmarkResults

func SendBenchmarkResults(agentID int64, benchmarkResults []BenchmarkResult) error

func SendCrackedHash

func SendCrackedHash(hash hashcat.HashcatResult, task *cipherswarm.Task)

func SendHeartBeat

func SendHeartBeat(agentID int64)

func SendStatusUpdate

func SendStatusUpdate(update hashcat.HashcatStatus, task *cipherswarm.Task)

func UpdateAgentMetadata

func UpdateAgentMetadata(agentID int64)

UpdateAgentMetadata updates the metadata of an agent. It takes a client object and an agent ID as parameters. It retrieves the host information and constructs an AgentMetadata object. The AgentMetadata object includes the agent's name, client signature, devices, and operating system. The agent metadata is then sent to the server using a PUT request. If there is an error retrieving the host information or updating the agent metadata, an error message is logged. The updated agent metadata is also logged for debugging purposes.

func UpdateBenchmarks

func UpdateBenchmarks(agentID int64)

func UpdateClientConfig

func UpdateClientConfig()

UpdateClientConfig updates the client configuration settings. It sets the API version and advanced configuration settings based on the values in the Configuration struct. It then writes the updated configuration to the config file using viper.WriteConfig(). If there is an error while writing the config file, it logs the error.

func UpdateCracker

func UpdateCracker()

UpdateCracker checks for an updated version of the cracker and performs the necessary actions. It takes a client object as a parameter and uses it to make a request to check for updates. If an updated version is available, it logs the information about the latest version. If any errors occur during the process, they are logged as well.

Types

type AgentConfiguration

type AgentConfiguration struct {
	Config struct {
		UseNativeHashcat    bool   `json:"use_native_hashcat" yaml:"use_native_hashcat"` // UseNativeHashcat specifies whether to use the native Hashcat implementation.
		AgentUpdateInterval int32  `json:"agent_update_interval" yaml:"agent_update_interval"`
		BackendDevices      string `json:"backend_devices,omitempty" yaml:"backend_devices,omitempty"`
	} `json:"config" yaml:"config"`
	APIVersion int32 `json:"api_version" yaml:"api_version"` // ApiVersion represents the version of the API used by the agent client.
}

func GetAgentConfiguration

func GetAgentConfiguration() (AgentConfiguration, error)

GetAgentConfiguration retrieves the agent configuration from the CipherSwarm API. It returns an AgentConfiguration struct and an error if there was a problem connecting to the API or if the response was not successful.

type BenchmarkResult

type BenchmarkResult struct {
	Device    string `json:"device,omitempty"`
	HashType  string `json:"hash_type,omitempty"`
	RuntimeMs string `json:"runtime,omitempty"`
	SpeedHs   string `json:"hash_speed,omitempty"`
}

func RunBenchmarkTask

func RunBenchmarkTask(sess *hashcat.HashcatSession) ([]BenchmarkResult, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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