Documentation ¶
Index ¶
- Constants
- Variables
- func AbandonTask(task *components.Task)
- func AcceptTask(task *components.Task) error
- func AuthenticateAgent() error
- func CheckForExistingClient(pidFilePath string) bool
- func CreateDataDirs() error
- func CreateLockFile() error
- func DisplayAuthenticated()
- func DisplayInactive(sleepTime time.Duration)
- func DisplayNewAttack(attack *components.Attack)
- func DisplayNewTask(task *components.Task)
- func DisplayRunTaskAccepted(task *components.Task)
- func DisplayShuttingDown()
- func DisplayStartup()
- func DownloadFiles(attack *components.Attack) error
- func GetAgentConfiguration() error
- func GetAttackParameters(attackID int64) (*components.Attack, error)
- func GetNewTask() (*components.Task, error)
- func RunTask(task *components.Task, attack *components.Attack) error
- func SendAgentError(stdErrLine string, task *components.Task, severity operations.Severity)
- func SendAgentShutdown()
- func SendHeartBeat() *operations.State
- func UpdateAgentMetadata() error
- func UpdateBenchmarks() error
- func UpdateCracker()
Constants ¶
const AgentVersion = "0.5.5"
AgentVersion represents the current version of the agent software as a string.
Variables ¶
var ( Configuration agentConfiguration // Configuration represents the configuration of the agent. Context context.Context // Context represents the context of the agent. SdkClient *sdk.CipherSwarmAgentSDK // SdkClient is the client for interacting with the CipherSwarm API. )
Functions ¶
func AbandonTask ¶ added in v0.2.0
func AbandonTask(task *components.Task)
AbandonTask sets the given task to an abandoned state using the SdkClient and logs any errors that occur. If the task is nil, it logs an error and returns immediately.
func AcceptTask ¶
func AcceptTask(task *components.Task) error
AcceptTask attempts to accept the given task identified by its ID. It logs an error and returns if the task is nil. If the task is successfully accepted, it logs a debug message indicating success. In case of an error during task acceptance, it handles the error and returns it.
func AuthenticateAgent ¶
func AuthenticateAgent() error
AuthenticateAgent authenticates the agent with the CipherSwarm API using the SDK client. It sends an authentication request to the API, processes the response, and updates the shared state. On error, it logs the error and returns it. If the response is nil or indicates a failed authentication, an error is logged and returned.
func CheckForExistingClient ¶ added in v0.1.2
CheckForExistingClient checks if a client process is already running by examining a PID file at the specified path. Returns true if the process is found or errors occur, otherwise false.
func CreateDataDirs ¶
func CreateDataDirs() error
CreateDataDirs creates required directories based on the paths set in shared.State. It checks for each path's existence, ensures it's not blank, and creates the directory if it doesn't exist, logging any errors that occur. Returns an error if any directory creation fails.
func CreateLockFile ¶
func CreateLockFile() error
CreateLockFile creates a lock file with the current process PID. Writes the PID to the designated lock file in the shared state. Logs an error and returns it if writing fails.
func DisplayAuthenticated ¶ added in v0.1.2
func DisplayAuthenticated()
DisplayAuthenticated logs an informational message indicating successful authentication with the CipherSwarm API.
func DisplayInactive ¶ added in v0.1.2
DisplayInactive logs a debug message with the provided sleepTime duration before the agent pauses its activity.
func DisplayNewAttack ¶ added in v0.1.2
func DisplayNewAttack(attack *components.Attack)
DisplayNewAttack logs debug and info level messages for a new attack. It logs attack parameters and information about the new attack initiation using shared.Logger.
func DisplayNewTask ¶ added in v0.1.2
func DisplayNewTask(task *components.Task)
DisplayNewTask logs a new task as available using the shared.Logger instance. It outputs debug and info level logs with the complete task details and its ID, respectively.
func DisplayRunTaskAccepted ¶ added in v0.1.2
func DisplayRunTaskAccepted(task *components.Task)
DisplayRunTaskAccepted logs an informational message indicating that a task has been accepted, specifying the task ID.
func DisplayShuttingDown ¶ added in v0.1.2
func DisplayShuttingDown()
DisplayShuttingDown logs an informational message indicating the shutdown of the CipherSwarm Agent.
func DisplayStartup ¶ added in v0.1.2
func DisplayStartup()
DisplayStartup logs an informational message indicating the start of the CipherSwarm Agent.
func DownloadFiles ¶
func DownloadFiles(attack *components.Attack) error
DownloadFiles downloads the necessary files for the provided attack. It performs the following steps: 1. Logs the start of the download process. 2. Downloads the hash list associated with the attack. 3. Iterates over resource files (word list, rule list, and mask list) and downloads each one. If any step encounters an error, the function returns that error.
func GetAgentConfiguration ¶
func GetAgentConfiguration() error
GetAgentConfiguration retrieves the agent configuration from the CipherSwarm API and handles errors. It updates the global Configuration variable with the fetched configuration. If UseNativeHashcat is true in the configuration, it sets the native Hashcat path.
func GetAttackParameters ¶
func GetAttackParameters(attackID int64) (*components.Attack, error)
GetAttackParameters retrieves the attack parameters for a given attackID via the SdkClient. Returns an Attack object if the API call is successful and the response status is OK.
func GetNewTask ¶
func GetNewTask() (*components.Task, error)
GetNewTask retrieves a new task from the server. It sends a request using SdkClient, handles any errors, and returns the task if available. If the server responds with no content, it means no new task is available, and the function returns nil without error. For any other unexpected response status, an error is returned.
func RunTask ¶
func RunTask(task *components.Task, attack *components.Attack) error
RunTask performs a hashcat attack based on the provided task and attack objects. It initializes the task, creates job parameters, starts the hashcat session, and handles task completion or errors. Parameters:
- task: Pointer to the Task object to be run.
- attack: Pointer to the Attack object describing the specifics of the attack.
Returns an error if the task could not be run or if the attack session could not be started.
func SendAgentError ¶ added in v0.1.11
func SendAgentError(stdErrLine string, task *components.Task, severity operations.Severity)
SendAgentError sends an error message to the centralized server, including metadata and severity level. - stdErrLine: The error message string to send. - task: Pointer to the task associated with the error, can be nil. - severity: The severity level of the error (e.g., critical, warning). The function prepares metadata including platform and agent version details, constructs the request body, and sends it to the server using the SDK client. If the sending fails, it handles the error accordingly.
func SendAgentShutdown ¶ added in v0.2.0
func SendAgentShutdown()
SendAgentShutdown notifies the server of the agent shutdown and handles any errors during the API call.
func SendHeartBeat ¶
func SendHeartBeat() *operations.State
SendHeartBeat sends a heartbeat signal to the server and processes the server's response. It handles different response status codes and logs relevant messages. It returns the agent's state object or nil if an error occurs or if the response status is http.StatusNoContent.
func UpdateAgentMetadata ¶
func UpdateAgentMetadata() error
UpdateAgentMetadata updates the agent's metadata and sends it to the CipherSwarm API. It retrieves host information, device list, constructs the agent update request body, and sends the updated metadata to the API. Logs relevant information and handles any API errors.
func UpdateBenchmarks ¶
func UpdateBenchmarks() error
UpdateBenchmarks updates the benchmark metrics using Hashcat. Creates a Hashcat session with benchmark parameters and initiates the benchmarking process. Logs the session start, runs the benchmark task, and updates the results. If any errors occur during session creation or result sending, logs the errors and returns them.
func UpdateCracker ¶
func UpdateCracker()
UpdateCracker checks for updates to the cracker and applies them if available. It starts by logging the beginning of the update process and attempts to fetch the current version of Hashcat. It then calls the API to check if there are any updates available. Depending on the API response, it either handles the update process or logs the absence of any new updates. If any errors occur during these steps, they are logged and handled accordingly.
Types ¶
This section is empty.