hashcat Crack Progress
Former-commit-id: d4ffb11a013d34f2ab9ea2fe8e4b412a58db2f12
This commit is contained in:
parent
7cc3ebdf55
commit
94a9154011
|
@ -555,6 +555,11 @@ type NodeAsset {
|
|||
}
|
||||
|
||||
type crackProgressResp {
|
||||
crackProgressList []CrackProgress `json:"crackProgressList"`
|
||||
}
|
||||
|
||||
type CrackProgress {
|
||||
Name string `json:"name"`
|
||||
Progress string `json:"progress"`
|
||||
Current string `json:"current"`
|
||||
Total string `json:"total"`
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/core"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
)
|
||||
|
@ -12,10 +12,6 @@ func CrackProgressHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := core.NewCrackProgressLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CrackProgress()
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package core
|
|||
|
||||
import (
|
||||
"context"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||
"strings"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
|
@ -28,24 +27,25 @@ func NewCrackProgressLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cra
|
|||
func (l *CrackProgressLogic) CrackProgress() (resp *types.CrackProgressResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
result := types.CrackProgressResp{}
|
||||
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)
|
||||
var crackProgressList []*types.CrackProgress
|
||||
tx := l.svcCtx.DbEngin.Raw("SELECT h.id, h.speed, h.crack_progress as progress,c.`name` \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(&crackProgressList)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
for _, hashcat := range hashcatList {
|
||||
if len(hashcat.Speed) != 0 {
|
||||
str1 := strings.Split(hashcat.Speed, "@")
|
||||
result.Speed = str1[0]
|
||||
for _, crackProgress := range crackProgressList {
|
||||
if len(crackProgress.Speed) != 0 {
|
||||
str1 := strings.Split(crackProgress.Speed, "@")
|
||||
crackProgress.Speed = str1[0]
|
||||
}
|
||||
if len(hashcat.CrackProgress) != 0 {
|
||||
str1 := strings.Split(hashcat.CrackProgress, "/")
|
||||
result.Current = str1[0]
|
||||
if len(crackProgress.Progress) != 0 {
|
||||
str1 := strings.Split(crackProgress.Progress, "/")
|
||||
crackProgress.Current = str1[0]
|
||||
str2 := strings.Split(str1[1], " (")
|
||||
result.Total = str2[0]
|
||||
crackProgress.Total = str2[0]
|
||||
str3 := strings.Split(str2[1], "%")
|
||||
result.Progress = str3[0]
|
||||
crackProgress.Progress = str3[0]
|
||||
}
|
||||
result.CrackProgressList = append(result.CrackProgressList, *crackProgress)
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
|
|
|
@ -518,6 +518,11 @@ type NodeAsset struct {
|
|||
}
|
||||
|
||||
type CrackProgressResp struct {
|
||||
CrackProgressList []CrackProgress `json:"crackProgressList"`
|
||||
}
|
||||
|
||||
type CrackProgress struct {
|
||||
Name string `json:"name"`
|
||||
Progress string `json:"progress"`
|
||||
Current string `json:"current"`
|
||||
Total string `json:"total"`
|
||||
|
|
Loading…
Reference in New Issue