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.4"
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 abandons the given task. If the task is nil, it logs an error and returns. Otherwise, it notifies the server that the task has been abandoned. If there is an error notifying the server, it logs the error and sends an agent error.
func AcceptTask ¶
func AcceptTask(task *components.Task) error
AcceptTask accepts a task and returns a boolean indicating whether the task was accepted successfully. It takes a pointer to a `components.Task` as input. If the task is nil, it logs an error message and returns false. If there is an error while accepting the task, it checks the type of error and handles it accordingly: - If the error is of type `sdkerrors.ErrorObject`, it logs an error message, sends an agent error, and returns false. - If the error is of type `sdkerrors.SDKError`, it logs an error message, sends an agent error with severity set to "Critical", and returns false. If there are no errors, it logs a debug message and returns true.
func AuthenticateAgent ¶
func AuthenticateAgent() error
AuthenticateAgent authenticates the agent with the CipherSwarm API. It sends an authentication request to the API and checks the response status. If the authentication is successful, it sets the agent ID in the shared state. If the authentication fails, it returns an error. The function returns an error if there is an error connecting to the API or if the response status is not OK.
func CheckForExistingClient ¶ added in v0.1.2
CheckForExistingClient checks if there is an existing client running by checking the PID file. It reads the PID file and checks if the process with the specified PID is running. If the PID file does not exist, it returns false. If the PID file exists and the process is running, it returns true. If the PID file exists and the process is not running, it returns false. If there is an error reading the PID file or checking if the process is running, it returns true.
func CreateDataDirs ¶
func CreateDataDirs() error
CreateDataDirs creates a set of predefined directories if they do not already exist. It retrieves the directory paths from the shared.State configuration and iterates over them. For each directory path, it checks if the path is blank or if it already exists as a directory. If the path is blank, it logs an error and continues to the next path. If the directory does not exist, it attempts to create it and logs the result. If an error occurs during the creation of any directory, it logs the error and returns it.
func CreateLockFile ¶
func CreateLockFile() 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 DisplayAuthenticated ¶ added in v0.1.2
func DisplayAuthenticated()
DisplayAuthenticated displays a message when the agent is authenticated with the CipherSwarm API.
func DisplayInactive ¶ added in v0.1.2
DisplayInactive displays a message when the agent is inactive and sleeping.
func DisplayNewAttack ¶ added in v0.1.2
func DisplayNewAttack(attack *components.Attack)
DisplayNewAttack displays a message when a new attack is started.
func DisplayNewTask ¶ added in v0.1.2
func DisplayNewTask(task *components.Task)
DisplayNewTask displays a message when a new task is available.
func DisplayRunTaskAccepted ¶ added in v0.1.2
func DisplayRunTaskAccepted(task *components.Task)
DisplayRunTaskAccepted displays a log message indicating that a task has been accepted.
func DisplayShuttingDown ¶ added in v0.1.2
func DisplayShuttingDown()
DisplayShuttingDown displays a message when the agent is shutting down.
func DisplayStartup ¶ added in v0.1.2
func DisplayStartup()
DisplayStartup displays a message when the agent starts up.
func DownloadFiles ¶
func DownloadFiles(attack *components.Attack) error
DownloadFiles downloads the necessary files for the given attack. It downloads the hashlist, wordlists, and rulelists required for the attack. The downloaded files are saved to the specified file paths. If any error occurs during the download process, the function returns the error.
func GetAgentConfiguration ¶
func GetAgentConfiguration() error
func GetAttackParameters ¶
func GetAttackParameters(attackID int64) (*components.Attack, error)
GetAttackParameters retrieves the attack parameters for the specified attack ID. It makes a request to the CipherSwarm API using the SdkClient and returns the attack parameters if the request is successful. If there is an error connecting to the API or if the response status is not OK, an error is returned.
func GetNewTask ¶
func GetNewTask() (*components.Task, error)
GetNewTask retrieves a new task from the CipherSwarm API. It returns the new task if available, or nil if no new task is available. If there is an error connecting to the API, it logs the error and returns the error.
func RunTask ¶
func RunTask(task *components.Task, attack *components.Attack) error
RunTask executes a task using the provided attack parameters. It creates a hashcat session based on the attack parameters and runs the attack task. If the task is accepted, it displays a message indicating that the task has been accepted. After the attack task is completed, it displays a message indicating that the task has been completed. If any error occurs during the process, it logs the error and returns.
func SendAgentError ¶ added in v0.1.11
func SendAgentError(stdErrLine string, task *components.Task, severity operations.Severity)
SendAgentError sends an agent error to the server. It takes the following parameters: - stdErrLine: a string representing the error message. - task: a pointer to a Task object representing the task associated with the error. - severity: a Severity object representing the severity of the error.
If the task parameter is nil, the taskID will be set to nil. Otherwise, the taskID will be set to the ID of the task.
The function creates a Metadata object with the current error date and additional metadata, such as the agent platform and version.
It then creates an AgentError object with the error message, metadata, severity, agent ID, and task ID.
Finally, it submits the agent error to the server using the SdkClient.Agents.SubmitErrorAgent method. If there is an error during the submission, it logs the error using the shared.Logger.Error method.
func SendAgentShutdown ¶ added in v0.2.0
func SendAgentShutdown()
SendAgentShutdown sends a request to shut down the agent. It calls the SetAgentShutdown method of the SdkClient to set the agent's shutdown state. If an error occurs during the shutdown process, it logs the error and sends an agent error message.
func SendHeartBeat ¶
func SendHeartBeat() *operations.State
SendHeartBeat sends a heartbeat to the server and returns the agent heartbeat response state. If an error occurs while sending the heartbeat, it logs the error and sends an agent error. If the response status code is http.StatusNoContent, it logs that the heartbeat was sent and returns nil. If the response status code is http.StatusOK, it logs that the heartbeat was sent and checks the agent heartbeat response state. It logs the corresponding agent state based on the response state and returns a pointer to the response state. If the response status code is neither http.StatusNoContent nor http.StatusOK, it returns nil.
func UpdateAgentMetadata ¶
func UpdateAgentMetadata() error
func UpdateBenchmarks ¶
func UpdateBenchmarks() error
UpdateBenchmarks updates the benchmarks for the agent. It creates a new hashcat session for benchmarking and sends the benchmark results. If any error occurs during the process, it logs the error and sends an agent error.
func UpdateCracker ¶
func UpdateCracker()
UpdateCracker checks for an updated version of the cracker and performs the necessary updates. It connects to the CipherSwarm API to check for updates, downloads the updated cracker if available, moves the file to the correct location, extracts the file, and updates the config file with the new hashcat path.
Types ¶
This section is empty.