diff --git a/common/job.go b/common/job.go index de49d57..b9ef781 100644 --- a/common/job.go +++ b/common/job.go @@ -3,6 +3,7 @@ package common import ( "time" + log "github.com/Sirupsen/logrus" "github.com/pborman/uuid" ) @@ -88,3 +89,22 @@ func IsEmpty(j Job) bool { return false } + +// LogJob returns a github.com/Sirupsen/logrus log.Fields structure for logging a jobs status +func LogJob(j Job) log.Fields { + return log.Fields{ + "uuid": j.UUID, + "name": j.Name, + "resuuid": j.ResAssigned, + "status": j.Status, + "error": j.Error, + "starttime": j.StartTime, + "runtime": j.RunTime, + "etc": j.ETC, + "owner": j.Owner, + "teamvisibility": j.TeamVisible, + "crackedhashes": j.CrackedHashes, + "totalhashes": j.TotalHashes, + "progress": j.Progress, + } +} diff --git a/plugins/tools/hashcat5/charsets.go b/plugins/tools/hashcat5/charsets.go index d80a451..5fdb217 100644 --- a/plugins/tools/hashcat5/charsets.go +++ b/plugins/tools/hashcat5/charsets.go @@ -1,26 +1,38 @@ package hashcat5 -// Assumes ?1=?l?d, ?2=?u?l?d, ?3=?d?s, ?4=?l?d?s -var CharSetPreDefCustom1 = "?l?d" // Lower ad number -var CharSetPreDefCustom2 = "?u?l?d" // Upper, lower, and number -var CharSetPreDefCustom3 = "?d?s" // number and symbols -var CharSetPreDefCustom4 = "?l?d?s" // lower, number, and symbol +// CharSetPreDefCustom1 is a custom character set that includes lower case and numbers +var CharSetPreDefCustom1 = "?l?d" +// CharSetPreDefCustom2 is a custom character set that includes lower case, upper case and numbers +var CharSetPreDefCustom2 = "?u?l?d" + +// CharSetPreDefCustom3 is a custom character set that includes numbers and symbols +var CharSetPreDefCustom3 = "?d?s" + +// CharSetPreDefCustom4 is a custom character set that includes lower case, numbers and symbols +var CharSetPreDefCustom4 = "?l?d?s" + +// Charset is a structure representing a character set for Hashcat. It has a name for easy of selection and a Mask that is the value given to Hashcat. type Charset struct { Name string Mask string } +// Charsets is a slice of Charset structs type Charsets []Charset +// Len is the length of the Charsets for sorting func (r Charsets) Len() int { return len(r) } + +// Swap is the swap function of the Charsets for sorting func (r Charsets) Swap(i, j int) { r[i], r[j] = r[j], r[i] } +// Less is the comparison of the Charsets for sorting func (r Charsets) Less(i, j int) bool { return r[i].Name < r[j].Name } diff --git a/plugins/tools/hashcat5/dictionaries.go b/plugins/tools/hashcat5/dictionaries.go index 50ff561..867b074 100644 --- a/plugins/tools/hashcat5/dictionaries.go +++ b/plugins/tools/hashcat5/dictionaries.go @@ -1,20 +1,26 @@ package hashcat5 +// Dictionary is a structure for working with dictionaries related to Hashcat. The Dictionary has a name for display and a file path which is given to Hashcat. type Dictionary struct { Name string Path string } +// Dictionaries is a slice of Dictionary structs type Dictionaries []Dictionary +// Len is a function giving the length of the slice for sorting func (d Dictionaries) Len() int { return len(d) } + +// Swap is a function for swaping slice indexes for sorting func (d Dictionaries) Swap(i, j int) { d[i], d[j] = d[j], d[i] } +// Less is a comparision function for sorting func (d Dictionaries) Less(i, j int) bool { return d[i].Name < d[j].Name } diff --git a/plugins/tools/hashcat5/hashcat5.go b/plugins/tools/hashcat5/hashcat5.go index 1d3960b..da50032 100644 --- a/plugins/tools/hashcat5/hashcat5.go +++ b/plugins/tools/hashcat5/hashcat5.go @@ -28,7 +28,7 @@ var config Config // Setup configures this plugin for running and returns and error something is wrong. func Setup(confPath string) error { - log.Debug("Setting up hashcat 5.x plugin...") + log.Debug("setting up hashcat 5.x plugin...") // Load the configuration file confFile, err := ini.LoadFile(confPath) @@ -36,7 +36,7 @@ func Setup(confPath string) error { log.WithFields(log.Fields{ "error": err.Error(), "file": confPath, - }).Error("Unable to load configuration file.") + }).Error("unable to load configuration file.") return err } @@ -44,8 +44,8 @@ func Setup(confPath string) error { basicConfig := confFile.Section("Basic") if len(basicConfig) == 0 { // Nothing retrieved, so return error - log.Error(`No "Basic" configuration section.`) - return errors.New(`No "Basic" configuration section.`) + log.Error("no [Basic] configuration section") + return errors.New("no [Basic] configuration section") } // Setup BinPath & WorkingDir @@ -54,21 +54,21 @@ func Setup(confPath string) error { log.WithFields(log.Fields{ "binpath": config.BinPath, - "WorkDir": config.WorkingDir, - }).Debug("BinPath and WorkingDir") + "workdir": config.WorkingDir, + }).Debug("binary path and working directory setup") // Get the dictionary section dicts := confFile.Section("Dictionaries") if len(dicts) == 0 { // Nothing retrieved, so return error - log.Error(`No "Dictionaries" configuration section.`) - return errors.New(`No "Dictionaries" configuration section.`) + log.Error("no [Dictionaries] configuration section") + return errors.New("no [Dictionaries] configuration section") } for key, value := range dicts { log.WithFields(log.Fields{ "name": key, "path": value, - }).Debug("Added dictionary") + }).Debug("added dictionary") config.Dictionaries = append(config.Dictionaries, Dictionary{Name: key, Path: value}) } @@ -78,15 +78,15 @@ func Setup(confPath string) error { rules := confFile.Section("Rules") if len(rules) == 0 { // Nothing retrieved, so return error - log.Error(`No "Rules" configuration section.`) - return errors.New(`No "Rules" configuration section.`) + log.Error("no [Rules] configuration section") + return errors.New("no [Rules] configuration section") } for key, value := range rules { log.WithFields(log.Fields{ "name": key, "path": value, - }).Debug("Added rule") + }).Debug("added rule") config.RuleFiles = append(config.RuleFiles, RuleFile{Name: key, Path: value}) } @@ -97,15 +97,15 @@ func Setup(confPath string) error { if len(charset) == 0 { // Nothing retrieved, so return error - log.Error(`No "charset" configuration section.`) - return errors.New(`No "charset" configuration section.`) + log.Error("no [Charset] configuration section") + return errors.New("no [Charset] configuration section") } for key, value := range charset { log.WithFields(log.Fields{ "name": key, "path": value, - }).Debug("Added charset to hashcat") + }).Debug("added charset to hashcat") config.Charsets = append(config.Charsets, Charset{Name: key, Mask: value}) } @@ -115,15 +115,15 @@ func Setup(confPath string) error { options := confFile.Section("Options") if len(options) == 0 { // Nothing retrieved, so return error - log.Error(`No options configuration section.`) - return errors.New(`No options configuration section.`) + log.Error("no [Options] configuration section") + return errors.New("no [Options] configuration section") } for flag, value := range options { log.WithFields(log.Fields{ "flag": flag, "value": value, - }).Debug("Added option to hashcat") + }).Debug("added option to hashcat") // Catch some important flags that we need later switch flag { @@ -145,15 +145,15 @@ func Setup(confPath string) error { excludeHashModes := confFile.Section("ExcludeHashMode") if len(excludeHashModes) == 0 { // Nothing retrieved, so return error - log.Error(`No excludeHashModes configuration section.`) - return errors.New(`No excludeHashModes configuration section.`) + log.Error("no [ExcludeHashMode] configuration section") + return errors.New("no [ExcludeHashMode] configuration section") } for mode, name := range excludeHashModes { log.WithFields(log.Fields{ "mode": mode, "name": name, - }).Debug("Added excludeHashModes to hashcat") + }).Debug("added excludeHashModes to hashcat") exHMMap[mode] = name } @@ -162,7 +162,7 @@ func Setup(confPath string) error { help, err := exec.Command(config.BinPath, "--help").Output() if err != nil { // Something is wrong with our executable so log and fail - log.WithField("error", err.Error()).Error("Error executing hashcat for help screen.") + log.WithField("error", err.Error()).Error("error executing hashcat for help screen") return err } diff --git a/plugins/tools/hashcat5/output-parse.go b/plugins/tools/hashcat5/output-parse.go index 91fbc48..42953b6 100644 --- a/plugins/tools/hashcat5/output-parse.go +++ b/plugins/tools/hashcat5/output-parse.go @@ -219,7 +219,7 @@ func ParseMachineOutput(out string) (Status, error) { // If we did not find a status line return a failure and nil status if !statusLineFound { - return Status{}, errors.New("No status line found.") + return Status{}, errors.New("no status line found") } // Set the time estimate diff --git a/plugins/tools/hashcat5/rulefiles.go b/plugins/tools/hashcat5/rulefiles.go index 6e6eea5..2f5e626 100644 --- a/plugins/tools/hashcat5/rulefiles.go +++ b/plugins/tools/hashcat5/rulefiles.go @@ -1,20 +1,26 @@ package hashcat5 +// RuleFile is a structure for storing rules for hashcat. Name is a display name and Path specifies the file path. type RuleFile struct { Name string Path string } +// RuleFiles is a slice of RuleFile structs type RuleFiles []RuleFile +// Len returns the slice length for the sorting interface. func (r RuleFiles) Len() int { return len(r) } + +// Swap swaps values by index for the sorting interface. func (r RuleFiles) Swap(i, j int) { r[i], r[j] = r[j], r[i] } +// Less compares values by index for the sorting interface. func (r RuleFiles) Less(i, j int) bool { return r[i].Name < r[j].Name } diff --git a/plugins/tools/hashcat5/tasker.go b/plugins/tools/hashcat5/tasker.go index 9b25b5d..22215fe 100644 --- a/plugins/tools/hashcat5/tasker.go +++ b/plugins/tools/hashcat5/tasker.go @@ -54,9 +54,7 @@ func (t *Tasker) Status() common.Job { if t.job.Status == common.STATUS_RUNNING { if !t.stderrCp { go func() { - log.WithFields(log.Fields{ - "jobUUID": t.job.UUID, - }).Debug("Stopping Stderr Pipe Copy") + log.WithFields(common.LogJob(t.job)).Debug("stopping Stderr Pipe Copy") t.stderrCp = true for t.job.Status == common.STATUS_RUNNING { @@ -65,17 +63,13 @@ func (t *Tasker) Status() common.Job { } t.stderrCp = false - log.WithFields(log.Fields{ - "jobUUID": t.job.UUID, - }).Debug("Stopping Stderr Pipe Copy") + log.WithFields(common.LogJob(t.job)).Debug("stopping Stderr Pipe Copy") }() } if !t.stdoutCp { go func() { - log.WithFields(log.Fields{ - "jobUUID": t.job.UUID, - }).Debug("Stopping Stdout Pipe Copy") + log.WithFields(common.LogJob(t.job)).Debug("stopping Stdout Pipe Copy") t.stdoutCp = true for t.job.Status == common.STATUS_RUNNING { @@ -84,9 +78,7 @@ func (t *Tasker) Status() common.Job { } t.stdoutCp = false - log.WithFields(log.Fields{ - "jobUUID": t.job.UUID, - }).Debug("Stopping Stdout Pipe Copy") + log.WithFields(common.LogJob(t.job)).Debug("stopping Stdout Pipe Copy") }() } @@ -135,11 +127,9 @@ func (t *Tasker) Status() common.Job { // Get the hash file var hashes [][]string - hashFile, err := os.Open(filepath.Join(t.wd, HASH_OUTPUT_FILENAME)) + hashFile, err := os.Open(filepath.Join(t.wd, ConstHashcatOutputFilename)) if err == nil { _, hashes = ParseHashcatOutputFile(hashFile, t.inputSplits, t.hashMode) - } else { - log.WithField("io_error", err).Debug("Failed to open output.txt") } // Add in the pot file items @@ -159,7 +149,7 @@ func (t *Tasker) Status() common.Job { t.stderr.Reset() t.stdout.Reset() - log.WithField("job", t.job).Debug("Returning job with status call") + log.WithFields(common.LogJob(t.job)).Debug("Returning job with status call") return t.job } @@ -171,34 +161,23 @@ func (t *Tasker) Run() error { // Check that we have not already finished this job if t.job.Status == common.STATUS_DONE || t.job.Status == common.STATUS_QUIT || t.job.Status == common.STATUS_FAILED { - log.WithField("Status", t.job.Status).Debug("Unable to start hashcat5 job as it is done.") - return errors.New("Job already finished.") + log.WithFields(common.LogJob(t.job)).Debug("unable to start hashcat5 job as it is done, quit or failed already") + return errors.New("job already finished") } // Check if this job is running if t.job.Status == common.STATUS_RUNNING { // Job already running so return no errors - log.Debug("hashcat5 job already running, doing nothing") + log.Debug("hashcat5 job already running") return nil } - // We need to first parse the stuff we were given by the user for the hash file. - // We will do this via hashcat's --left output, which also will create our hash file for cracking - hashcatLeftExec := exec.Command(config.BinPath, t.showPotLeft...) - hashcatLeftExec.Dir = t.wd - log.WithField("Left Command", hashcatLeftExec.Args).Debug("Executing Left Command") - showPotLeftStdout, err := hashcatLeftExec.Output() - if err != nil { - log.WithField("execError", err).Error("Error running hashcat --left command.") - } - log.WithField("showLeftStdout", string(showPotLeftStdout)).Debug("Show Left command stdout.") - // Get the first line of the Left output to count our separators (:) - hashcatLeftFilename := filepath.Join(t.wd, HASHCAT_LEFT_FILENAME) + hashcatLeftFilename := filepath.Join(t.wd, ConstHashcatLeftFilename) hashcatLeftFile, err := os.Open(hashcatLeftFilename) if err != nil { log.Error(err) - return errors.New("Error opening LEFT Hash file") + return errors.New("error opening hashcat left flag file") } // Get the count of hashes and the split count @@ -208,19 +187,19 @@ func (t *Tasker) Run() error { // Create and pull the pot file search hashcatShowPotExec := exec.Command(config.BinPath, t.showPot...) hashcatShowPotExec.Dir = t.wd - log.WithField("Show Command", hashcatShowPotExec.Args).Debug("Executing Show Command") + log.WithField("args", hashcatShowPotExec.Args).Debug("show command executing") showPotStdout, err := hashcatShowPotExec.Output() if err != nil { - log.WithField("execError", err).Error("Error running hashcat --show command.") + log.WithField("error", err).Error("error running hashcat show command.") } log.WithField("showStdout", string(showPotStdout)).Debug("Show command stdout.") // Get the output of the show pot file - hashcatPotShowFilename := filepath.Join(t.wd, HASHCAT_POT_SHOW_FILENAME) + hashcatPotShowFilename := filepath.Join(t.wd, ConstHashcatPotShowFilename) hashcatPotShowFile, err := os.Open(hashcatPotShowFilename) if err != nil { log.Error(err) - return errors.New("Error opening LEFT Hash file") + return errors.New("error opening hashcat show file") } var potCount int64 potCount, t.showPotOutput = ParseShowPotFile(hashcatPotShowFile, t.inputSplits, t.hashMode) @@ -229,12 +208,10 @@ func (t *Tasker) Run() error { t.job.TotalHashes = leftCount + potCount t.job.CrackedHashes = potCount + // Set commands for restore or start // We need to check for a restore file. If it does not exist we have to start over and not give the --restore command hashcatBinFolder := filepath.Dir(config.BinPath) _, err = os.Stat(filepath.Join(hashcatBinFolder, t.job.UUID+".restore")) - log.WithField("error", err).Debug("Stat of restore file returned error") - - // Set commands for restore or start if t.job.Status == common.STATUS_CREATED || os.IsNotExist(err) { t.exec = *exec.Command(config.BinPath, t.start...) } else { @@ -244,8 +221,8 @@ func (t *Tasker) Run() error { // Set the working directory t.exec.Dir = t.wd log.WithFields(log.Fields{ - "dir": t.exec.Dir, - }).Debug("Setup working directory") + "workingdir": t.exec.Dir, + }).Debug("setup working directory") // Assign the stderr, stdout, stdin pipes t.stderrPipe, err = t.exec.StderrPipe() @@ -267,13 +244,13 @@ func (t *Tasker) Run() error { t.stdout = bytes.NewBuffer([]byte("")) // Start the command - log.WithField("argument", t.exec.Args).Debug("Running command.") + log.WithField("arguments", t.exec.Args).Debug("running command") err = t.exec.Start() t.doneWG.Add(1) if err != nil { // We had an error starting to return that and quit the job t.job.Status = common.STATUS_FAILED - log.Errorf("There was an error starting the job: %v", err) + log.WithFields(common.LogJob(t.job)).Errorf("there was an error starting the job: %v", err) return err } @@ -285,12 +262,8 @@ func (t *Tasker) Run() error { // Wait for the job to finish t.exec.Wait() t.mux.Lock() - log.WithFields(log.Fields{ - "task": t.job.UUID, - "returnedStatus": t.returnStatus, - }).Debug("Job exec returned Wait().") + log.WithFields(common.LogJob(t.job)).Debug("job execution returned wait function") - //log.WithField("task", t.job.UUID).Debug("Took lock on job to change status to done.") switch t.returnStatus { case "": t.job.Status = common.STATUS_DONE @@ -341,7 +314,7 @@ func (t *Tasker) quitExec(returnStatus string) { // Pause kills the hashcat process and marks the job as paused func (t *Tasker) Pause() error { - log.WithField("task", t.job.UUID).Debug("Attempting to pause hashcat task") + log.WithFields(common.LogJob(t.job)).Debug("attempting to pause hashcat task") if t.job.Status == common.STATUS_RUNNING { // Call status to update the job internals before pausing @@ -349,7 +322,7 @@ func (t *Tasker) Pause() error { t.quitExec(common.STATUS_PAUSED) - log.WithField("task", t.job.UUID).Debug("Task paused successfully") + log.WithFields(common.LogJob(t.job)).Debug("task paused successfully") } return nil @@ -357,7 +330,7 @@ func (t *Tasker) Pause() error { // Quit kills the hashcat process and then returns the most up-to-date status func (t *Tasker) Quit() common.Job { - log.WithField("task", t.job.UUID).Debug("Attempting to quit hashcat task") + log.WithFields(common.LogJob(t.job)).Debug("attempting to quit hashcat task") if t.job.Status == common.STATUS_RUNNING { // Call status to update the job internals before quiting @@ -365,7 +338,7 @@ func (t *Tasker) Quit() common.Job { t.quitExec(common.STATUS_QUIT) - log.WithField("task", t.job.UUID).Debug("Task quit successfully") + log.WithFields(common.LogJob(t.job)).Debug("task quit successfully") } return t.job } diff --git a/plugins/tools/hashcat5/tooler.go b/plugins/tools/hashcat5/tooler.go index 5657497..3d47746 100644 --- a/plugins/tools/hashcat5/tooler.go +++ b/plugins/tools/hashcat5/tooler.go @@ -16,10 +16,14 @@ import ( ) const ( - USER_HASHES_FILENAME = "user-input-hashes.txt" - HASHCAT_POT_SHOW_FILENAME = "hashcat-pot-show.txt" - HASHCAT_LEFT_FILENAME = "hashcat-left.txt" - HASH_OUTPUT_FILENAME = "output-hashes.txt" + // ConstUserHashesFilename is the filename used for user provided hashes + ConstUserHashesFilename = "user-input-hashes.txt" + // ConstHashcatPotShowFilename is the filename for the hashcat pot checking file + ConstHashcatPotShowFilename = "hashcat-pot-show.txt" + // ConstHashcatLeftFilename is the filename of the hashcat left file + ConstHashcatLeftFilename = "hashcat-left.txt" + // ConstHashcatOutputFilename is the filename of the hashcat output file + ConstHashcatOutputFilename = "output-hashes.txt" ) type hashcat5Tooler struct { @@ -379,7 +383,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { "hashmode": htype, "err": ok, }).Error("Could not find the hashmode provided") - return nil, errors.New("Could not find the hashmode provided.") + return nil, errors.New("could not find the hashmode provided") } opts = append(opts, "--hash-type="+htype) t.hashMode = htype @@ -397,7 +401,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { if dictIndex == len(config.Dictionaries) { // We did not find the dictionary so return an error log.WithField("dictionary", dictDictionary).Error("Dictionary provided does not exist.") - return nil, errors.New("Dictionary provided does not exist.") + return nil, errors.New("dictionary provided does not exist") } log.WithField("Dictionary", config.Dictionaries[dictIndex].Path).Debug("Dictionary selected.") @@ -461,8 +465,8 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { } if ruleRandomMax <= 0 { - log.Error("The value given for the number of random rules to generate was not more than 0.") - return nil, errors.New("The value given for the number of random rules to generate was not more than 0.") + log.Error("the value given for the number of random rules to generate was not more than 0") + return nil, errors.New("the value given for the number of random rules to generate was not more than 0") } // Append the value @@ -493,7 +497,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { if ruleIndex == len(config.RuleFiles) { // We did not find the rule file provided log.WithField("rule file", ruleFile).Error("Rule file selected does not exit.") - return nil, errors.New("Rule file provided does not exist.") + return nil, errors.New("rule file provided does not exist") } // Add the fule file argument @@ -508,7 +512,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { fileParts := strings.Split((t.job.Parameters["dict_rules_custom_file"]), ";") if len(fileParts) != 3 { log.Error("Error parsing the uploaded file.") - return nil, errors.New("Error parsing the uploaded file.") + return nil, errors.New("error parsing the uploaded file") } // [0] - file:[filename of uploaded file] // [1] - data:[data type (text/plain)] @@ -592,7 +596,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { // We have now defined our custom character sets, if any, so check our provided custom mask if len(bruCustomMask) <= 0 { log.WithField("brute_custom_mask", bruCustomMask).Error("Length of brute_custom_mask was <= 0.") - return nil, errors.New("Length of brute_custom_mask was <= 0.") + return nil, errors.New("length of brute_custom_mask was less than or equal to 0") } // Append the custom mask @@ -607,7 +611,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { if charSetIndex == len(config.Charsets) { // We did not find the dictionary so return an error log.WithField("characterset", bruPreDefMask).Error("Character Set provided does not exist.") - return nil, errors.New("Character Set provided does not exist.") + return nil, errors.New("character Set provided does not exist") } // Add the custom character sets used by the configured pre definied character masks @@ -633,7 +637,9 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { } // Enable increment mode - opts = append(opts, "--increment") + if incModeBool { + opts = append(opts, "--increment") + } if incModeBool { // Check the start and maxium integers @@ -647,7 +653,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { if incMinInt <= 0 { log.WithField("brute_min_length", incMinString).Error("The brute_min_length value is not at least 1.") - return nil, errors.New("The brute_min_length value is not at least 1.") + return nil, errors.New("the brute_min_length value is not at least 1") } // Append the minimum value @@ -664,7 +670,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { if incMaxInt <= 0 { log.WithField("brute_max_length", incMaxString).Error("The brute_max_length value is not at least 1.") - return nil, errors.New("The brute_max_length value is not at least 1.") + return nil, errors.New("the brute_max_length value is not at least 1") } // Append the minimum value @@ -692,7 +698,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { } var hashBytes []byte - hashFilePath := filepath.Join(t.wd, USER_HASHES_FILENAME) + hashFilePath := filepath.Join(t.wd, ConstUserHashesFilename) if hashUseUploadBool { // Use an uploaded hashfile if _, hashUploadOk := t.job.Parameters["hashes_file_upload"]; hashUploadOk { @@ -704,25 +710,25 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { } } else { log.Error("No hash file was uploaded, even though we checked the box.") - return nil, errors.New("No hash file was uploaded, even though we checked the box.") + return nil, errors.New("no hash file was uploaded, even though we checked the box") } } else { // Use the provided text input for the hashfile if _, hashMultilineOk := t.job.Parameters["hashes_multiline"]; hashMultilineOk { if len(t.job.Parameters["hashes_multiline"]) <= 0 { log.Error("The hash multiline was provided with a length of 0.") - return nil, errors.New("The hash multiline was provided with a length of 0.") + return nil, errors.New("the hash multiline was provided with a length of 0") } hashBytes = []byte(t.job.Parameters["hashes_multiline"]) } else { log.Error("Hashes were not provided in the multiline input and no file was uploaded.") - return nil, errors.New("Hashes were not provided in the multiline input and no file was uploaded.") + return nil, errors.New("hashes were not provided in the multiline input and no file was uploaded") } } // Save hashes to a file for us to process later - err = ioutil.WriteFile(filepath.Join(t.wd, USER_HASHES_FILENAME), hashBytes, 0660) + err = ioutil.WriteFile(filepath.Join(t.wd, ConstUserHashesFilename), hashBytes, 0660) if err != nil { return nil, err } @@ -805,7 +811,7 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { } // Setup the output file argument - opts = append(opts, "--outfile", filepath.Join(t.wd, HASH_OUTPUT_FILENAME)) + opts = append(opts, "--outfile", filepath.Join(t.wd, ConstHashcatOutputFilename)) // Append args from the configuration file t.start = append(t.start, config.Args...) @@ -819,11 +825,11 @@ func (h *hashcat5Tooler) NewTask(job common.Job) (common.Tasker, error) { t.resume = append(t.resume, "--session="+t.job.UUID, "--restore") // Setup the show command for the showPot execution - leftFilePath := filepath.Join(t.wd, HASHCAT_LEFT_FILENAME) - t.showPotLeft = append(t.showPot, "--outfile", leftFilePath, "--left", USER_HASHES_FILENAME) + leftFilePath := filepath.Join(t.wd, ConstHashcatLeftFilename) + t.showPotLeft = append(t.showPot, "--outfile", leftFilePath, "--left", ConstUserHashesFilename) - showPotFilePath := filepath.Join(t.wd, HASHCAT_POT_SHOW_FILENAME) - t.showPot = append(t.showPot, "--outfile", showPotFilePath, "--show", USER_HASHES_FILENAME) + showPotFilePath := filepath.Join(t.wd, ConstHashcatPotShowFilename) + t.showPot = append(t.showPot, "--outfile", showPotFilePath, "--show", ConstUserHashesFilename) // Append the various inputs to the argument args = append(args, opts...)