lachlan2k / phatcrack

Modern web-based distributed hashcracking solution, built on hashcat
MIT License
109 stars 8 forks source link

Hashlist ordering getting shuffled #42

Closed JSmith-Aura closed 2 weeks ago

JSmith-Aura commented 2 months ago

Each time that api/v1/hashlist/<hashlist_id> is queried the frontend hashlist shuffles to a new random ordering which is quite distracting when a job is running.

func GetHashlistWithHashes(hashlistId string) (*Hashlist, error) {
    var hashlist Hashlist
    err := GetInstance().Preload("Hashes").First(&hashlist, "id = ?", hashlistId).Error
    if err != nil {
        return nil, err
    }
    return &hashlist, nil
}

I believe this is happening because the Preload doesnt have an order specified, e.g:

err := db.Where("id = ?", userID).Preload("Schools")
.Preload("Schools.Jobs", func(db *gorm.DB) *gorm.DB {
    return db.Order("job.job_reference DESC")
}).Scan(&user).Error
return &user.Schools, err
lachlan2k commented 2 weeks ago

As discussed, this only happens when a new cracked hash has been added to the list. Only becomes distracting on very very large sets of hashes where the results are coming in quite quickly.

The solution would be to sort the DB query, first in terms of if its cracked, second in terms of ID. However, I'd need to performance test this for sets of hashes (i.e. 10k+) to evaluate any perf concerns, and I can't be bothered doing that quite yet. Might revisit in future