(response []byte, sig *auth.SigInfo)
| 104 | } |
| 105 | |
| 106 | func parseNtloginResponse(response []byte, sig *auth.SigInfo) (LoginResponse, error) { |
| 107 | var frame login.SsoNTLoginEncryptedData |
| 108 | err := proto.Unmarshal(response, &frame) |
| 109 | if err != nil { |
| 110 | return LoginResponse{ |
| 111 | Success: false, |
| 112 | }, fmt.Errorf("proto decode failed: %w", err) |
| 113 | } |
| 114 | |
| 115 | var base login.SsoNTLoginBase |
| 116 | data, err := crypto.AESGCMDecrypt(frame.GcmCalc, sig.ExchangeKey) |
| 117 | if err != nil { |
| 118 | return LoginResponse{ |
| 119 | Success: false, |
| 120 | }, err |
| 121 | } |
| 122 | err = proto.Unmarshal(data, &base) |
| 123 | if err != nil { |
| 124 | return LoginResponse{ |
| 125 | Success: false, |
| 126 | }, fmt.Errorf("proto decode failed: %w", err) |
| 127 | } |
| 128 | var body login.SsoNTLoginResponse |
| 129 | err = proto.Unmarshal(base.Body, &body) |
| 130 | if err != nil { |
| 131 | return LoginResponse{ |
| 132 | Success: false, |
| 133 | }, fmt.Errorf("proto decode failed: %w", err) |
| 134 | } |
| 135 | |
| 136 | if body.Credentials != nil { |
| 137 | sig.Tgt = body.Credentials.Tgt |
| 138 | sig.D2 = body.Credentials.D2 |
| 139 | sig.D2Key = body.Credentials.D2Key |
| 140 | sig.TempPwd = body.Credentials.TempPassword |
| 141 | return LoginResponse{Success: true}, nil |
| 142 | } |
| 143 | |
| 144 | ret := loginstate.State(base.Header.Error.ErrorCode) |
| 145 | if base.Header.Error != nil && ret.NeedVerify() { |
| 146 | sig.UnusualSig = func() []byte { |
| 147 | if body.Unusual != nil { |
| 148 | return body.Unusual.Sig |
| 149 | } |
| 150 | return nil |
| 151 | }() |
| 152 | sig.Cookies = base.Header.Cookie.Cookie.Unwrap() |
| 153 | sig.NewDeviceVerifyURL = base.Header.Error.NewDeviceVerifyUrl.Unwrap() |
| 154 | err = nil |
| 155 | } |
| 156 | if base.Header.Error.Tag != "" { |
| 157 | stat := base.Header.Error |
| 158 | title := stat.Tag |
| 159 | content := stat.Message |
| 160 | err = fmt.Errorf("login fail on ntlogin(%s): [%s]>%s", ret.Name(), title, content) |
| 161 | } |
| 162 | var loginErr LoginError |
| 163 | var verifyURL string |
no test coverage detected