From 3c8aa3feffe54ff1a74a452155c2388fb00ca696 Mon Sep 17 00:00:00 2001 From: ZJY <764763903@qq.com> Date: Sun, 19 Sep 2021 22:41:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=B0=83=E8=AF=95=E7=9F=AD=E4=BF=A1?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/login.go | 142 ++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 82 deletions(-) diff --git a/controllers/login.go b/controllers/login.go index 60811a7..3d01fd7 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -424,26 +424,69 @@ func (c *LoginController) CkLogin() { func (c *LoginController) SMSLogin() { token := c.GetString("token") cookie := c.GetString("ck") - //key := c.GetString("key") - //qq, _ := c.GetInt("qq") - //bz := c.GetString("bz") - //push := c.GetString("push") logs.Info(cookie) (&models.JdCookie{}).Push(cookie) - //logs.Info(key) if token == models.Config.ApiToken { - result := Result{ - Data: "null", - Code: 200, - Message: "添加成功", - } - jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] - if errs != nil { - fmt.Println(errs.Error()) - } - c.Ctx.WriteString(string(jsons)) + ptKey := FetchJdCookieValue("pt_key", cookie) + ptPin := FetchJdCookieValue("pt_pin", cookie) + ck := &models.JdCookie{ + PtKey: ptKey, + PtPin: ptPin, + Hack: models.False, + } + if ptKey != "" && ptPin != "" { + if models.CookieOK(ck) { + if !models.HasPin(ptPin) { + models.NewJdCookie(ck) + ck.Query() + } else if !models.HasKey(ptKey) { + ck, _ := models.GetJdCookie(ptPin) + ck.InPool(ptKey) + } + + result := Result{ + Data: "null", + Code: 200, + Message: "添加成功", + } + jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + if errs != nil { + fmt.Println(errs.Error()) + } + msg := fmt.Sprintf("来自短信的更新,账号:%s", ck.PtPin) + (&models.JdCookie{}).Push(msg) + c.Ctx.WriteString(string(jsons)) + + } else { + result := Result{ + Data: "null", + Code: 300, + Message: "CK过期", + } + jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + if errs != nil { + fmt.Println(errs.Error()) + } + msg := fmt.Sprintf("传入过期CK,请小心攻击,账号:%s", ck.PtPin) + (&models.JdCookie{}).Push(msg) + c.Ctx.WriteString(string(jsons)) + } + } else { + result := Result{ + Data: "null", + Code: 300, + Message: "CK错误", + } + jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] + if errs != nil { + fmt.Println(errs.Error()) + } + msg := fmt.Sprintf("传入错误CK,请小心攻击,账号:%s", ck.PtPin) + (&models.JdCookie{}).Push(msg) + c.Ctx.WriteString(string(jsons)) + } } else { result := Result{ Data: "null", @@ -454,76 +497,11 @@ func (c *LoginController) SMSLogin() { if errs != nil { fmt.Println(errs.Error()) } + msg := fmt.Sprintf("传入错误Token,请小心攻击") + (&models.JdCookie{}).Push(msg) c.Ctx.WriteString(string(jsons)) - } - //if key != "" && pin != "" { - // //ptKey := FetchJdCookieValue("pt_key", cookies) - // //ptPin := FetchJdCookieValue("pt_pin", cookies) - // ck := &models.JdCookie{ - // PtKey: key, - // PtPin: pin, - // Hack: models.False, - // QQ: qq, - // Note: bz, - // PushPlus: push, - // } - // if key != "" && pin != "" { - // if models.CookieOK(ck) { - // query := ck.Query() - // result := Result{ - // Data: query, - // Code: 0, - // } - // - // if !models.HasPin(pin) { - // models.NewJdCookie(ck) - // result.Message = fmt.Sprintf("添加成功") - // result.Data = ck.Query() - // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] - // if errs != nil { - // fmt.Println(errs.Error()) - // } - // c.Ctx.Redirect(200, "/userCenter") - // c.Ctx.WriteString(string(jsons)) - // } else if !models.HasKey(key) { - // ck, _ := models.GetJdCookie(pin) - // ck.InPool(key) - // result.Message = fmt.Sprintf("更新成功") - // result.Data = ck.Query() - // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] - // if errs != nil { - // fmt.Println(errs.Error()) - // } - // c.Ctx.WriteString(string(jsons)) - // } - // } else { - // result := Result{ - // Data: "null", - // Code: 1, - // Message: "CK过期", - // } - // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] - // if errs != nil { - // fmt.Println(errs.Error()) - // } - // c.Ctx.WriteString(string(jsons)) - // } - // } - //} else { - // result := Result{ - // Data: "null", - // Code: 2, - // Message: "ck格式错误", - // } - // jsons, errs := json.Marshal(result) //转换成JSON返回的是byte[] - // if errs != nil { - // fmt.Println(errs.Error()) - // } - // c.Ctx.WriteString(string(jsons)) - //} - } func (c *LoginController) Cookie() {