hashcat Crack Progress
Former-commit-id: d3a55c66825a25684102ef5e2361d8ac864f80b1
This commit is contained in:
parent
72d29eccff
commit
7cc3ebdf55
|
@ -554,10 +554,6 @@ type NodeAsset {
|
|||
ParticipantId int64 `json:"ParticipantId"` // 集群动态信息id
|
||||
}
|
||||
|
||||
type crackProgressReq {
|
||||
CrackTaskId string `form:"crackTaskId"`
|
||||
}
|
||||
|
||||
type crackProgressResp {
|
||||
Progress string `json:"progress"`
|
||||
Current string `json:"current"`
|
||||
|
|
|
@ -114,7 +114,7 @@ service pcm {
|
|||
|
||||
@doc "Hashcat Crack Progress"
|
||||
@handler crackProgressHandler
|
||||
get /core/crack/progress (crackProgressReq) returns (crackProgressResp)
|
||||
get /core/crack/progress returns (crackProgressResp)
|
||||
|
||||
@doc "Resource Center Information"
|
||||
@handler resourceCenterInfoHandler
|
||||
|
|
|
@ -6,19 +6,12 @@ import (
|
|||
"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"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
)
|
||||
|
||||
func CrackProgressHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CrackProgressReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := core.NewCrackProgressLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CrackProgress(&req)
|
||||
resp, err := l.CrackProgress()
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -517,10 +517,6 @@ type NodeAsset struct {
|
|||
ParticipantId int64 `json:"ParticipantId"` // 集群动态信息id
|
||||
}
|
||||
|
||||
type CrackProgressReq struct {
|
||||
CrackTaskId string `form:"crackTaskId"`
|
||||
}
|
||||
|
||||
type CrackProgressResp struct {
|
||||
Progress string `json:"progress"`
|
||||
Current string `json:"current"`
|
||||
|
|
Loading…
Reference in New Issue