MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / buildNtloginRequest

Function buildNtloginRequest

client/ntlogin.go:52–104  ·  view source on GitHub ↗
(uin uint32, app *auth.AppInfo, device *auth.DeviceInfo, sig *auth.SigInfo, credential []byte)

Source from the content-addressed store, hash-verified

50}
51
52func buildNtloginRequest(uin uint32, app *auth.AppInfo, device *auth.DeviceInfo, sig *auth.SigInfo, credential []byte) ([]byte, error) {
53 if sig.ExchangeKey == nil || sig.KeySig == nil {
54 return nil, errors.New("empty key")
55 }
56
57 packet := login.SsoNTLoginBase{
58 Header: &login.SsoNTLoginHeader{
59 Uin: &login.SsoNTLoginUin{Uin: proto.Some(strconv.Itoa(int(uin)))},
60 System: &login.SsoNTLoginSystem{
61 OS: proto.Some(app.OS),
62 DeviceName: proto.Some(device.DeviceName),
63 Type: int32(app.NTLoginType),
64 Guid: utils.MustParseHexStr(device.GUID),
65 },
66 Version: &login.SsoNTLoginVersion{
67 KernelVersion: proto.Some(device.KernelVersion),
68 AppId: int32(app.AppID),
69 PackageName: proto.Some(app.PackageName),
70 },
71 Cookie: &login.SsoNTLoginCookie{Cookie: proto.Some(sig.Cookies)},
72 },
73 Body: func() []byte {
74 body := login.SsoNTLoginEasyLogin{
75 TempPassword: credential,
76 }
77 if all(sig.CaptchaInfo[:3]) {
78 body.Captcha = &login.SsoNTLoginCaptchaSubmit{
79 Ticket: sig.CaptchaInfo[0],
80 RandStr: sig.CaptchaInfo[1],
81 Aid: sig.CaptchaInfo[2],
82 }
83 }
84 b, _ := proto.Marshal(&body)
85 return b
86 }(),
87 }
88
89 pkt, err := proto.Marshal(&packet)
90 if err != nil {
91 return nil, err
92 }
93
94 data, err := crypto.AESGCMEncrypt(pkt, sig.ExchangeKey)
95 if err != nil {
96 return nil, err
97 }
98
99 return proto.Marshal(&login.SsoNTLoginEncryptedData{
100 Sign: sig.KeySig,
101 GcmCalc: data,
102 Type: 1,
103 })
104}
105
106func parseNtloginResponse(response []byte, sig *auth.SigInfo) (LoginResponse, error) {
107 var frame login.SsoNTLoginEncryptedData

Callers 3

TokenLoginMethod · 0.85
NewDeviceVerifyMethod · 0.85

Calls 5

SomeFunction · 0.92
MustParseHexStrFunction · 0.92
MarshalFunction · 0.92
AESGCMEncryptFunction · 0.92
allFunction · 0.85

Tested by

no test coverage detected