Documentation
¶
Index ¶
Constants ¶
const ( AttackModeMask = 3 // AttackModeMask is the attack mode for mask attacks AttackBenchmark = 9 // AttackBenchmark is the attack mode for benchmarking )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Params ¶ added in v0.1.2
type Params struct { AttackMode int64 `json:"attack_mode"` // Attack mode to use HashType int64 `json:"hash_type"` // Hash type to crack HashFile string `json:"hash_file"` // Path to the file containing the hashes to crack Mask string `json:"mask,omitempty"` // Mask to use for mask attack MaskIncrement bool `json:"mask_increment,omitempty"` // Whether to use mask increment MaskIncrementMin int64 `json:"mask_increment_min"` // Min mask length for increment MaskIncrementMax int64 `json:"mask_increment_max"` // Max mask length for increment MaskCustomCharsets []string `json:"mask_custom_charsets"` // Custom charsets for mask attack WordListFilename string `json:"wordlist_filename"` // Wordlist to use for dictionary and hybrid attacks RuleListFilename string `json:"rules_filename"` // Rule list to use for dictionary attack MaskListFilename string `json:"mask_list_filename"` // Mask list to use for mask attack AdditionalArgs []string `json:"additional_args"` // Additional arguments to pass to hashcat OptimizedKernels bool `json:"optimized_kernels"` // Whether to use optimized kernels SlowCandidates bool `json:"slow_candidates"` // Whether to use slow candidates Skip int64 `json:"skip,omitempty"` // Keyspace offset to start at Limit int64 `json:"limit,omitempty"` // Maximum keyspace to process BackendDevices string `json:"backend_devices,omitempty"` // Devices to use for the backend, comma-separated OpenCLDevices string `json:"opencl_devices,omitempty"` // OpenCL devices to use, comma-separated EnableAdditionalHashTypes bool `json:"enable_additional_hash_types"` // Whether to enable additional hash types when benchmarking RestoreFilePath string `json:"restore_file_path,omitempty"` // Path to the restore file }
func (Params) Validate ¶ added in v0.1.2
Validate checks the Params struct for valid attack mode configurations. It validates the parameters based on the specified attack mode and returns an error if the attack mode is unsupported or if the parameters are invalid for the given attack mode.
Supported attack modes: - attackModeDictionary: Validates dictionary attack parameters. - AttackModeMask: Validates mask attack parameters. - attackModeHybridDM, attackModeHybridMD: Validates hybrid attack parameters. - AttackBenchmark: No validation needed.
Returns an error if the attack mode is unsupported or if validation fails.
type Session ¶ added in v0.1.2
type Session struct { CrackedHashes chan Result // Channel to send cracked hashes to StatusUpdates chan Status // Channel to send status updates to StderrMessages chan string // Channel to send stderr messages to StdoutLines chan string // Channel to send stdout lines to DoneChan chan error // Channel to send the done signal to SkipStatusUpdates bool // Whether to skip sending status updates RestoreFilePath string // Path to the restore file // contains filtered or unexported fields }
Session represents a running Hashcat session. It contains the hashcat process, the path of the file containing the hashes to crack, the file to write cracked hashes to, charset files for mask attacks, a channel to send cracked hashes to,.
func NewHashcatSession ¶
NewHashcatSession creates a new Hashcat session with the given ID and parameters. It initializes the necessary files and command arguments for running Hashcat.
Parameters:
- id: A unique identifier for the session.
- params: A Params struct containing configuration for the Hashcat session.
Returns:
- *Session: A pointer to the newly created Session struct.
- error: An error if the session could not be created.
The function performs the following steps:
- Retrieves the Hashcat binary path from the configuration.
- Creates a temporary output file for the session.
- Creates charset files based on the provided custom charsets.
- Constructs the command arguments for running Hashcat.
- Checks if a restore file path is provided and exists, and adjusts the arguments accordingly.
- Initializes and returns a new Session struct with the prepared command and channels.
func (*Session) Cleanup ¶ added in v0.1.2
func (sess *Session) Cleanup()
Cleanup removes session-related files and directories. It performs the following actions: 1. Logs the cleanup process initiation. 2. Checks if the output file exists and removes it if present. 3. Sets the output file reference to nil. 4. Removes the zaps directory if the retain flag is not set. 5. Iterates through charset files, checking for existence and removing them if present. 6. Checks if the hash file exists and removes it if present. 7. Resets the hash file reference to an empty string.
func (*Session) CmdLine ¶ added in v0.1.2
CmdLine returns the command line string used to start the session.
func (*Session) Kill ¶ added in v0.1.2
Kill terminates the process associated with the session. If the process is already nil or has completed, it returns nil. If an error occurs during termination, it returns the error. If the error indicates the process is already done, it returns nil.
type Status ¶ added in v0.1.2
type Status struct { OriginalLine string `json:"original_line"` // The original line from hashcat Time time.Time `json:"time"` // The time the status was received Session string `json:"session"` // The session ID Guess statusGuess `json:"guess"` // The current guess Status int64 `json:"status"` // The status of the attack Target string `json:"target"` // The target hash Progress []int64 `json:"progress"` // The progress of the attack RestorePoint int64 `json:"restore_point"` // The restore point RecoveredHashes []int64 `json:"recovered_hashes"` // The number of recovered hashes RecoveredSalts []int64 `json:"recovered_salts"` // The number of recovered salts Rejected int64 `json:"rejected"` // The number of rejected hashes Devices []StatusDevice `json:"devices"` // The devices used for the attack TimeStart int64 `json:"time_start"` // The start time of the attack EstimatedStop int64 `json:"estimated_stop"` // The estimated stop time of the attack }
type StatusDevice ¶ added in v0.1.2
type StatusDevice struct { DeviceID int64 `json:"device_id"` // The device ID DeviceName string `json:"device_name"` // The device name DeviceType string `json:"device_type"` // The device type Speed int64 `json:"speed"` // The speed of the device Util int64 `json:"util"` // The utilization of the device Temp int64 `json:"temp"` // The temperature of the device }