|
|
|
@@ -25,24 +25,28 @@ func NewCrackProgressLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cra |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (l *CrackProgressLogic) CrackProgress(req *types.CrackProgressReq) (resp *types.CrackProgressResp, err error) { |
|
|
|
func (l *CrackProgressLogic) CrackProgress() (resp *types.CrackProgressResp, err error) { |
|
|
|
// todo: add your logic here and delete this line |
|
|
|
result := types.CrackProgressResp{} |
|
|
|
var hashcat *models.THashcat |
|
|
|
tx := l.svcCtx.DbEngin.Where("crack_task_id = ?", req.CrackTaskId).Order("id desc").Limit(1).Find(&hashcat) |
|
|
|
var hashcatList []*models.THashcat |
|
|
|
tx := l.svcCtx.DbEngin.Raw("SELECT h.id, h.speed, h.crack_progress \nFROM t_hashcat h \nJOIN ( \n SELECT crack_task_id, MAX(id) as max_id \n FROM t_hashcat \n GROUP BY crack_task_id \n) AS sub_query ON h.crack_task_id = sub_query.crack_task_id AND h.id = sub_query.max_id \nJOIN cloud c ON h.crack_task_id = c.`name`").Scan(&hashcatList) |
|
|
|
if tx.Error != nil { |
|
|
|
return nil, tx.Error |
|
|
|
} |
|
|
|
if len(hashcat.Speed) != 0 { |
|
|
|
str1 := strings.Split(hashcat.Speed, "@") |
|
|
|
result.Speed = str1[0] |
|
|
|
} |
|
|
|
if len(hashcat.CrackProgress) != 0 { |
|
|
|
str1 := strings.Split(hashcat.CrackProgress, "/") |
|
|
|
result.Current = str1[0] |
|
|
|
str2 := strings.Split(str1[1], " (") |
|
|
|
result.Total = str2[0] |
|
|
|
str3 := strings.Split(str2[1], "%") |
|
|
|
result.Progress = str3[0] |
|
|
|
for _, hashcat := range hashcatList { |
|
|
|
if len(hashcat.Speed) != 0 { |
|
|
|
str1 := strings.Split(hashcat.Speed, "@") |
|
|
|
result.Speed = str1[0] |
|
|
|
} |
|
|
|
if len(hashcat.CrackProgress) != 0 { |
|
|
|
str1 := strings.Split(hashcat.CrackProgress, "/") |
|
|
|
result.Current = str1[0] |
|
|
|
str2 := strings.Split(str1[1], " (") |
|
|
|
result.Total = str2[0] |
|
|
|
str3 := strings.Split(str2[1], "%") |
|
|
|
result.Progress = str3[0] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return &result, nil |
|
|
|
} |