Skip to content

Commit

Permalink
fix: password login (#119)
Browse files Browse the repository at this point in the history
* fix: password login

* fix

* make lint happy

* make lint happy
  • Loading branch information
Redmomn authored Nov 11, 2024
1 parent 32bfe36 commit ad45eae
Show file tree
Hide file tree
Showing 15 changed files with 490 additions and 242 deletions.
19 changes: 12 additions & 7 deletions client/auth/sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ var (
)

type SigInfo struct {
Uin uint32
Sequence uint32
UID string
Tgtgt []byte
Tgt []byte
D2 []byte
D2Key []byte
Uin uint32
Sequence uint32
UID string

Tgtgt []byte
Tgt []byte
D2 []byte
D2Key []byte

Qrsig []byte
ExchangeKey []byte
KeySig []byte
Expand All @@ -29,6 +31,9 @@ type SigInfo struct {
TempPwd []byte
CaptchaInfo [3]string

CaptchaURL string
NewDeviceVerifyURL string

Nickname string
Age uint8
Gender uint8
Expand Down
17 changes: 12 additions & 5 deletions client/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
// 部分借鉴 https://github.com/Mrs4s/MiraiGo/blob/master/client/client.go

import (
"crypto/md5"
"errors"
"net/http"
"net/http/cookiejar"
Expand Down Expand Up @@ -30,11 +31,16 @@ import (
)

// NewClient 创建一个新的 QQ Client
func NewClient(uin uint32, appInfo *auth.AppInfo, signURL ...string) *QQClient {
func NewClient(uin uint32, password string, appInfo *auth.AppInfo, signURL ...string) *QQClient {
return NewClientMD5(uin, md5.Sum([]byte(password)), appInfo, signURL...)
}

func NewClientMD5(uin uint32, passwordMD5 [16]byte, appInfo *auth.AppInfo, signURL ...string) *QQClient {
cookieContainer, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
client := &QQClient{
Uin: uin,
oicq: oicq.NewCodec(int64(uin)),
Uin: uin,
oicq: oicq.NewCodec(int64(uin)),
passwordMD5: passwordMD5,
highwaySession: highway.Session{
AppID: uint32(appInfo.AppID),
SubAppID: uint32(appInfo.SubAppID),
Expand Down Expand Up @@ -65,8 +71,9 @@ type QQClient struct {

Online atomic.Bool

t106 []byte
t16a []byte
t106 []byte
t16a []byte
passwordMD5 [16]byte

UA string

Expand Down
Loading

0 comments on commit ad45eae

Please sign in to comment.